File tree 4 files changed +27
-7
lines changed
x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan
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 7
7
package org .elasticsearch .xpack .esql .plan .logical ;
8
8
9
9
import org .elasticsearch .xpack .esql .core .expression .Attribute ;
10
+ import org .elasticsearch .xpack .esql .core .expression .AttributeSet ;
10
11
import org .elasticsearch .xpack .esql .core .tree .Source ;
11
12
12
13
import java .util .Collections ;
20
21
public abstract class UnaryPlan extends LogicalPlan {
21
22
22
23
private final LogicalPlan child ;
24
+ private AttributeSet lazyOutputSet ;
23
25
24
26
protected UnaryPlan (Source source , LogicalPlan child ) {
25
27
super (source , Collections .singletonList (child ));
@@ -42,6 +44,14 @@ public List<Attribute> output() {
42
44
return child .output ();
43
45
}
44
46
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
+
45
55
@ Override
46
56
public int hashCode () {
47
57
return Objects .hashCode (child ());
Original file line number Diff line number Diff line change 9
9
import org .elasticsearch .common .io .stream .NamedWriteableRegistry ;
10
10
import org .elasticsearch .common .io .stream .StreamInput ;
11
11
import org .elasticsearch .common .io .stream .StreamOutput ;
12
- import org .elasticsearch .xpack .esql .core .expression .Attribute ;
13
12
import org .elasticsearch .xpack .esql .core .expression .Expression ;
14
13
import org .elasticsearch .xpack .esql .core .tree .NodeInfo ;
15
14
import org .elasticsearch .xpack .esql .core .tree .Source ;
16
15
import org .elasticsearch .xpack .esql .io .stream .PlanStreamInput ;
17
16
18
17
import java .io .IOException ;
19
- import java .util .List ;
20
18
import java .util .Objects ;
21
19
22
20
public class FilterExec extends UnaryExec {
@@ -63,11 +61,6 @@ public Expression condition() {
63
61
return condition ;
64
62
}
65
63
66
- @ Override
67
- public List <Attribute > output () {
68
- return child ().output ();
69
- }
70
-
71
64
@ Override
72
65
public int hashCode () {
73
66
return Objects .hash (condition , child ());
Original file line number Diff line number Diff line change 8
8
package org .elasticsearch .xpack .esql .plan .physical ;
9
9
10
10
import org .elasticsearch .xpack .esql .core .expression .Attribute ;
11
+ import org .elasticsearch .xpack .esql .core .expression .AttributeSet ;
11
12
import org .elasticsearch .xpack .esql .core .tree .Source ;
12
13
13
14
import java .util .Collections ;
17
18
public abstract class UnaryExec extends PhysicalPlan {
18
19
19
20
private final PhysicalPlan child ;
21
+ private AttributeSet lazyOutputSet ;
20
22
21
23
protected UnaryExec (Source source , PhysicalPlan child ) {
22
24
super (source , Collections .singletonList (child ));
@@ -39,6 +41,16 @@ public List<Attribute> output() {
39
41
return child .output ();
40
42
}
41
43
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
+
42
54
@ Override
43
55
public int hashCode () {
44
56
return Objects .hashCode (child ());
You can’t perform that action at this time.
0 commit comments