forked from opensearch-project/sql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added push down page size from `LogicalPaginate` to `LogicalRelation`. * Improved cursor encoding and decoding. * Added cursor compression. * Fixed issuing `SearchScrollRequest`. * Fixed returning last empty page. * Minor code grooming/commenting. Signed-off-by: Yury-Fridlyand <[email protected]>
- Loading branch information
1 parent
7b508db
commit 2c1b2f9
Showing
16 changed files
with
205 additions
and
78 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
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
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/optimizer/rule/PushPageSize.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.optimizer.rule; | ||
|
||
import static org.opensearch.sql.planner.optimizer.pattern.Patterns.pagination; | ||
|
||
import com.facebook.presto.matching.Capture; | ||
import com.facebook.presto.matching.Captures; | ||
import com.facebook.presto.matching.Pattern; | ||
import lombok.Getter; | ||
import lombok.experimental.Accessors; | ||
import org.opensearch.sql.planner.logical.LogicalPaginate; | ||
import org.opensearch.sql.planner.logical.LogicalPlan; | ||
import org.opensearch.sql.planner.logical.LogicalRelation; | ||
import org.opensearch.sql.planner.optimizer.Rule; | ||
|
||
import java.util.Objects; | ||
|
||
public class PushPageSize | ||
implements Rule<LogicalPaginate> { | ||
/** Capture the table inside matched logical paginate operator. */ | ||
private final Capture<Integer> capture; | ||
|
||
/** Pattern that matches logical paginate operator. */ | ||
@Accessors(fluent = true) | ||
@Getter | ||
private final Pattern<LogicalPaginate> pattern; | ||
|
||
/** | ||
* Constructor. | ||
*/ | ||
public PushPageSize() { | ||
this.capture = Capture.newCapture(); | ||
this.pattern = Pattern.typeOf(LogicalPaginate.class) | ||
.with(pagination().capturedAs(capture)); | ||
} | ||
|
||
private LogicalRelation findLogicalRelation(LogicalPlan plan) { //TODO TBD multiple relations? | ||
for (var subplan : plan.getChild()) { | ||
if (subplan instanceof LogicalRelation) { | ||
return (LogicalRelation) subplan; | ||
} | ||
var found = findLogicalRelation(subplan); | ||
if (found != null) { | ||
return found; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public LogicalPlan apply(LogicalPaginate plan, Captures captures) { | ||
var relation = findLogicalRelation(plan); | ||
if (relation != null) { | ||
relation.setPageSize(captures.get(capture)); | ||
} | ||
return plan; | ||
} | ||
} |
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.