1 | /* | |
2 | * Copyright OpenSearch Contributors | |
3 | * SPDX-License-Identifier: Apache-2.0 | |
4 | */ | |
5 | ||
6 | ||
7 | package org.opensearch.sql.planner; | |
8 | ||
9 | import org.opensearch.sql.planner.logical.LogicalAggregation; | |
10 | import org.opensearch.sql.planner.logical.LogicalDedupe; | |
11 | import org.opensearch.sql.planner.logical.LogicalEval; | |
12 | import org.opensearch.sql.planner.logical.LogicalFilter; | |
13 | import org.opensearch.sql.planner.logical.LogicalLimit; | |
14 | import org.opensearch.sql.planner.logical.LogicalPlan; | |
15 | import org.opensearch.sql.planner.logical.LogicalPlanNodeVisitor; | |
16 | import org.opensearch.sql.planner.logical.LogicalProject; | |
17 | import org.opensearch.sql.planner.logical.LogicalRareTopN; | |
18 | import org.opensearch.sql.planner.logical.LogicalRelation; | |
19 | import org.opensearch.sql.planner.logical.LogicalRemove; | |
20 | import org.opensearch.sql.planner.logical.LogicalRename; | |
21 | import org.opensearch.sql.planner.logical.LogicalSort; | |
22 | import org.opensearch.sql.planner.logical.LogicalValues; | |
23 | import org.opensearch.sql.planner.logical.LogicalWindow; | |
24 | import org.opensearch.sql.planner.physical.AggregationOperator; | |
25 | import org.opensearch.sql.planner.physical.DedupeOperator; | |
26 | import org.opensearch.sql.planner.physical.EvalOperator; | |
27 | import org.opensearch.sql.planner.physical.FilterOperator; | |
28 | import org.opensearch.sql.planner.physical.LimitOperator; | |
29 | import org.opensearch.sql.planner.physical.PhysicalPlan; | |
30 | import org.opensearch.sql.planner.physical.ProjectOperator; | |
31 | import org.opensearch.sql.planner.physical.RareTopNOperator; | |
32 | import org.opensearch.sql.planner.physical.RemoveOperator; | |
33 | import org.opensearch.sql.planner.physical.RenameOperator; | |
34 | import org.opensearch.sql.planner.physical.SortOperator; | |
35 | import org.opensearch.sql.planner.physical.ValuesOperator; | |
36 | import org.opensearch.sql.planner.physical.WindowOperator; | |
37 | ||
38 | /** | |
39 | * Default implementor for implementing logical to physical translation. "Default" here means all | |
40 | * logical operator will be translated to correspondent physical operator to pipeline operations | |
41 | * in post-processing style in memory. | |
42 | * Different storage can override methods here to optimize default pipelining operator, for example | |
43 | * a storage has the flexibility to override visitFilter and visitRelation to push down filtering | |
44 | * operation and return a single physical index scan operator. | |
45 | * | |
46 | * @param <C> context type | |
47 | */ | |
48 | public class DefaultImplementor<C> extends LogicalPlanNodeVisitor<PhysicalPlan, C> { | |
49 | ||
50 | @Override | |
51 | public PhysicalPlan visitRareTopN(LogicalRareTopN node, C context) { | |
52 |
1
1. visitRareTopN : replaced return value with null for org/opensearch/sql/planner/DefaultImplementor::visitRareTopN → KILLED |
return new RareTopNOperator( |
53 | visitChild(node, context), | |
54 | node.getCommandType(), | |
55 | node.getNoOfResults(), | |
56 | node.getFieldList(), | |
57 | node.getGroupByList() | |
58 | ); | |
59 | } | |
60 | ||
61 | @Override | |
62 | public PhysicalPlan visitDedupe(LogicalDedupe node, C context) { | |
63 |
1
1. visitDedupe : replaced return value with null for org/opensearch/sql/planner/DefaultImplementor::visitDedupe → KILLED |
return new DedupeOperator( |
64 | visitChild(node, context), | |
65 | node.getDedupeList(), | |
66 | node.getAllowedDuplication(), | |
67 | node.getKeepEmpty(), | |
68 | node.getConsecutive()); | |
69 | } | |
70 | ||
71 | @Override | |
72 | public PhysicalPlan visitProject(LogicalProject node, C context) { | |
73 |
1
1. visitProject : replaced return value with null for org/opensearch/sql/planner/DefaultImplementor::visitProject → KILLED |
return new ProjectOperator(visitChild(node, context), node.getProjectList(), |
74 | node.getNamedParseExpressions()); | |
75 | } | |
76 | ||
77 | @Override | |
78 | public PhysicalPlan visitWindow(LogicalWindow node, C context) { | |
79 |
1
1. visitWindow : replaced return value with null for org/opensearch/sql/planner/DefaultImplementor::visitWindow → KILLED |
return new WindowOperator( |
80 | visitChild(node, context), | |
81 | node.getWindowFunction(), | |
82 | node.getWindowDefinition()); | |
83 | } | |
84 | ||
85 | @Override | |
86 | public PhysicalPlan visitRemove(LogicalRemove node, C context) { | |
87 |
1
1. visitRemove : replaced return value with null for org/opensearch/sql/planner/DefaultImplementor::visitRemove → KILLED |
return new RemoveOperator(visitChild(node, context), node.getRemoveList()); |
88 | } | |
89 | ||
90 | @Override | |
91 | public PhysicalPlan visitEval(LogicalEval node, C context) { | |
92 |
1
1. visitEval : replaced return value with null for org/opensearch/sql/planner/DefaultImplementor::visitEval → KILLED |
return new EvalOperator(visitChild(node, context), node.getExpressions()); |
93 | } | |
94 | ||
95 | @Override | |
96 | public PhysicalPlan visitSort(LogicalSort node, C context) { | |
97 |
1
1. visitSort : replaced return value with null for org/opensearch/sql/planner/DefaultImplementor::visitSort → KILLED |
return new SortOperator(visitChild(node, context), node.getSortList()); |
98 | } | |
99 | ||
100 | @Override | |
101 | public PhysicalPlan visitRename(LogicalRename node, C context) { | |
102 |
1
1. visitRename : replaced return value with null for org/opensearch/sql/planner/DefaultImplementor::visitRename → KILLED |
return new RenameOperator(visitChild(node, context), node.getRenameMap()); |
103 | } | |
104 | ||
105 | @Override | |
106 | public PhysicalPlan visitAggregation(LogicalAggregation node, C context) { | |
107 |
1
1. visitAggregation : replaced return value with null for org/opensearch/sql/planner/DefaultImplementor::visitAggregation → KILLED |
return new AggregationOperator( |
108 | visitChild(node, context), node.getAggregatorList(), node.getGroupByList()); | |
109 | } | |
110 | ||
111 | @Override | |
112 | public PhysicalPlan visitFilter(LogicalFilter node, C context) { | |
113 |
1
1. visitFilter : replaced return value with null for org/opensearch/sql/planner/DefaultImplementor::visitFilter → KILLED |
return new FilterOperator(visitChild(node, context), node.getCondition()); |
114 | } | |
115 | ||
116 | @Override | |
117 | public PhysicalPlan visitValues(LogicalValues node, C context) { | |
118 |
1
1. visitValues : replaced return value with null for org/opensearch/sql/planner/DefaultImplementor::visitValues → KILLED |
return new ValuesOperator(node.getValues()); |
119 | } | |
120 | ||
121 | @Override | |
122 | public PhysicalPlan visitLimit(LogicalLimit node, C context) { | |
123 |
1
1. visitLimit : replaced return value with null for org/opensearch/sql/planner/DefaultImplementor::visitLimit → KILLED |
return new LimitOperator(visitChild(node, context), node.getLimit(), node.getOffset()); |
124 | } | |
125 | ||
126 | @Override | |
127 | public PhysicalPlan visitRelation(LogicalRelation node, C context) { | |
128 | throw new UnsupportedOperationException("Storage engine is responsible for " | |
129 | + "implementing and optimizing logical plan with relation involved"); | |
130 | } | |
131 | ||
132 | protected PhysicalPlan visitChild(LogicalPlan node, C context) { | |
133 | // Logical operators visited here must have a single child | |
134 |
1
1. visitChild : replaced return value with null for org/opensearch/sql/planner/DefaultImplementor::visitChild → KILLED |
return node.getChild().get(0).accept(this, context); |
135 | } | |
136 | ||
137 | } | |
Mutations | ||
52 |
1.1 |
|
63 |
1.1 |
|
73 |
1.1 |
|
79 |
1.1 |
|
87 |
1.1 |
|
92 |
1.1 |
|
97 |
1.1 |
|
102 |
1.1 |
|
107 |
1.1 |
|
113 |
1.1 |
|
118 |
1.1 |
|
123 |
1.1 |
|
134 |
1.1 |