9
9
10
10
import org .elasticsearch .TransportVersions ;
11
11
import org .elasticsearch .common .io .stream .NamedWriteable ;
12
- import org .elasticsearch .common .io .stream .StreamInput ;
13
- import org .elasticsearch .common .io .stream .StreamOutput ;
14
- import org .elasticsearch .common .util .iterable .Iterables ;
15
- import org .elasticsearch .index .IndexMode ;
16
12
import org .elasticsearch .index .query .QueryBuilder ;
17
- import org .elasticsearch .transport .RemoteClusterAware ;
18
13
import org .elasticsearch .xpack .esql .core .expression .Alias ;
19
14
import org .elasticsearch .xpack .esql .core .expression .Attribute ;
20
15
import org .elasticsearch .xpack .esql .core .expression .Expression ;
21
16
import org .elasticsearch .xpack .esql .core .expression .NamedExpression ;
22
17
import org .elasticsearch .xpack .esql .core .tree .Source ;
23
- import org .elasticsearch .xpack .esql .index .EsIndex ;
24
- import org .elasticsearch .xpack .esql .plan .logical .Enrich ;
25
18
import org .elasticsearch .xpack .esql .plan .logical .Grok ;
26
19
import org .elasticsearch .xpack .esql .plan .logical .LogicalPlan ;
27
20
import org .elasticsearch .xpack .esql .plan .physical .AggregateExec ;
50
43
51
44
import java .io .IOException ;
52
45
import java .util .List ;
53
- import java .util .Map ;
54
- import java .util .Set ;
55
46
56
47
import static org .elasticsearch .xpack .esql .io .stream .PlanNameRegistry .Entry .of ;
57
48
@@ -92,11 +83,11 @@ public static List<PlanNameRegistry.Entry> namedTypeEntries() {
92
83
of (PhysicalPlan .class , EsQueryExec .ENTRY ),
93
84
of (PhysicalPlan .class , EsSourceExec .ENTRY ),
94
85
of (PhysicalPlan .class , EvalExec .ENTRY ),
95
- of (PhysicalPlan .class , EnrichExec .class , PlanNamedTypes :: writeEnrichExec , PlanNamedTypes :: readEnrichExec ),
86
+ of (PhysicalPlan .class , EnrichExec .ENTRY ),
96
87
of (PhysicalPlan .class , ExchangeExec .ENTRY ),
97
88
of (PhysicalPlan .class , ExchangeSinkExec .ENTRY ),
98
89
of (PhysicalPlan .class , ExchangeSourceExec .ENTRY ),
99
- of (PhysicalPlan .class , FieldExtractExec .class , PlanNamedTypes :: writeFieldExtractExec , PlanNamedTypes :: readFieldExtractExec ),
90
+ of (PhysicalPlan .class , FieldExtractExec .ENTRY ),
100
91
of (PhysicalPlan .class , FilterExec .class , PlanNamedTypes ::writeFilterExec , PlanNamedTypes ::readFilterExec ),
101
92
of (PhysicalPlan .class , FragmentExec .class , PlanNamedTypes ::writeFragmentExec , PlanNamedTypes ::readFragmentExec ),
102
93
of (PhysicalPlan .class , GrokExec .class , PlanNamedTypes ::writeGrokExec , PlanNamedTypes ::readGrokExec ),
@@ -114,72 +105,6 @@ public static List<PlanNameRegistry.Entry> namedTypeEntries() {
114
105
}
115
106
116
107
// -- physical plan nodes
117
- static EnrichExec readEnrichExec (PlanStreamInput in ) throws IOException {
118
- final Source source = Source .readFrom (in );
119
- final PhysicalPlan child = in .readPhysicalPlanNode ();
120
- final NamedExpression matchField = in .readNamedWriteable (NamedExpression .class );
121
- final String policyName = in .readString ();
122
- final String matchType = (in .getTransportVersion ().onOrAfter (TransportVersions .V_8_14_0 )) ? in .readString () : "match" ;
123
- final String policyMatchField = in .readString ();
124
- final Map <String , String > concreteIndices ;
125
- final Enrich .Mode mode ;
126
- if (in .getTransportVersion ().onOrAfter (TransportVersions .V_8_13_0 )) {
127
- mode = in .readEnum (Enrich .Mode .class );
128
- concreteIndices = in .readMap (StreamInput ::readString , StreamInput ::readString );
129
- } else {
130
- mode = Enrich .Mode .ANY ;
131
- EsIndex esIndex = new EsIndex (in );
132
- if (esIndex .concreteIndices ().size () != 1 ) {
133
- throw new IllegalStateException ("expected a single concrete enrich index; got " + esIndex .concreteIndices ());
134
- }
135
- concreteIndices = Map .of (RemoteClusterAware .LOCAL_CLUSTER_GROUP_KEY , Iterables .get (esIndex .concreteIndices (), 0 ));
136
- }
137
- return new EnrichExec (
138
- source ,
139
- child ,
140
- mode ,
141
- matchType ,
142
- matchField ,
143
- policyName ,
144
- policyMatchField ,
145
- concreteIndices ,
146
- in .readNamedWriteableCollectionAsList (NamedExpression .class )
147
- );
148
- }
149
-
150
- static void writeEnrichExec (PlanStreamOutput out , EnrichExec enrich ) throws IOException {
151
- Source .EMPTY .writeTo (out );
152
- out .writePhysicalPlanNode (enrich .child ());
153
- out .writeNamedWriteable (enrich .matchField ());
154
- out .writeString (enrich .policyName ());
155
- if (out .getTransportVersion ().onOrAfter (TransportVersions .V_8_14_0 )) {
156
- out .writeString (enrich .matchType ());
157
- }
158
- out .writeString (enrich .policyMatchField ());
159
- if (out .getTransportVersion ().onOrAfter (TransportVersions .V_8_13_0 )) {
160
- out .writeEnum (enrich .mode ());
161
- out .writeMap (enrich .concreteIndices (), StreamOutput ::writeString , StreamOutput ::writeString );
162
- } else {
163
- if (enrich .concreteIndices ().keySet ().equals (Set .of (RemoteClusterAware .LOCAL_CLUSTER_GROUP_KEY ))) {
164
- String concreteIndex = enrich .concreteIndices ().get (RemoteClusterAware .LOCAL_CLUSTER_GROUP_KEY );
165
- new EsIndex (concreteIndex , Map .of (), Map .of (concreteIndex , IndexMode .STANDARD )).writeTo (out );
166
- } else {
167
- throw new IllegalStateException ("expected a single concrete enrich index; got " + enrich .concreteIndices ());
168
- }
169
- }
170
- out .writeNamedWriteableCollection (enrich .enrichFields ());
171
- }
172
-
173
- static FieldExtractExec readFieldExtractExec (PlanStreamInput in ) throws IOException {
174
- return new FieldExtractExec (Source .readFrom (in ), in .readPhysicalPlanNode (), in .readNamedWriteableCollectionAsList (Attribute .class ));
175
- }
176
-
177
- static void writeFieldExtractExec (PlanStreamOutput out , FieldExtractExec fieldExtractExec ) throws IOException {
178
- Source .EMPTY .writeTo (out );
179
- out .writePhysicalPlanNode (fieldExtractExec .child ());
180
- out .writeNamedWriteableCollection (fieldExtractExec .attributesToExtract ());
181
- }
182
-
183
108
static FilterExec readFilterExec (PlanStreamInput in ) throws IOException {
184
109
return new FilterExec (Source .readFrom (in ), in .readPhysicalPlanNode (), in .readNamedWriteable (Expression .class ));
185
110
}
0 commit comments