Skip to content

Commit 1f90d8c

Browse files
authored
Hook in the optimizer rules (#52172)
1 parent e5ad72b commit 1f90d8c

File tree

1 file changed

+26
-2
lines changed
  • x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/optimizer

1 file changed

+26
-2
lines changed

x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/optimizer/Optimizer.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,18 @@
66

77
package org.elasticsearch.xpack.eql.optimizer;
88

9+
import org.elasticsearch.xpack.ql.optimizer.OptimizerRules.BooleanLiteralsOnTheRight;
10+
import org.elasticsearch.xpack.ql.optimizer.OptimizerRules.BooleanSimplification;
11+
import org.elasticsearch.xpack.ql.optimizer.OptimizerRules.CombineBinaryComparisons;
12+
import org.elasticsearch.xpack.ql.optimizer.OptimizerRules.ConstantFolding;
13+
import org.elasticsearch.xpack.ql.optimizer.OptimizerRules.PropagateEquals;
14+
import org.elasticsearch.xpack.ql.optimizer.OptimizerRules.PruneFilters;
15+
import org.elasticsearch.xpack.ql.optimizer.OptimizerRules.PruneLiteralsInOrderBy;
16+
import org.elasticsearch.xpack.ql.optimizer.OptimizerRules.SetAsOptimized;
917
import org.elasticsearch.xpack.ql.plan.logical.LogicalPlan;
1018
import org.elasticsearch.xpack.ql.rule.RuleExecutor;
1119

12-
import static java.util.Collections.emptyList;
20+
import java.util.Arrays;
1321

1422
public class Optimizer extends RuleExecutor<LogicalPlan> {
1523

@@ -19,6 +27,22 @@ public LogicalPlan optimize(LogicalPlan verified) {
1927

2028
@Override
2129
protected Iterable<RuleExecutor<LogicalPlan>.Batch> batches() {
22-
return emptyList();
30+
Batch operators = new Batch("Operator Optimization",
31+
new ConstantFolding(),
32+
// boolean
33+
new BooleanSimplification(),
34+
new BooleanLiteralsOnTheRight(),
35+
// needs to occur before BinaryComparison combinations
36+
new PropagateEquals(),
37+
new CombineBinaryComparisons(),
38+
// prune/elimination
39+
new PruneFilters(),
40+
new PruneLiteralsInOrderBy()
41+
);
42+
43+
Batch label = new Batch("Set as Optimized", Limiter.ONCE,
44+
new SetAsOptimized());
45+
46+
return Arrays.asList(operators, label);
2347
}
2448
}

0 commit comments

Comments
 (0)