-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
- Loading branch information
1 parent
9ebdda5
commit 92e9fb7
Showing
35 changed files
with
876 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
core/src/main/java/org/opensearch/sql/ast/tree/CloseCursor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.sql.ast.tree; | ||
|
||
import java.util.List; | ||
import org.opensearch.sql.ast.AbstractNodeVisitor; | ||
import org.opensearch.sql.ast.Node; | ||
|
||
/** | ||
* AST node to represent close cursor operation. | ||
* Actually a wrapper to the AST. | ||
*/ | ||
public class CloseCursor extends UnresolvedPlan { | ||
|
||
/** | ||
* An instance of {@link FetchCursor}. | ||
*/ | ||
private UnresolvedPlan cursor; | ||
|
||
@Override | ||
public <T, C> T accept(AbstractNodeVisitor<T, C> nodeVisitor, C context) { | ||
return nodeVisitor.visitCloseCursor(this, context); | ||
} | ||
|
||
@Override | ||
public UnresolvedPlan attach(UnresolvedPlan child) { | ||
this.cursor = child; | ||
return this; | ||
} | ||
|
||
@Override | ||
public List<? extends Node> getChild() { | ||
return List.of(cursor); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
core/src/main/java/org/opensearch/sql/executor/execution/CommandPlan.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.sql.executor.execution; | ||
|
||
import org.opensearch.sql.ast.tree.UnresolvedPlan; | ||
import org.opensearch.sql.common.response.ResponseListener; | ||
import org.opensearch.sql.executor.ExecutionEngine; | ||
import org.opensearch.sql.executor.QueryId; | ||
import org.opensearch.sql.executor.QueryService; | ||
|
||
/** | ||
* Query plan which does not reflect a search query being executed. | ||
* It contains a command or an action, for example, a DDL query. | ||
*/ | ||
public class CommandPlan extends AbstractPlan { | ||
|
||
/** | ||
* The query plan ast. | ||
*/ | ||
protected final UnresolvedPlan plan; | ||
|
||
/** | ||
* Query service. | ||
*/ | ||
protected final QueryService queryService; | ||
|
||
protected final ResponseListener<ExecutionEngine.QueryResponse> listener; | ||
|
||
/** Constructor. */ | ||
public CommandPlan(QueryId queryId, UnresolvedPlan plan, QueryService queryService, | ||
ResponseListener<ExecutionEngine.QueryResponse> listener) { | ||
super(queryId); | ||
this.plan = plan; | ||
this.queryService = queryService; | ||
this.listener = listener; | ||
} | ||
|
||
@Override | ||
public void execute() { | ||
queryService.execute(plan, listener); | ||
} | ||
|
||
@Override | ||
public void explain(ResponseListener<ExecutionEngine.ExplainResponse> listener) { | ||
throw new UnsupportedOperationException("CommandPlan does not support explain"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
core/src/main/java/org/opensearch/sql/planner/logical/LogicalCloseCursor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.sql.planner.logical; | ||
|
||
import java.util.List; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.ToString; | ||
|
||
/** | ||
* A logical plan node which wraps {@link org.opensearch.sql.planner.LogicalCursor} | ||
* and represent a cursor close operation. | ||
*/ | ||
@ToString | ||
@EqualsAndHashCode(callSuper = false) | ||
public class LogicalCloseCursor extends LogicalPlan { | ||
|
||
public LogicalCloseCursor(LogicalPlan child) { | ||
super(List.of(child)); | ||
} | ||
|
||
@Override | ||
public <R, C> R accept(LogicalPlanNodeVisitor<R, C> visitor, C context) { | ||
return visitor.visitCloseCursor(this, context); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
core/src/main/java/org/opensearch/sql/planner/physical/CursorCloseOperator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.sql.planner.physical; | ||
|
||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.opensearch.sql.data.model.ExprValue; | ||
import org.opensearch.sql.executor.ExecutionEngine; | ||
|
||
/** | ||
* A plan node which blocks issuing a request in {@link #open} and | ||
* getting results in {@link #hasNext}, but doesn't block releasing resources in {@link #close}. | ||
* Designed to be on top of the deserialized tree. | ||
*/ | ||
@RequiredArgsConstructor | ||
public class CursorCloseOperator extends PhysicalPlan { | ||
|
||
// Entire deserialized from cursor plan tree | ||
private final PhysicalPlan input; | ||
|
||
@Override | ||
public <R, C> R accept(PhysicalPlanNodeVisitor<R, C> visitor, C context) { | ||
return visitor.visitCursorClose(this, context); | ||
} | ||
|
||
@Override | ||
public boolean hasNext() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public ExprValue next() { | ||
throw new IllegalStateException(); | ||
} | ||
|
||
@Override | ||
public List<PhysicalPlan> getChild() { | ||
return List.of(input); | ||
} | ||
|
||
/** | ||
* Provides an empty schema, because this plan node is always located on the top of the tree. | ||
*/ | ||
@Override | ||
public ExecutionEngine.Schema schema() { | ||
return new ExecutionEngine.Schema(List.of()); | ||
} | ||
|
||
// TODO remove | ||
@Override | ||
public long getTotalHits() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public void open() { | ||
// no-op, no search should be invoked. | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.