Skip to content

Commit 3e02b86

Browse files
author
Lukas Wegmann
authored
QL: Make UnaryPlan.replaceChild public and use it where appropriate (#76071)
1 parent 0fd3f76 commit 3e02b86

File tree

19 files changed

+22
-25
lines changed

19 files changed

+22
-25
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
import java.util.Objects;
6666

6767
import static java.util.Arrays.asList;
68-
import static java.util.Collections.singletonList;
6968
import static java.util.stream.Collectors.toList;
7069
import static org.elasticsearch.xpack.ql.optimizer.OptimizerRules.PropagateNullable;
7170

@@ -448,13 +447,13 @@ protected LogicalPlan rule(OrderBy orderBy) {
448447
// preserve the order for the base query, everything else needs to be ascending
449448
List<Order> pushedOrder = baseFilter ? orderBy.order() : ascendingOrders;
450449
OrderBy order = new OrderBy(filter.source(), filter.child(), pushedOrder);
451-
orderedQueries.add((KeyedFilter) filter.replaceChildrenSameSize(singletonList(order)));
450+
orderedQueries.add(filter.replaceChild(order));
452451
baseFilter = false;
453452
}
454453

455454
KeyedFilter until = join.until();
456455
OrderBy order = new OrderBy(until.source(), until.child(), ascendingOrders);
457-
until = (KeyedFilter) until.replaceChildrenSameSize(singletonList(order));
456+
until = until.replaceChild(order);
458457

459458
OrderDirection direction = orderBy.order().get(0).direction();
460459
plan = join.with(orderedQueries, until, direction);

x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plan/logical/Head.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protected NodeInfo<Limit> info() {
2525
}
2626

2727
@Override
28-
protected Head replaceChild(LogicalPlan newChild) {
28+
public Head replaceChild(LogicalPlan newChild) {
2929
return new Head(source(), limit(), newChild);
3030
}
3131
}

x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plan/logical/KeyedFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected NodeInfo<KeyedFilter> info() {
4343
}
4444

4545
@Override
46-
protected KeyedFilter replaceChild(LogicalPlan newChild) {
46+
public KeyedFilter replaceChild(LogicalPlan newChild) {
4747
return new KeyedFilter(source(), newChild, keys, timestamp, tiebreaker);
4848
}
4949

x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plan/logical/LimitWithOffset.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected NodeInfo<Limit> info() {
3434
}
3535

3636
@Override
37-
protected LimitWithOffset replaceChild(LogicalPlan newChild) {
37+
public LimitWithOffset replaceChild(LogicalPlan newChild) {
3838
return new LimitWithOffset(source(), limit(), offset, newChild);
3939
}
4040

x-pack/plugin/eql/src/main/java/org/elasticsearch/xpack/eql/plan/logical/Tail.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected NodeInfo<Limit> info() {
3333
}
3434

3535
@Override
36-
protected Tail replaceChild(LogicalPlan newChild) {
36+
public Tail replaceChild(LogicalPlan newChild) {
3737
return new Tail(source(), newChild, limit());
3838
}
3939
}

x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/optimizer/OptimizerRules.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868

6969
import static java.lang.Math.signum;
7070
import static java.util.Arrays.asList;
71-
import static java.util.Collections.singletonList;
7271
import static org.elasticsearch.xpack.ql.expression.Literal.FALSE;
7372
import static org.elasticsearch.xpack.ql.expression.Literal.TRUE;
7473
import static org.elasticsearch.xpack.ql.expression.predicate.Predicates.combineAnd;
@@ -1207,14 +1206,12 @@ else if (child instanceof UnaryPlan) {
12071206
}
12081207
// if at least one expression can be pushed down, update the tree
12091208
if (conjunctions.size() > 0) {
1210-
child = child.replaceChildrenSameSize(
1211-
singletonList(filter.with(unary.child(), Predicates.combineAnd(conjunctions)))
1212-
);
1209+
child = unary.replaceChild(filter.with(unary.child(), Predicates.combineAnd(conjunctions)));
12131210
plan = filter.with(child, Predicates.combineAnd(inPlace));
12141211
}
12151212
} else {
12161213
// push down filter
1217-
plan = child.replaceChildrenSameSize(singletonList(filter.with(unary.child(), condition)));
1214+
plan = unary.replaceChild(filter.with(unary.child(), condition));
12181215
}
12191216
}
12201217

x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/plan/logical/Aggregate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected NodeInfo<Aggregate> info() {
3434
}
3535

3636
@Override
37-
protected Aggregate replaceChild(LogicalPlan newChild) {
37+
public Aggregate replaceChild(LogicalPlan newChild) {
3838
return new Aggregate(source(), newChild, groupings, aggregates);
3939
}
4040

x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/plan/logical/Filter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ protected NodeInfo<Filter> info() {
3232
}
3333

3434
@Override
35-
protected Filter replaceChild(LogicalPlan newChild) {
35+
public Filter replaceChild(LogicalPlan newChild) {
3636
return new Filter(source(), newChild, condition);
3737
}
3838

x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/plan/logical/Limit.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ protected NodeInfo<Limit> info() {
2727
}
2828

2929
@Override
30-
protected Limit replaceChild(LogicalPlan newChild) {
30+
public Limit replaceChild(LogicalPlan newChild) {
3131
return new Limit(source(), limit, newChild);
3232
}
3333

x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/plan/logical/OrderBy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ protected NodeInfo<OrderBy> info() {
2929
}
3030

3131
@Override
32-
protected OrderBy replaceChild(LogicalPlan newChild) {
32+
public OrderBy replaceChild(LogicalPlan newChild) {
3333
return new OrderBy(source(), newChild, order);
3434
}
3535

0 commit comments

Comments
 (0)