4343 * Reduce a multivalued field to a single valued field containing the count of values.
4444 */
4545public class MvContainsAll extends BinaryScalarFunction implements EvaluatorMapper {
46- public static final NamedWriteableRegistry .Entry ENTRY = new NamedWriteableRegistry .Entry (Expression .class , "MvContainsAll" , MvContainsAll ::new );
46+ public static final NamedWriteableRegistry .Entry ENTRY = new NamedWriteableRegistry .Entry (
47+ Expression .class ,
48+ "MvContainsAll" ,
49+ MvContainsAll ::new
50+ );
4751 private DataType dataType ;
4852
4953 @ FunctionInfo (
5054 returnType = "boolean" ,
51- description = "Checks if the values yielded by multivalue value expression are all also present in the values yielded by another" +
52- "multivalue expression. The result is a boolean representing the outcome or null if either of the expressions where null." ,
55+ description = "Checks if the values yielded by multivalue value expression are all also present in the values yielded by another"
56+ + "multivalue expression. The result is a boolean representing the outcome or null if either of the expressions where null." ,
5357 examples = { @ Example (file = "string" , tag = "mv_contains_all" ), @ Example (file = "string" , tag = "mv_contains_all_bothsides" ), }
5458 )
5559 public MvContainsAll (
@@ -107,7 +111,6 @@ public String getWriteableName() {
107111 return ENTRY .name ;
108112 }
109113
110-
111114 @ Override
112115 protected TypeResolution resolveType () {
113116 if (childrenResolved () == false ) {
@@ -153,11 +156,13 @@ public Object fold(FoldContext ctx) {
153156 public ExpressionEvaluator .Factory toEvaluator (ToEvaluator toEvaluator ) {
154157 var supersetType = PlannerUtils .toElementType (left ().dataType ());
155158 var subsetType = PlannerUtils .toElementType (right ().dataType ());
156- if ( supersetType != subsetType ) {
159+ if ( supersetType != subsetType ) {
157160 throw new EsqlIllegalArgumentException (
158161 "Incompatible data types for MvContainsAll, superset type({}) value({}) and subset type({}) value({}) don't match." ,
159- supersetType , left (),
160- subsetType , right ()
162+ supersetType ,
163+ left (),
164+ subsetType ,
165+ right ()
161166 );
162167 }
163168 return switch (supersetType ) {
@@ -193,18 +198,15 @@ static void process(BooleanBlock.Builder builder, int position, DoubleBlock fiel
193198
194199 @ Evaluator (extraName = "BytesRef" )
195200 static void process (BooleanBlock .Builder builder , int position , BytesRefBlock field1 , BytesRefBlock field2 ) {
196- appendTo (
197- builder ,
198- containsAll (field1 , field2 , position , (block , index ) -> {
199- var ref = new BytesRef ();
200- block .getBytesRef (index , ref );
201- return ref ;
202- })
203- );
201+ appendTo (builder , containsAll (field1 , field2 , position , (block , index ) -> {
202+ var ref = new BytesRef ();
203+ block .getBytesRef (index , ref );
204+ return ref ;
205+ }));
204206 }
205207
206208 static void appendTo (BooleanBlock .Builder builder , Boolean bool ) {
207- if (bool == null ) {
209+ if (bool == null ) {
208210 builder .appendNull ();
209211 } else {
210212 builder .beginPositionEntry ().appendBoolean (bool ).endPositionEntry ();
@@ -235,7 +237,7 @@ static <BlockType extends Block, Type> Boolean containsAll(
235237
236238 final var subsetCount = subset .getValueCount (position );
237239 final var startIndex = subset .getFirstValueIndex (position );
238- for (int subsetIndex = startIndex ; subsetIndex < startIndex + subsetCount ; subsetIndex ++) {
240+ for (int subsetIndex = startIndex ; subsetIndex < startIndex + subsetCount ; subsetIndex ++) {
239241 var value = valueExtractor .extractValue (subset , subsetIndex );
240242 if (hasValue (superset , position , value , valueExtractor ) == false ) {
241243 return false ;
@@ -258,9 +260,9 @@ static <BlockType extends Block, Type> boolean hasValue(
258260 ) {
259261 final var supersetCount = superset .getValueCount (position );
260262 final var startIndex = superset .getFirstValueIndex (position );
261- for (int supersetIndex = startIndex ; supersetIndex < startIndex + supersetCount ; supersetIndex ++) {
263+ for (int supersetIndex = startIndex ; supersetIndex < startIndex + supersetCount ; supersetIndex ++) {
262264 var element = valueExtractor .extractValue (superset , supersetIndex );
263- if (element .equals (value )) {
265+ if (element .equals (value )) {
264266 return true ;
265267 }
266268 }
0 commit comments