Skip to content

Commit

Permalink
Remove paginate operator (#1528)
Browse files Browse the repository at this point in the history
* Remove PaginateOperator class since it is no longer used.


---------

Signed-off-by: MaxKsyunz <[email protected]>
  • Loading branch information
Max Ksyunz authored Apr 17, 2023
1 parent ce509b0 commit dd3df8c
Show file tree
Hide file tree
Showing 11 changed files with 4 additions and 264 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.opensearch.sql.planner.logical.LogicalFilter;
import org.opensearch.sql.planner.logical.LogicalLimit;
import org.opensearch.sql.planner.logical.LogicalNested;
import org.opensearch.sql.planner.logical.LogicalPaginate;
import org.opensearch.sql.planner.logical.LogicalPlan;
import org.opensearch.sql.planner.logical.LogicalPlanNodeVisitor;
import org.opensearch.sql.planner.logical.LogicalProject;
Expand All @@ -29,7 +28,6 @@
import org.opensearch.sql.planner.physical.FilterOperator;
import org.opensearch.sql.planner.physical.LimitOperator;
import org.opensearch.sql.planner.physical.NestedOperator;
import org.opensearch.sql.planner.physical.PaginateOperator;
import org.opensearch.sql.planner.physical.PhysicalPlan;
import org.opensearch.sql.planner.physical.ProjectOperator;
import org.opensearch.sql.planner.physical.RareTopNOperator;
Expand Down Expand Up @@ -134,11 +132,6 @@ public PhysicalPlan visitLimit(LogicalLimit node, C context) {
return new LimitOperator(visitChild(node, context), node.getLimit(), node.getOffset());
}

@Override
public PhysicalPlan visitPaginate(LogicalPaginate plan, C context) {
return new PaginateOperator(visitChild(plan, context), plan.getPageSize());
}

@Override
public PhysicalPlan visitTableScanBuilder(TableScanBuilder plan, C context) {
return plan.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ public LogicalPlan apply(LogicalPaginate plan, Captures captures) {
var scan = logicalRelation.getTable().createPagedScanBuilder(plan.getPageSize());
relationParent.replaceChildPlans(List.of(scan));

return plan;
return plan.getChild().get(0);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,4 @@ public R visitAD(PhysicalPlan node, C context) {
public R visitML(PhysicalPlan node, C context) {
return visitNode(node, context);
}

public R visitPaginate(PaginateOperator node, C context) {
return visitNode(node, context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
import org.opensearch.sql.planner.logical.LogicalPlan;
import org.opensearch.sql.planner.logical.LogicalPlanDSL;
import org.opensearch.sql.planner.logical.LogicalRelation;
import org.opensearch.sql.planner.physical.PaginateOperator;
import org.opensearch.sql.planner.physical.PhysicalPlan;
import org.opensearch.sql.planner.physical.PhysicalPlanDSL;
import org.opensearch.sql.storage.Table;
Expand Down Expand Up @@ -247,11 +246,4 @@ public TableWriteOperator build(PhysicalPlan child) {
};
assertEquals(tableWriteOperator, logicalPlan.accept(implementor, null));
}

@Test
public void visitPaginate_should_build_PaginateOperator_and_keep_page_size() {
var paginate = new LogicalPaginate(42, List.of(values()));
var plan = paginate.accept(implementor, null);
assertEquals(paginate.getPageSize(), ((PaginateOperator) plan).getPageSize());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ void paged_table_scan_builder_support_project_push_down_can_apply_its_rule() {
var relation = relation("schema", table);

assertEquals(
paginate(project(pagedTableScanBuilder), 4),
project(pagedTableScanBuilder),
LogicalPlanOptimizer.create().optimize(paginate(project(relation), 4)));
}

Expand Down Expand Up @@ -401,7 +401,7 @@ void table_scan_builder_support_offset_push_down_can_apply_its_rule() {
.optimize(new LogicalPaginate(42, List.of(project(relation))));
// `optimized` structure: LogicalPaginate -> LogicalProject -> TableScanBuilder
// LogicalRelation replaced by a TableScanBuilder instance
assertEquals(paginate(project(pagedTableScanBuilder), 42), optimized);
assertEquals(project(pagedTableScanBuilder), optimized);
}

private LogicalPlan optimize(LogicalPlan plan) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,6 @@ public void test_visitML() {
assertNull(physicalPlanNodeVisitor.visitML(plan, null));
}

@Test
public void test_visitPaginate() {
PhysicalPlanNodeVisitor physicalPlanNodeVisitor =
new PhysicalPlanNodeVisitor<Integer, Object>() {};

assertNull(physicalPlanNodeVisitor.visitPaginate(new PaginateOperator(plan, 42), null));
}

public static class PhysicalPlanPrinter extends PhysicalPlanNodeVisitor<String, Integer> {

public String print(PhysicalPlan node) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.opensearch.sql.planner.physical.FilterOperator;
import org.opensearch.sql.planner.physical.LimitOperator;
import org.opensearch.sql.planner.physical.NestedOperator;
import org.opensearch.sql.planner.physical.PaginateOperator;
import org.opensearch.sql.planner.physical.PhysicalPlan;
import org.opensearch.sql.planner.physical.ProjectOperator;
import org.opensearch.sql.planner.physical.RareTopNOperator;
Expand Down Expand Up @@ -65,12 +64,6 @@ public PhysicalPlan visitRename(RenameOperator node, Object context) {
return new RenameOperator(visitInput(node.getInput(), context), node.getMapping());
}

@Override
public PhysicalPlan visitPaginate(PaginateOperator node, Object context) {
return new PaginateOperator(visitInput(node.getInput(), context), node.getPageSize(),
node.getPageIndex());
}

/**
* Decorate with {@link ResourceMonitorPlan}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@
import org.opensearch.sql.opensearch.client.OpenSearchClient;
import org.opensearch.sql.opensearch.data.value.OpenSearchExprValueFactory;
import org.opensearch.sql.opensearch.executor.protector.OpenSearchExecutionProtector;
import org.opensearch.sql.opensearch.request.OpenSearchRequestBuilder;
import org.opensearch.sql.opensearch.storage.scan.OpenSearchIndexScan;
import org.opensearch.sql.planner.SerializablePlan;
import org.opensearch.sql.planner.physical.PaginateOperator;
import org.opensearch.sql.planner.physical.PhysicalPlan;
import org.opensearch.sql.storage.TableScanOperator;
import org.opensearch.sql.storage.split.Split;
Expand Down Expand Up @@ -120,7 +118,7 @@ void execute_with_cursor() {
List<ExprValue> expected =
Arrays.asList(
tupleValue(of("name", "John", "age", 20)), tupleValue(of("name", "Allen", "age", 30)));
FakePaginatePlan plan = new FakePaginatePlan(new FakePhysicalPlan(expected.iterator()), 10, 0);
var plan = new FakePhysicalPlan(expected.iterator());
when(protector.protect(plan)).thenReturn(plan);

OpenSearchExecutionEngine executor = new OpenSearchExecutionEngine(client, protector,
Expand Down Expand Up @@ -255,49 +253,6 @@ public void onFailure(Exception e) {
assertTrue(plan.hasClosed);
}

private static class FakePaginatePlan extends PaginateOperator {
private final PhysicalPlan input;
private final int pageSize;
private final int pageIndex;

public FakePaginatePlan(PhysicalPlan input, int pageSize, int pageIndex) {
super(input, pageSize, pageIndex);
this.input = input;
this.pageSize = pageSize;
this.pageIndex = pageIndex;
}

@Override
public void open() {
input.open();
}

@Override
public void close() {
input.close();
}

@Override
public void add(Split split) {
input.add(split);
}

@Override
public boolean hasNext() {
return input.hasNext();
}

@Override
public ExprValue next() {
return input.next();
}

@Override
public ExecutionEngine.Schema schema() {
return input.schema();
}
}

@RequiredArgsConstructor
private static class FakePhysicalPlan extends TableScanOperator implements SerializablePlan {
private final Iterator<ExprValue> it;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
import org.opensearch.sql.opensearch.setting.OpenSearchSettings;
import org.opensearch.sql.opensearch.storage.scan.OpenSearchIndexScan;
import org.opensearch.sql.planner.physical.NestedOperator;
import org.opensearch.sql.planner.physical.PaginateOperator;
import org.opensearch.sql.planner.physical.PhysicalPlan;
import org.opensearch.sql.planner.physical.PhysicalPlanDSL;

Expand Down Expand Up @@ -335,13 +334,6 @@ public void testVisitNested() {
executionProtector.visitNested(nestedOperator, values(emptyList())));
}

@Test
public void visitPaginate() {
var paginate = new PaginateOperator(values(List.of()), 42);
assertEquals(executionProtector.protect(paginate),
executionProtector.visitPaginate(paginate, null));
}

PhysicalPlan resourceMonitor(PhysicalPlan input) {
return new ResourceMonitorPlan(input, resourceMonitor);
}
Expand Down

0 comments on commit dd3df8c

Please sign in to comment.