File tree Expand file tree Collapse file tree 4 files changed +27
-7
lines changed
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan Expand file tree Collapse file tree 4 files changed +27
-7
lines changed Original file line number Diff line number Diff line change 1+ pr : 124611
2+ summary : Reuse child `outputSet` inside the plan where possible
3+ area : ES|QL
4+ type : enhancement
5+ issues : []
Original file line number Diff line number Diff line change 77package org .elasticsearch .xpack .esql .plan .logical ;
88
99import org .elasticsearch .xpack .esql .core .expression .Attribute ;
10+ import org .elasticsearch .xpack .esql .core .expression .AttributeSet ;
1011import org .elasticsearch .xpack .esql .core .tree .Source ;
1112
1213import java .util .Collections ;
2021public abstract class UnaryPlan extends LogicalPlan {
2122
2223 private final LogicalPlan child ;
24+ private AttributeSet lazyOutputSet ;
2325
2426 protected UnaryPlan (Source source , LogicalPlan child ) {
2527 super (source , Collections .singletonList (child ));
@@ -42,6 +44,14 @@ public List<Attribute> output() {
4244 return child .output ();
4345 }
4446
47+ public AttributeSet outputSet () {
48+ if (lazyOutputSet == null ) {
49+ List <Attribute > output = output ();
50+ lazyOutputSet = (output == child .output () ? child .outputSet () : new AttributeSet (output ));
51+ }
52+ return lazyOutputSet ;
53+ }
54+
4555 @ Override
4656 public int hashCode () {
4757 return Objects .hashCode (child ());
Original file line number Diff line number Diff line change 99import org .elasticsearch .common .io .stream .NamedWriteableRegistry ;
1010import org .elasticsearch .common .io .stream .StreamInput ;
1111import org .elasticsearch .common .io .stream .StreamOutput ;
12- import org .elasticsearch .xpack .esql .core .expression .Attribute ;
1312import org .elasticsearch .xpack .esql .core .expression .Expression ;
1413import org .elasticsearch .xpack .esql .core .tree .NodeInfo ;
1514import org .elasticsearch .xpack .esql .core .tree .Source ;
1615import org .elasticsearch .xpack .esql .io .stream .PlanStreamInput ;
1716
1817import java .io .IOException ;
19- import java .util .List ;
2018import java .util .Objects ;
2119
2220public class FilterExec extends UnaryExec {
@@ -63,11 +61,6 @@ public Expression condition() {
6361 return condition ;
6462 }
6563
66- @ Override
67- public List <Attribute > output () {
68- return child ().output ();
69- }
70-
7164 @ Override
7265 public int hashCode () {
7366 return Objects .hash (condition , child ());
Original file line number Diff line number Diff line change 88package org .elasticsearch .xpack .esql .plan .physical ;
99
1010import org .elasticsearch .xpack .esql .core .expression .Attribute ;
11+ import org .elasticsearch .xpack .esql .core .expression .AttributeSet ;
1112import org .elasticsearch .xpack .esql .core .tree .Source ;
1213
1314import java .util .Collections ;
1718public abstract class UnaryExec extends PhysicalPlan {
1819
1920 private final PhysicalPlan child ;
21+ private AttributeSet lazyOutputSet ;
2022
2123 protected UnaryExec (Source source , PhysicalPlan child ) {
2224 super (source , Collections .singletonList (child ));
@@ -39,6 +41,16 @@ public List<Attribute> output() {
3941 return child .output ();
4042 }
4143
44+ @ Override
45+ public AttributeSet outputSet () {
46+ if (lazyOutputSet == null ) {
47+ List <Attribute > output = output ();
48+ lazyOutputSet = (output == child .output () ? child .outputSet () : new AttributeSet (output ));
49+ return lazyOutputSet ;
50+ }
51+ return lazyOutputSet ;
52+ }
53+
4254 @ Override
4355 public int hashCode () {
4456 return Objects .hashCode (child ());
You can’t perform that action at this time.
0 commit comments