99
1010import org .elasticsearch .TransportVersions ;
1111import org .elasticsearch .cluster .service .ClusterService ;
12+ import org .elasticsearch .common .breaker .CircuitBreaker ;
13+ import org .elasticsearch .common .breaker .NoopCircuitBreaker ;
1214import org .elasticsearch .common .collect .Iterators ;
1315import org .elasticsearch .common .io .stream .StreamInput ;
1416import org .elasticsearch .common .io .stream .StreamOutput ;
3032import org .elasticsearch .xpack .esql .core .type .DataType ;
3133import org .elasticsearch .xpack .esql .io .stream .PlanStreamInput ;
3234import org .elasticsearch .xpack .esql .io .stream .PlanStreamOutput ;
35+ import org .elasticsearch .xpack .esql .session .Configuration ;
3336
3437import java .io .IOException ;
3538import java .util .List ;
3639import java .util .Objects ;
3740
41+ import static java .lang .System .in ;
42+
3843/**
3944 * {@link LookupFromIndexService} performs lookup against a Lookup index for
4045 * a given input page. See {@link AbstractLookupService} for how it works
@@ -66,6 +71,7 @@ public LookupFromIndexService(
6671 protected TransportRequest transportRequest (LookupFromIndexService .Request request , ShardId shardId ) {
6772 return new TransportRequest (
6873 request .sessionId ,
74+ request .configuration ,
6975 shardId ,
7076 request .inputDataType ,
7177 request .inputPage ,
@@ -101,10 +107,12 @@ protected AbstractLookupService.LookupResponse readLookupResponse(StreamInput in
101107 }
102108
103109 public static class Request extends AbstractLookupService .Request {
110+ private final Configuration configuration ;
104111 private final String matchField ;
105112
106113 Request (
107114 String sessionId ,
115+ Configuration configuration ,
108116 String index ,
109117 DataType inputDataType ,
110118 String matchField ,
@@ -113,15 +121,18 @@ public static class Request extends AbstractLookupService.Request {
113121 Source source
114122 ) {
115123 super (sessionId , index , inputDataType , inputPage , extractFields , source );
124+ this .configuration = configuration ;
116125 this .matchField = matchField ;
117126 }
118127 }
119128
120129 protected static class TransportRequest extends AbstractLookupService .TransportRequest {
130+ private final Configuration configuration ;
121131 private final String matchField ;
122132
123133 TransportRequest (
124134 String sessionId ,
135+ Configuration configuration ,
125136 ShardId shardId ,
126137 DataType inputDataType ,
127138 Page inputPage ,
@@ -131,19 +142,30 @@ protected static class TransportRequest extends AbstractLookupService.TransportR
131142 Source source
132143 ) {
133144 super (sessionId , shardId , inputDataType , inputPage , toRelease , extractFields , source );
145+ this .configuration = configuration ;
134146 this .matchField = matchField ;
135147 }
136148
137149 static TransportRequest readFrom (StreamInput in , BlockFactory blockFactory ) throws IOException {
138150 TaskId parentTaskId = TaskId .readFromStream (in );
139151 String sessionId = in .readString ();
152+ Configuration configuration = null ;
153+ if (in .getTransportVersion ().onOrAfter (TransportVersions .ESQL_LOOKUP_JOIN_CONFIGURATION_IN_REQUEST )) {
154+ configuration = new Configuration (
155+ // TODO make EsqlConfiguration Releasable
156+ new BlockStreamInput (
157+ in ,
158+ new BlockFactory (new NoopCircuitBreaker (CircuitBreaker .REQUEST ), BigArrays .NON_RECYCLING_INSTANCE )
159+ )
160+ );
161+ }
140162 ShardId shardId = new ShardId (in );
141163 DataType inputDataType = DataType .fromTypeName (in .readString ());
142164 Page inputPage ;
143165 try (BlockStreamInput bsi = new BlockStreamInput (in , blockFactory )) {
144166 inputPage = new Page (bsi );
145167 }
146- PlanStreamInput planIn = new PlanStreamInput (in , in .namedWriteableRegistry (), null );
168+ PlanStreamInput planIn = new PlanStreamInput (in , in .namedWriteableRegistry (), configuration );
147169 List <NamedExpression > extractFields = planIn .readNamedWriteableCollectionAsList (NamedExpression .class );
148170 String matchField = in .readString ();
149171 var source = Source .EMPTY ;
@@ -152,6 +174,7 @@ static TransportRequest readFrom(StreamInput in, BlockFactory blockFactory) thro
152174 }
153175 TransportRequest result = new TransportRequest (
154176 sessionId ,
177+ configuration ,
155178 shardId ,
156179 inputDataType ,
157180 inputPage ,
@@ -168,6 +191,9 @@ static TransportRequest readFrom(StreamInput in, BlockFactory blockFactory) thro
168191 public void writeTo (StreamOutput out ) throws IOException {
169192 super .writeTo (out );
170193 out .writeString (sessionId );
194+ if (out .getTransportVersion ().onOrAfter (TransportVersions .ESQL_LOOKUP_JOIN_CONFIGURATION_IN_REQUEST )) {
195+ configuration .writeTo (out );
196+ }
171197 out .writeWriteable (shardId );
172198 out .writeString (inputDataType .typeName ());
173199 out .writeWriteable (inputPage );
0 commit comments