generated from amazon-archives/__template_Custom
-
Notifications
You must be signed in to change notification settings - Fork 179
Pagination: Add Close Cursor API in v2. #1660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Yury-Fridlyand
merged 1 commit into
feature/pagination/integ
from
feature/pagination/close-cursor-api
May 30, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| @Override | ||
| public long getTotalHits() { | ||
| return 0; | ||
| } | ||
|
|
||
| @Override | ||
| public void open() { | ||
| // no-op, no search should be invoked. | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.