Skip to content

Commit d1ceb2c

Browse files
committed
Renamed PreOptimizer into LogicalPlanPreOptimizer
1 parent f58d40a commit d1ceb2c

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/execution/PlanExecutor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import org.elasticsearch.xpack.esql.expression.function.EsqlFunctionRegistry;
2222
import org.elasticsearch.xpack.esql.optimizer.LogicalOptimizerContext;
2323
import org.elasticsearch.xpack.esql.optimizer.LogicalPlanOptimizer;
24-
import org.elasticsearch.xpack.esql.optimizer.PreOptimizer;
24+
import org.elasticsearch.xpack.esql.optimizer.LogicalPlanPreOptimizer;
2525
import org.elasticsearch.xpack.esql.planner.mapper.Mapper;
2626
import org.elasticsearch.xpack.esql.plugin.TransportActionServices;
2727
import org.elasticsearch.xpack.esql.querylog.EsqlQueryLog;
@@ -86,7 +86,7 @@ public void esql(
8686
indexResolver,
8787
enrichPolicyResolver,
8888
preAnalyzer,
89-
new PreOptimizer(services, foldContext),
89+
new LogicalPlanPreOptimizer(services, foldContext),
9090
functionRegistry,
9191
new LogicalPlanOptimizer(new LogicalOptimizerContext(cfg, foldContext)),
9292
mapper,

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/PreOptimizer.java renamed to x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanPreOptimizer.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@
2929
* This is useful, especially if you need to execute some async tasks before the plan is optimized.
3030
* </p>
3131
*/
32-
public class PreOptimizer {
32+
public class LogicalPlanPreOptimizer {
3333

3434
private final InferencePreOptimizer inferencePreOptimizer;
3535

36-
public PreOptimizer(TransportActionServices services, FoldContext foldContext) {
36+
public LogicalPlanPreOptimizer(TransportActionServices services, FoldContext foldContext) {
3737
this(services.inferenceRunner(), foldContext);
3838
}
3939

40-
PreOptimizer(InferenceRunner inferenceRunner, FoldContext foldContext) {
40+
LogicalPlanPreOptimizer(InferenceRunner inferenceRunner, FoldContext foldContext) {
4141
this.inferencePreOptimizer = new InferencePreOptimizer(inferenceRunner, foldContext);
4242
}
4343

@@ -78,9 +78,12 @@ private void foldInferenceFunctions(LogicalPlan plan, ActionListener<LogicalPlan
7878

7979
// Prepare a listener that will be called when all inference functions are done.
8080
// This listener will replace the inference functions in the plan with their results.
81-
CountDownActionListener completionListener = new CountDownActionListener(inferenceFunctions.size(), listener.map(ignored ->
82-
plan.transformExpressionsUp(InferenceFunction.class, f -> inferenceFunctionsToResults.getOrDefault(f, f))
83-
));
81+
CountDownActionListener completionListener = new CountDownActionListener(
82+
inferenceFunctions.size(),
83+
listener.map(
84+
ignored -> plan.transformExpressionsUp(InferenceFunction.class, f -> inferenceFunctionsToResults.getOrDefault(f, f))
85+
)
86+
);
8487

8588
// Try to compute the result for each inference function.
8689
for (InferenceFunction<?> inferenceFunction : inferenceFunctions) {

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session/EsqlSession.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@
7272
import org.elasticsearch.xpack.esql.inference.InferenceResolution;
7373
import org.elasticsearch.xpack.esql.inference.InferenceResolver;
7474
import org.elasticsearch.xpack.esql.optimizer.LogicalPlanOptimizer;
75+
import org.elasticsearch.xpack.esql.optimizer.LogicalPlanPreOptimizer;
7576
import org.elasticsearch.xpack.esql.optimizer.PhysicalOptimizerContext;
7677
import org.elasticsearch.xpack.esql.optimizer.PhysicalPlanOptimizer;
77-
import org.elasticsearch.xpack.esql.optimizer.PreOptimizer;
7878
import org.elasticsearch.xpack.esql.parser.EsqlParser;
7979
import org.elasticsearch.xpack.esql.parser.QueryParams;
8080
import org.elasticsearch.xpack.esql.plan.IndexPattern;
@@ -146,9 +146,9 @@ public interface PlanRunner {
146146
private final EnrichPolicyResolver enrichPolicyResolver;
147147

148148
private final PreAnalyzer preAnalyzer;
149-
private final PreOptimizer preOptimizer;
150149
private final Verifier verifier;
151150
private final EsqlFunctionRegistry functionRegistry;
151+
private final LogicalPlanPreOptimizer logicalPlanPreOptimizer;
152152
private final LogicalPlanOptimizer logicalPlanOptimizer;
153153
private final PreMapper preMapper;
154154

@@ -170,7 +170,7 @@ public EsqlSession(
170170
IndexResolver indexResolver,
171171
EnrichPolicyResolver enrichPolicyResolver,
172172
PreAnalyzer preAnalyzer,
173-
PreOptimizer preOptimizer,
173+
LogicalPlanPreOptimizer logicalPlanPreOptimizer,
174174
EsqlFunctionRegistry functionRegistry,
175175
LogicalPlanOptimizer logicalPlanOptimizer,
176176
Mapper mapper,
@@ -194,7 +194,7 @@ public EsqlSession(
194194
this.indicesExpressionGrouper = indicesExpressionGrouper;
195195
this.inferenceResolver = inferenceResolver;
196196
this.preMapper = new PreMapper(services);
197-
this.preOptimizer = preOptimizer;
197+
this.logicalPlanPreOptimizer = logicalPlanPreOptimizer;
198198
this.remoteClusterService = services.transportService().getRemoteClusterService();
199199
}
200200

@@ -217,7 +217,7 @@ public void execute(EsqlQueryRequest request, EsqlExecutionInfo executionInfo, P
217217
analyzedPlan(parsed, executionInfo, request.filter(), new EsqlCCSUtils.CssPartialErrorsActionListener(executionInfo, listener) {
218218
@Override
219219
public void onResponse(LogicalPlan analyzedPlan) {
220-
SubscribableListener.<LogicalPlan>newForked(l -> preOptimizer.preOptimize(analyzedPlan, l))
220+
SubscribableListener.<LogicalPlan>newForked(l -> logicalPlanPreOptimizer.preOptimize(analyzedPlan, l))
221221
.<LogicalPlan>andThen((l, p) -> preMapper.preMapper(optimizedPlan(p), l))
222222
.<Result>andThen((l, p) -> executeOptimizedPlan(request, executionInfo, planRunner, p, l))
223223
.addListener(listener);

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/PreOptimizerTests.java renamed to x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanPreOptimizerTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import static org.hamcrest.Matchers.hasSize;
4141
import static org.hamcrest.Matchers.notNullValue;
4242

43-
public class PreOptimizerTests extends ESTestCase {
43+
public class LogicalPlanPreOptimizerTests extends ESTestCase {
4444

4545
public void testEvalFunctionEmbeddingBytes() throws Exception {
4646
testEvalFunctionEmbedding(BYTES_EMBEDDING_MODEL);
@@ -71,7 +71,7 @@ private void testEvalFunctionEmbedding(TextEmbeddingModelMock textEmbeddingModel
7171
String query = String.join(" ", randomArray(1, String[]::new, () -> randomAlphaOfLength(randomIntBetween(1, 10))));
7272
String fieldName = randomIdentifier();
7373

74-
PreOptimizer preOptimizer = new PreOptimizer(mockInferenceRunner(textEmbeddingModel), FoldContext.small());
74+
LogicalPlanPreOptimizer preOptimizer = new LogicalPlanPreOptimizer(mockInferenceRunner(textEmbeddingModel), FoldContext.small());
7575
EsRelation relation = relation();
7676
Eval eval = new Eval(
7777
Source.EMPTY,
@@ -99,7 +99,7 @@ private void testKnnFunctionEmbedding(TextEmbeddingModelMock textEmbeddingModel)
9999
String inferenceId = randomUUID();
100100
String query = String.join(" ", randomArray(1, String[]::new, () -> randomAlphaOfLength(randomIntBetween(1, 10))));
101101

102-
PreOptimizer preOptimizer = new PreOptimizer(mockInferenceRunner(textEmbeddingModel), FoldContext.small());
102+
LogicalPlanPreOptimizer preOptimizer = new LogicalPlanPreOptimizer(mockInferenceRunner(textEmbeddingModel), FoldContext.small());
103103
EsRelation relation = relation();
104104
Filter filter = new Filter(
105105
Source.EMPTY,

0 commit comments

Comments
 (0)