Skip to content

Commit e250247

Browse files
author
elasticsearchmachine
committed
[CI] Auto commit changes from spotless
1 parent 69cfa82 commit e250247

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/EsqlFunctionRegistry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@
120120
import org.elasticsearch.xpack.esql.expression.function.scalar.math.Tan;
121121
import org.elasticsearch.xpack.esql.expression.function.scalar.math.Tanh;
122122
import org.elasticsearch.xpack.esql.expression.function.scalar.math.Tau;
123-
import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvContainsAll;
124123
import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvAppend;
125124
import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvAvg;
126125
import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvConcat;
126+
import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvContainsAll;
127127
import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvCount;
128128
import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvDedupe;
129129
import org.elasticsearch.xpack.esql.expression.function.scalar.multivalue.MvFirst;

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/multivalue/MvContainsAll.java

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,17 @@
4343
* Reduce a multivalued field to a single valued field containing the count of values.
4444
*/
4545
public 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

Comments
 (0)