3737import static org .elasticsearch .xpack .esql .core .expression .TypeResolutions .ParamOrdinal .FIRST ;
3838import static org .elasticsearch .xpack .esql .core .expression .TypeResolutions .ParamOrdinal .SECOND ;
3939import static org .elasticsearch .xpack .esql .core .expression .TypeResolutions .ParamOrdinal .THIRD ;
40- import static org .elasticsearch .xpack .esql .core .expression .TypeResolutions .ParamOrdinal .fromIndex ;
4140import static org .elasticsearch .xpack .esql .core .expression .TypeResolutions .isIPAndExact ;
4241import static org .elasticsearch .xpack .esql .expression .EsqlTypeResolutions .isStringAndExact ;
4342
@@ -75,8 +74,8 @@ public NetworkDirection(
7574 @ Param (
7675 name = "internal_networks" ,
7776 type = { "keyword" , "text" },
78- description = "List of internal networks. Supports IPv4 and IPv6 addresses, ranges in CIDR notation, and named ranges." )
79- Expression internalNetworks
77+ description = "List of internal networks. Supports IPv4 and IPv6 addresses, ranges in CIDR notation, and named ranges."
78+ ) Expression internalNetworks
8079 ) {
8180 super (source , Arrays .asList (sourceIpField , destinationIpField , internalNetworks ));
8281 this .sourceIpField = sourceIpField ;
@@ -116,7 +115,6 @@ protected NodeInfo<? extends Expression> info() {
116115 return NodeInfo .create (this , NetworkDirection ::new , sourceIpField , destinationIpField , internalNetworks );
117116 }
118117
119-
120118 @ Override
121119 public EvalOperator .ExpressionEvaluator .Factory toEvaluator (ToEvaluator toEvaluator ) {
122120 var sourceIpEvaluatorSupplier = toEvaluator .apply (sourceIpField );
@@ -133,7 +131,15 @@ public EvalOperator.ExpressionEvaluator.Factory toEvaluator(ToEvaluator toEvalua
133131 }
134132
135133 @ Evaluator ()
136- static void process (BytesRefBlock .Builder builder , @ Fixed (includeInToString =false , scope =THREAD_LOCAL ) BytesRef scratch , @ Fixed (includeInToString =false , scope =THREAD_LOCAL ) BytesRef netScratch , BytesRef sourceIp , BytesRef destinationIp , @ Position int position , BytesRefBlock networks ) {
134+ static void process (
135+ BytesRefBlock .Builder builder ,
136+ @ Fixed (includeInToString = false , scope = THREAD_LOCAL ) BytesRef scratch ,
137+ @ Fixed (includeInToString = false , scope = THREAD_LOCAL ) BytesRef netScratch ,
138+ BytesRef sourceIp ,
139+ BytesRef destinationIp ,
140+ @ Position int position ,
141+ BytesRefBlock networks
142+ ) {
137143 int valueCount = networks .getValueCount (position );
138144 if (valueCount == 0 ) {
139145 builder .appendNull ();
@@ -176,8 +182,7 @@ protected TypeResolution resolveType() {
176182 return new TypeResolution ("Unresolved children" );
177183 }
178184
179- return isIPAndExact (sourceIpField , sourceText (), FIRST )
180- .and (isIPAndExact (destinationIpField , sourceText (), SECOND ))
185+ return isIPAndExact (sourceIpField , sourceText (), FIRST ).and (isIPAndExact (destinationIpField , sourceText (), SECOND ))
181186 .and (isStringAndExact (internalNetworks , sourceText (), THIRD ));
182187 }
183188
0 commit comments