From a18b3313364b6b7c87c45bae9dc342dec314966d Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Wed, 2 Oct 2024 10:42:43 -0400 Subject: [PATCH] ESQL: Fix filtering all elements in aggs (#113804) This adds a test to *every* agg for when it's entirely filtered away and another when filtering is enabled but unused. I'll follow up with another test later for partial filtering. That test caught a bug where some aggs would think they'd been `seen` when they hadn't. This fixes that too. --- .../compute/operator/AggregatorBenchmark.java | 96 ++++++++++++++++--- .../compute/gen/AggregatorImplementer.java | 15 +-- .../compute/data/BooleanArrayVector.java | 26 +++++ .../compute/data/BooleanBigArrayVector.java | 26 +++++ .../compute/data/BooleanVector.java | 10 ++ .../compute/data/ConstantBooleanVector.java | 16 ++++ ...ountDistinctBooleanAggregatorFunction.java | 10 +- ...untDistinctBytesRefAggregatorFunction.java | 10 +- ...CountDistinctDoubleAggregatorFunction.java | 10 +- .../CountDistinctFloatAggregatorFunction.java | 10 +- .../CountDistinctIntAggregatorFunction.java | 10 +- .../CountDistinctLongAggregatorFunction.java | 10 +- .../MaxBooleanAggregatorFunction.java | 10 +- .../MaxBytesRefAggregatorFunction.java | 10 +- .../MaxDoubleAggregatorFunction.java | 10 +- .../MaxFloatAggregatorFunction.java | 10 +- .../aggregation/MaxIntAggregatorFunction.java | 10 +- .../aggregation/MaxIpAggregatorFunction.java | 10 +- .../MaxLongAggregatorFunction.java | 10 +- ...luteDeviationDoubleAggregatorFunction.java | 10 +- ...oluteDeviationFloatAggregatorFunction.java | 10 +- ...bsoluteDeviationIntAggregatorFunction.java | 10 +- ...soluteDeviationLongAggregatorFunction.java | 10 +- .../MinBooleanAggregatorFunction.java | 10 +- .../MinBytesRefAggregatorFunction.java | 10 +- .../MinDoubleAggregatorFunction.java | 10 +- .../MinFloatAggregatorFunction.java | 10 +- .../aggregation/MinIntAggregatorFunction.java | 10 +- .../aggregation/MinIpAggregatorFunction.java | 10 +- .../MinLongAggregatorFunction.java | 10 +- .../PercentileDoubleAggregatorFunction.java | 10 +- .../PercentileFloatAggregatorFunction.java | 10 +- .../PercentileIntAggregatorFunction.java | 10 +- .../PercentileLongAggregatorFunction.java | 10 +- .../SumDoubleAggregatorFunction.java | 10 +- .../SumFloatAggregatorFunction.java | 10 +- .../aggregation/SumIntAggregatorFunction.java | 10 +- .../SumLongAggregatorFunction.java | 10 +- .../TopBooleanAggregatorFunction.java | 10 +- .../TopBytesRefAggregatorFunction.java | 10 +- .../TopDoubleAggregatorFunction.java | 10 +- .../TopFloatAggregatorFunction.java | 10 +- .../aggregation/TopIntAggregatorFunction.java | 10 +- .../aggregation/TopIpAggregatorFunction.java | 10 +- .../TopLongAggregatorFunction.java | 10 +- .../ValuesBooleanAggregatorFunction.java | 10 +- .../ValuesBytesRefAggregatorFunction.java | 10 +- .../ValuesDoubleAggregatorFunction.java | 10 +- .../ValuesFloatAggregatorFunction.java | 10 +- .../ValuesIntAggregatorFunction.java | 10 +- .../ValuesLongAggregatorFunction.java | 10 +- ...esianPointDocValuesAggregatorFunction.java | 10 +- ...anPointSourceValuesAggregatorFunction.java | 10 +- ...idGeoPointDocValuesAggregatorFunction.java | 10 +- ...eoPointSourceValuesAggregatorFunction.java | 10 +- .../CountGroupingAggregatorFunction.java | 1 - .../aggregation/blockhash/AddPage.java | 2 +- .../aggregation/blockhash/BlockHash.java | 3 + .../compute/data/ConstantNullVector.java | 12 +++ .../compute/data/X-ArrayVector.java.st | 27 ++++++ .../compute/data/X-BigArrayVector.java.st | 27 ++++++ .../compute/data/X-ConstantVector.java.st | 17 ++++ .../compute/data/X-Vector.java.st | 11 +++ .../ConstantBooleanExpressionEvaluator.java | 42 ++++++++ .../AggregatorFunctionTestCase.java | 39 +++++++- ...ooleanGroupingAggregatorFunctionTests.java | 11 +++ ...tesRefGroupingAggregatorFunctionTests.java | 11 +++ ...DoubleGroupingAggregatorFunctionTests.java | 11 +++ ...tFloatGroupingAggregatorFunctionTests.java | 11 +++ ...nctIntGroupingAggregatorFunctionTests.java | 11 +++ ...ctLongGroupingAggregatorFunctionTests.java | 11 +++ .../CountGroupingAggregatorFunctionTests.java | 11 +++ .../FilteredAggregatorFunctionTests.java | 10 ++ .../GroupingAggregatorFunctionTestCase.java | 95 ++++++++++++++---- .../aggregation/blockhash/AddPageTests.java | 8 +- .../aggregation/blockhash/BlockHashTests.java | 12 ++- .../compute/data/BasicBlockTests.java | 24 ++++- .../compute/data/BigArrayVectorTests.java | 17 +++- 78 files changed, 804 insertions(+), 299 deletions(-) create mode 100644 x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/ConstantBooleanExpressionEvaluator.java diff --git a/benchmarks/src/main/java/org/elasticsearch/benchmark/compute/operator/AggregatorBenchmark.java b/benchmarks/src/main/java/org/elasticsearch/benchmark/compute/operator/AggregatorBenchmark.java index f23a4b07d8719..27f4d68b0bc3f 100644 --- a/benchmarks/src/main/java/org/elasticsearch/benchmark/compute/operator/AggregatorBenchmark.java +++ b/benchmarks/src/main/java/org/elasticsearch/benchmark/compute/operator/AggregatorBenchmark.java @@ -17,6 +17,7 @@ import org.elasticsearch.compute.aggregation.CountAggregatorFunction; import org.elasticsearch.compute.aggregation.CountDistinctDoubleAggregatorFunctionSupplier; import org.elasticsearch.compute.aggregation.CountDistinctLongAggregatorFunctionSupplier; +import org.elasticsearch.compute.aggregation.FilteredAggregatorFunctionSupplier; import org.elasticsearch.compute.aggregation.MaxDoubleAggregatorFunctionSupplier; import org.elasticsearch.compute.aggregation.MaxLongAggregatorFunctionSupplier; import org.elasticsearch.compute.aggregation.MinDoubleAggregatorFunctionSupplier; @@ -27,6 +28,7 @@ import org.elasticsearch.compute.data.Block; import org.elasticsearch.compute.data.BlockFactory; import org.elasticsearch.compute.data.BooleanBlock; +import org.elasticsearch.compute.data.BooleanVector; import org.elasticsearch.compute.data.BytesRefBlock; import org.elasticsearch.compute.data.DoubleBlock; import org.elasticsearch.compute.data.ElementType; @@ -35,6 +37,7 @@ import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.AggregationOperator; import org.elasticsearch.compute.operator.DriverContext; +import org.elasticsearch.compute.operator.EvalOperator; import org.elasticsearch.compute.operator.HashAggregationOperator; import org.elasticsearch.compute.operator.Operator; import org.openjdk.jmh.annotations.Benchmark; @@ -94,13 +97,20 @@ public class AggregatorBenchmark { private static final String NONE = "none"; + private static final String CONSTANT_TRUE = "constant_true"; + private static final String ALL_TRUE = "all_true"; + private static final String HALF_TRUE = "half_true"; + private static final String CONSTANT_FALSE = "constant_false"; + static { // Smoke test all the expected values and force loading subclasses more like prod try { for (String grouping : AggregatorBenchmark.class.getField("grouping").getAnnotationsByType(Param.class)[0].value()) { for (String op : AggregatorBenchmark.class.getField("op").getAnnotationsByType(Param.class)[0].value()) { for (String blockType : AggregatorBenchmark.class.getField("blockType").getAnnotationsByType(Param.class)[0].value()) { - run(grouping, op, blockType, 50); + for (String filter : AggregatorBenchmark.class.getField("filter").getAnnotationsByType(Param.class)[0].value()) { + run(grouping, op, blockType, filter, 10); + } } } } @@ -118,10 +128,14 @@ public class AggregatorBenchmark { @Param({ VECTOR_LONGS, HALF_NULL_LONGS, VECTOR_DOUBLES, HALF_NULL_DOUBLES }) public String blockType; - private static Operator operator(DriverContext driverContext, String grouping, String op, String dataType) { + @Param({ NONE, CONSTANT_TRUE, ALL_TRUE, HALF_TRUE, CONSTANT_FALSE }) + public String filter; + + private static Operator operator(DriverContext driverContext, String grouping, String op, String dataType, String filter) { + if (grouping.equals("none")) { return new AggregationOperator( - List.of(supplier(op, dataType, 0).aggregatorFactory(AggregatorMode.SINGLE).apply(driverContext)), + List.of(supplier(op, dataType, filter, 0).aggregatorFactory(AggregatorMode.SINGLE).apply(driverContext)), driverContext ); } @@ -144,14 +158,14 @@ private static Operator operator(DriverContext driverContext, String grouping, S default -> throw new IllegalArgumentException("unsupported grouping [" + grouping + "]"); }; return new HashAggregationOperator( - List.of(supplier(op, dataType, groups.size()).groupingAggregatorFactory(AggregatorMode.SINGLE)), + List.of(supplier(op, dataType, filter, groups.size()).groupingAggregatorFactory(AggregatorMode.SINGLE)), () -> BlockHash.build(groups, driverContext.blockFactory(), 16 * 1024, false), driverContext ); } - private static AggregatorFunctionSupplier supplier(String op, String dataType, int dataChannel) { - return switch (op) { + private static AggregatorFunctionSupplier supplier(String op, String dataType, String filter, int dataChannel) { + return filtered(switch (op) { case COUNT -> CountAggregatorFunction.supplier(List.of(dataChannel)); case COUNT_DISTINCT -> switch (dataType) { case LONGS -> new CountDistinctLongAggregatorFunctionSupplier(List.of(dataChannel), 3000); @@ -174,10 +188,22 @@ private static AggregatorFunctionSupplier supplier(String op, String dataType, i default -> throw new IllegalArgumentException("unsupported data type [" + dataType + "]"); }; default -> throw new IllegalArgumentException("unsupported op [" + op + "]"); - }; + }, filter); } - private static void checkExpected(String grouping, String op, String blockType, String dataType, Page page, int opCount) { + private static void checkExpected( + String grouping, + String op, + String blockType, + String filter, + String dataType, + Page page, + int opCount + ) { + if (filter.equals(CONSTANT_FALSE) || filter.equals(HALF_TRUE)) { + // We don't verify these because it's hard to get the right answer. + return; + } String prefix = String.format("[%s][%s][%s] ", grouping, op, blockType); if (grouping.equals("none")) { checkUngrouped(prefix, op, dataType, page, opCount); @@ -559,13 +585,59 @@ private static BytesRef bytesGroup(int group) { }); } + private static AggregatorFunctionSupplier filtered(AggregatorFunctionSupplier agg, String filter) { + if (filter.equals("none")) { + return agg; + } + BooleanBlock mask = mask(filter).asBlock(); + return new FilteredAggregatorFunctionSupplier(agg, context -> new EvalOperator.ExpressionEvaluator() { + @Override + public Block eval(Page page) { + mask.incRef(); + return mask; + } + + @Override + public void close() { + mask.close(); + } + }); + } + + private static BooleanVector mask(String filter) { + // Usually BLOCK_LENGTH is the count of positions, but sometimes the blocks are longer + int positionCount = BLOCK_LENGTH * 10; + return switch (filter) { + case CONSTANT_TRUE -> blockFactory.newConstantBooleanVector(true, positionCount); + case ALL_TRUE -> { + try (BooleanVector.Builder builder = blockFactory.newBooleanVectorFixedBuilder(positionCount)) { + for (int i = 0; i < positionCount; i++) { + builder.appendBoolean(true); + } + yield builder.build(); + } + } + case HALF_TRUE -> { + try (BooleanVector.Builder builder = blockFactory.newBooleanVectorFixedBuilder(positionCount)) { + for (int i = 0; i < positionCount; i++) { + builder.appendBoolean(i % 2 == 0); + } + yield builder.build(); + } + } + case CONSTANT_FALSE -> blockFactory.newConstantBooleanVector(false, positionCount); + default -> throw new IllegalArgumentException("unsupported filter [" + filter + "]"); + }; + } + @Benchmark @OperationsPerInvocation(OP_COUNT * BLOCK_LENGTH) public void run() { - run(grouping, op, blockType, OP_COUNT); + run(grouping, op, blockType, filter, OP_COUNT); } - private static void run(String grouping, String op, String blockType, int opCount) { + private static void run(String grouping, String op, String blockType, String filter, int opCount) { + // System.err.printf("[%s][%s][%s][%s][%s]\n", grouping, op, blockType, filter, opCount); String dataType = switch (blockType) { case VECTOR_LONGS, HALF_NULL_LONGS -> LONGS; case VECTOR_DOUBLES, HALF_NULL_DOUBLES -> DOUBLES; @@ -573,13 +645,13 @@ private static void run(String grouping, String op, String blockType, int opCoun }; DriverContext driverContext = driverContext(); - try (Operator operator = operator(driverContext, grouping, op, dataType)) { + try (Operator operator = operator(driverContext, grouping, op, dataType, filter)) { Page page = page(driverContext.blockFactory(), grouping, blockType); for (int i = 0; i < opCount; i++) { operator.addInput(page.shallowCopy()); } operator.finish(); - checkExpected(grouping, op, blockType, dataType, operator.getOutput(), opCount); + checkExpected(grouping, op, blockType, filter, dataType, operator.getOutput(), opCount); } } diff --git a/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/AggregatorImplementer.java b/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/AggregatorImplementer.java index 48269e7e2af9b..fe9576672cc2f 100644 --- a/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/AggregatorImplementer.java +++ b/x-pack/plugin/esql/compute/gen/src/main/java/org/elasticsearch/compute/gen/AggregatorImplementer.java @@ -353,14 +353,14 @@ private MethodSpec addRawInput() { builder.addStatement("return"); builder.endControlFlow(); } - builder.beginControlFlow("if (mask.isConstant())"); + builder.beginControlFlow("if (mask.allFalse())"); + { + builder.addComment("Entire page masked away"); + builder.addStatement("return"); + } + builder.endControlFlow(); + builder.beginControlFlow("if (mask.allTrue())"); { - builder.beginControlFlow("if (mask.getBoolean(0) == false)"); - { - builder.addComment("Entire page masked away"); - builder.addStatement("return"); - } - builder.endControlFlow(); builder.addComment("No masking"); builder.addStatement("$T block = page.getBlock(channels.get(0))", valueBlockType(init, combine)); builder.addStatement("$T vector = block.asVector()", valueVectorType(init, combine)); @@ -372,6 +372,7 @@ private MethodSpec addRawInput() { builder.addStatement("return"); } builder.endControlFlow(); + builder.addComment("Some positions masked away, others kept"); builder.addStatement("$T block = page.getBlock(channels.get(0))", valueBlockType(init, combine)); builder.addStatement("$T vector = block.asVector()", valueVectorType(init, combine)); diff --git a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BooleanArrayVector.java b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BooleanArrayVector.java index b44ad180a66ff..f761ed5806a06 100644 --- a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BooleanArrayVector.java +++ b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BooleanArrayVector.java @@ -128,6 +128,32 @@ public static long ramBytesEstimated(boolean[] values) { return BASE_RAM_BYTES_USED + RamUsageEstimator.sizeOf(values); } + /** + * Are all values {@code true}? This will scan all values to check and always answer accurately. + */ + @Override + public boolean allTrue() { + for (int i = 0; i < getPositionCount(); i++) { + if (values[i] == false) { + return false; + } + } + return true; + } + + /** + * Are all values {@code false}? This will scan all values to check and always answer accurately. + */ + @Override + public boolean allFalse() { + for (int i = 0; i < getPositionCount(); i++) { + if (values[i]) { + return false; + } + } + return true; + } + @Override public long ramBytesUsed() { return ramBytesEstimated(values); diff --git a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BooleanBigArrayVector.java b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BooleanBigArrayVector.java index f6bd6e978bc7e..a1ccfc487cca9 100644 --- a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BooleanBigArrayVector.java +++ b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BooleanBigArrayVector.java @@ -62,6 +62,32 @@ public boolean getBoolean(int position) { return values.get(position); } + /** + * Are all values {@code true}? This will scan all values to check and always answer accurately. + */ + @Override + public boolean allTrue() { + for (int i = 0; i < getPositionCount(); i++) { + if (values.get(i) == false) { + return false; + } + } + return true; + } + + /** + * Are all values {@code false}? This will scan all values to check and always answer accurately. + */ + @Override + public boolean allFalse() { + for (int i = 0; i < getPositionCount(); i++) { + if (values.get(i)) { + return false; + } + } + return true; + } + @Override public ElementType elementType() { return ElementType.BOOLEAN; diff --git a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BooleanVector.java b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BooleanVector.java index 5e3157a107fa5..f2d6b5fbd4ce9 100644 --- a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BooleanVector.java +++ b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/BooleanVector.java @@ -35,6 +35,16 @@ public sealed interface BooleanVector extends Vector permits ConstantBooleanVect @Override ReleasableIterator lookup(IntBlock positions, ByteSizeValue targetBlockSize); + /** + * Are all values {@code true}? This will scan all values to check and always answer accurately. + */ + boolean allTrue(); + + /** + * Are all values {@code false}? This will scan all values to check and always answer accurately. + */ + boolean allFalse(); + /** * Compares the given object with this vector for equality. Returns {@code true} if and only if the * given object is a BooleanVector, and both vectors are {@link #equals(BooleanVector, BooleanVector) equal}. diff --git a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/ConstantBooleanVector.java b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/ConstantBooleanVector.java index 1c886eb7c2dab..f36fbd7a20316 100644 --- a/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/ConstantBooleanVector.java +++ b/x-pack/plugin/esql/compute/src/main/generated-src/org/elasticsearch/compute/data/ConstantBooleanVector.java @@ -89,6 +89,22 @@ public ReleasableIterator lookup(IntBlock positions, ByteSizeValue return new BooleanLookup(asBlock(), positions, targetBlockSize); } + /** + * Are all values {@code true}? This will scan all values to check and always answer accurately. + */ + @Override + public boolean allTrue() { + return value; + } + + /** + * Are all values {@code false}? This will scan all values to check and always answer accurately. + */ + @Override + public boolean allFalse() { + return value == false; + } + @Override public ElementType elementType() { return ElementType.BOOLEAN; diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/CountDistinctBooleanAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/CountDistinctBooleanAggregatorFunction.java index 37543714717de..ca5cd1bda44d0 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/CountDistinctBooleanAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/CountDistinctBooleanAggregatorFunction.java @@ -54,11 +54,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking BooleanBlock block = page.getBlock(channels.get(0)); BooleanVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/CountDistinctBytesRefAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/CountDistinctBytesRefAggregatorFunction.java index 77d7e88cf9a93..38dadda1eba0c 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/CountDistinctBytesRefAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/CountDistinctBytesRefAggregatorFunction.java @@ -58,11 +58,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking BytesRefBlock block = page.getBlock(channels.get(0)); BytesRefVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/CountDistinctDoubleAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/CountDistinctDoubleAggregatorFunction.java index 4f0604b4f03c4..1d985fbd1dff6 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/CountDistinctDoubleAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/CountDistinctDoubleAggregatorFunction.java @@ -60,11 +60,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking DoubleBlock block = page.getBlock(channels.get(0)); DoubleVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/CountDistinctFloatAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/CountDistinctFloatAggregatorFunction.java index 00e5335138aa9..36d2aaf3e3d4f 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/CountDistinctFloatAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/CountDistinctFloatAggregatorFunction.java @@ -60,11 +60,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking FloatBlock block = page.getBlock(channels.get(0)); FloatVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/CountDistinctIntAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/CountDistinctIntAggregatorFunction.java index 90b4947b77d92..05bebca924f7e 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/CountDistinctIntAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/CountDistinctIntAggregatorFunction.java @@ -60,11 +60,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking IntBlock block = page.getBlock(channels.get(0)); IntVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/CountDistinctLongAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/CountDistinctLongAggregatorFunction.java index 99dc37d58a88c..9e62525fa2bb0 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/CountDistinctLongAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/CountDistinctLongAggregatorFunction.java @@ -60,11 +60,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking LongBlock block = page.getBlock(channels.get(0)); LongVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MaxBooleanAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MaxBooleanAggregatorFunction.java index 38de18bea776a..01763200f2d2c 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MaxBooleanAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MaxBooleanAggregatorFunction.java @@ -54,11 +54,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking BooleanBlock block = page.getBlock(channels.get(0)); BooleanVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MaxBytesRefAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MaxBytesRefAggregatorFunction.java index 1a4d440d2b8bc..73b927cd9c521 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MaxBytesRefAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MaxBytesRefAggregatorFunction.java @@ -57,11 +57,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking BytesRefBlock block = page.getBlock(channels.get(0)); BytesRefVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MaxDoubleAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MaxDoubleAggregatorFunction.java index 266977e2a689c..04d24d49cbff8 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MaxDoubleAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MaxDoubleAggregatorFunction.java @@ -56,11 +56,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking DoubleBlock block = page.getBlock(channels.get(0)); DoubleVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MaxFloatAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MaxFloatAggregatorFunction.java index 3a4dcaa3289fe..ce22983bff72b 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MaxFloatAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MaxFloatAggregatorFunction.java @@ -56,11 +56,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking FloatBlock block = page.getBlock(channels.get(0)); FloatVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MaxIntAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MaxIntAggregatorFunction.java index d5c0cea243499..6a91b574da769 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MaxIntAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MaxIntAggregatorFunction.java @@ -56,11 +56,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking IntBlock block = page.getBlock(channels.get(0)); IntVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MaxIpAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MaxIpAggregatorFunction.java index 13c74775d2796..7f6d47ce1c876 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MaxIpAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MaxIpAggregatorFunction.java @@ -57,11 +57,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking BytesRefBlock block = page.getBlock(channels.get(0)); BytesRefVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MaxLongAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MaxLongAggregatorFunction.java index d2acff0509dfe..97d12d1ef6852 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MaxLongAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MaxLongAggregatorFunction.java @@ -56,11 +56,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking LongBlock block = page.getBlock(channels.get(0)); LongVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MedianAbsoluteDeviationDoubleAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MedianAbsoluteDeviationDoubleAggregatorFunction.java index 4791767f4b43e..611314318eba7 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MedianAbsoluteDeviationDoubleAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MedianAbsoluteDeviationDoubleAggregatorFunction.java @@ -57,11 +57,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking DoubleBlock block = page.getBlock(channels.get(0)); DoubleVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MedianAbsoluteDeviationFloatAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MedianAbsoluteDeviationFloatAggregatorFunction.java index fd0e5d5fce1a8..e20badf2ce38a 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MedianAbsoluteDeviationFloatAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MedianAbsoluteDeviationFloatAggregatorFunction.java @@ -57,11 +57,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking FloatBlock block = page.getBlock(channels.get(0)); FloatVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MedianAbsoluteDeviationIntAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MedianAbsoluteDeviationIntAggregatorFunction.java index 67bc4b3bf0356..df0d24d442283 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MedianAbsoluteDeviationIntAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MedianAbsoluteDeviationIntAggregatorFunction.java @@ -57,11 +57,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking IntBlock block = page.getBlock(channels.get(0)); IntVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MedianAbsoluteDeviationLongAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MedianAbsoluteDeviationLongAggregatorFunction.java index 9255bb19cda70..e0ace94a1da49 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MedianAbsoluteDeviationLongAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MedianAbsoluteDeviationLongAggregatorFunction.java @@ -57,11 +57,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking LongBlock block = page.getBlock(channels.get(0)); LongVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MinBooleanAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MinBooleanAggregatorFunction.java index 9bd63ed8efbd8..4d91d3794aecb 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MinBooleanAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MinBooleanAggregatorFunction.java @@ -54,11 +54,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking BooleanBlock block = page.getBlock(channels.get(0)); BooleanVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MinBytesRefAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MinBytesRefAggregatorFunction.java index 2789f18a19dfc..01ee21f82ab53 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MinBytesRefAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MinBytesRefAggregatorFunction.java @@ -57,11 +57,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking BytesRefBlock block = page.getBlock(channels.get(0)); BytesRefVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MinDoubleAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MinDoubleAggregatorFunction.java index e736f91e0b38c..a436cdcdbef6d 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MinDoubleAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MinDoubleAggregatorFunction.java @@ -56,11 +56,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking DoubleBlock block = page.getBlock(channels.get(0)); DoubleVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MinFloatAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MinFloatAggregatorFunction.java index 9d67ccb8fb736..ec6757e59d074 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MinFloatAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MinFloatAggregatorFunction.java @@ -56,11 +56,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking FloatBlock block = page.getBlock(channels.get(0)); FloatVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MinIntAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MinIntAggregatorFunction.java index a5ead0bd635c0..f76dcec81d871 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MinIntAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MinIntAggregatorFunction.java @@ -56,11 +56,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking IntBlock block = page.getBlock(channels.get(0)); IntVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MinIpAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MinIpAggregatorFunction.java index 60ba1993f45d8..795299d9332fc 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MinIpAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MinIpAggregatorFunction.java @@ -57,11 +57,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking BytesRefBlock block = page.getBlock(channels.get(0)); BytesRefVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MinLongAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MinLongAggregatorFunction.java index b7bab86d6423e..4fc968bab2eff 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MinLongAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/MinLongAggregatorFunction.java @@ -56,11 +56,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking LongBlock block = page.getBlock(channels.get(0)); LongVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/PercentileDoubleAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/PercentileDoubleAggregatorFunction.java index 4de609a4c6044..9ece01135e0a9 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/PercentileDoubleAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/PercentileDoubleAggregatorFunction.java @@ -60,11 +60,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking DoubleBlock block = page.getBlock(channels.get(0)); DoubleVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/PercentileFloatAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/PercentileFloatAggregatorFunction.java index 095499fc9642a..434989adf47b2 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/PercentileFloatAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/PercentileFloatAggregatorFunction.java @@ -60,11 +60,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking FloatBlock block = page.getBlock(channels.get(0)); FloatVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/PercentileIntAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/PercentileIntAggregatorFunction.java index 33e06691fd367..eb4ae96f5dea5 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/PercentileIntAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/PercentileIntAggregatorFunction.java @@ -60,11 +60,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking IntBlock block = page.getBlock(channels.get(0)); IntVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/PercentileLongAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/PercentileLongAggregatorFunction.java index 0a20153e4a33d..837f7efb32441 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/PercentileLongAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/PercentileLongAggregatorFunction.java @@ -60,11 +60,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking LongBlock block = page.getBlock(channels.get(0)); LongVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/SumDoubleAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/SumDoubleAggregatorFunction.java index 7f0e0b4e15158..4d24579203df1 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/SumDoubleAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/SumDoubleAggregatorFunction.java @@ -57,11 +57,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking DoubleBlock block = page.getBlock(channels.get(0)); DoubleVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/SumFloatAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/SumFloatAggregatorFunction.java index d916b832d77ff..50f41b5edc05f 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/SumFloatAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/SumFloatAggregatorFunction.java @@ -59,11 +59,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking FloatBlock block = page.getBlock(channels.get(0)); FloatVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/SumIntAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/SumIntAggregatorFunction.java index 5cd1abc35d28f..95bd95ac474ad 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/SumIntAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/SumIntAggregatorFunction.java @@ -58,11 +58,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking IntBlock block = page.getBlock(channels.get(0)); IntVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/SumLongAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/SumLongAggregatorFunction.java index e7781f82b1021..fac21d99bf713 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/SumLongAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/SumLongAggregatorFunction.java @@ -56,11 +56,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking LongBlock block = page.getBlock(channels.get(0)); LongVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/TopBooleanAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/TopBooleanAggregatorFunction.java index 0580dc297a362..b8d06787f7f68 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/TopBooleanAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/TopBooleanAggregatorFunction.java @@ -59,11 +59,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking BooleanBlock block = page.getBlock(channels.get(0)); BooleanVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/TopBytesRefAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/TopBytesRefAggregatorFunction.java index 17b3d84ab0028..9ef460be5796b 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/TopBytesRefAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/TopBytesRefAggregatorFunction.java @@ -61,11 +61,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking BytesRefBlock block = page.getBlock(channels.get(0)); BytesRefVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/TopDoubleAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/TopDoubleAggregatorFunction.java index 899af1a58851b..210bc76483a81 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/TopDoubleAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/TopDoubleAggregatorFunction.java @@ -60,11 +60,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking DoubleBlock block = page.getBlock(channels.get(0)); DoubleVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/TopFloatAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/TopFloatAggregatorFunction.java index 168e7685c5273..f7fdb406acadb 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/TopFloatAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/TopFloatAggregatorFunction.java @@ -60,11 +60,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking FloatBlock block = page.getBlock(channels.get(0)); FloatVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/TopIntAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/TopIntAggregatorFunction.java index 80964decf572d..1ea40134f7260 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/TopIntAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/TopIntAggregatorFunction.java @@ -60,11 +60,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking IntBlock block = page.getBlock(channels.get(0)); IntVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/TopIpAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/TopIpAggregatorFunction.java index 90d8d7c124244..8c216c90504c1 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/TopIpAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/TopIpAggregatorFunction.java @@ -61,11 +61,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking BytesRefBlock block = page.getBlock(channels.get(0)); BytesRefVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/TopLongAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/TopLongAggregatorFunction.java index 18eef5a29b895..85df0f7edc843 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/TopLongAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/TopLongAggregatorFunction.java @@ -60,11 +60,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking LongBlock block = page.getBlock(channels.get(0)); LongVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/ValuesBooleanAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/ValuesBooleanAggregatorFunction.java index d71d9a7b45bdb..abf73c07d4ab6 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/ValuesBooleanAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/ValuesBooleanAggregatorFunction.java @@ -53,11 +53,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking BooleanBlock block = page.getBlock(channels.get(0)); BooleanVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/ValuesBytesRefAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/ValuesBytesRefAggregatorFunction.java index 56e79b64e3b86..ecc6424ba8501 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/ValuesBytesRefAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/ValuesBytesRefAggregatorFunction.java @@ -55,11 +55,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking BytesRefBlock block = page.getBlock(channels.get(0)); BytesRefVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/ValuesDoubleAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/ValuesDoubleAggregatorFunction.java index 3ec31b0fd5a4d..2fa8ed31ec427 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/ValuesDoubleAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/ValuesDoubleAggregatorFunction.java @@ -54,11 +54,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking DoubleBlock block = page.getBlock(channels.get(0)); DoubleVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/ValuesFloatAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/ValuesFloatAggregatorFunction.java index 00ab8db1c4ac6..8b61c6d07eed6 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/ValuesFloatAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/ValuesFloatAggregatorFunction.java @@ -54,11 +54,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking FloatBlock block = page.getBlock(channels.get(0)); FloatVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/ValuesIntAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/ValuesIntAggregatorFunction.java index 5a0d7c893e607..7f12bbc18b202 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/ValuesIntAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/ValuesIntAggregatorFunction.java @@ -54,11 +54,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking IntBlock block = page.getBlock(channels.get(0)); IntVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/ValuesLongAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/ValuesLongAggregatorFunction.java index ca9a8347e3a41..7e8c256d90f93 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/ValuesLongAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/ValuesLongAggregatorFunction.java @@ -54,11 +54,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking LongBlock block = page.getBlock(channels.get(0)); LongVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/spatial/SpatialCentroidCartesianPointDocValuesAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/spatial/SpatialCentroidCartesianPointDocValuesAggregatorFunction.java index a427c75c63fff..a205c728db5fc 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/spatial/SpatialCentroidCartesianPointDocValuesAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/spatial/SpatialCentroidCartesianPointDocValuesAggregatorFunction.java @@ -62,11 +62,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking LongBlock block = page.getBlock(channels.get(0)); LongVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/spatial/SpatialCentroidCartesianPointSourceValuesAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/spatial/SpatialCentroidCartesianPointSourceValuesAggregatorFunction.java index c2086f2ab3d98..e20a3fb1cfa35 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/spatial/SpatialCentroidCartesianPointSourceValuesAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/spatial/SpatialCentroidCartesianPointSourceValuesAggregatorFunction.java @@ -65,11 +65,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking BytesRefBlock block = page.getBlock(channels.get(0)); BytesRefVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/spatial/SpatialCentroidGeoPointDocValuesAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/spatial/SpatialCentroidGeoPointDocValuesAggregatorFunction.java index 0509c03ebf77c..b2c237a904796 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/spatial/SpatialCentroidGeoPointDocValuesAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/spatial/SpatialCentroidGeoPointDocValuesAggregatorFunction.java @@ -62,11 +62,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking LongBlock block = page.getBlock(channels.get(0)); LongVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/spatial/SpatialCentroidGeoPointSourceValuesAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/spatial/SpatialCentroidGeoPointSourceValuesAggregatorFunction.java index 10a29c841b79f..db61420fb8cbe 100644 --- a/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/spatial/SpatialCentroidGeoPointSourceValuesAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/generated/org/elasticsearch/compute/aggregation/spatial/SpatialCentroidGeoPointSourceValuesAggregatorFunction.java @@ -65,11 +65,11 @@ public int intermediateBlockCount() { @Override public void addRawInput(Page page, BooleanVector mask) { - if (mask.isConstant()) { - if (mask.getBoolean(0) == false) { - // Entire page masked away - return; - } + if (mask.allFalse()) { + // Entire page masked away + return; + } + if (mask.allTrue()) { // No masking BytesRefBlock block = page.getBlock(channels.get(0)); BytesRefVector vector = block.asVector(); diff --git a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/CountGroupingAggregatorFunction.java b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/CountGroupingAggregatorFunction.java index f610abf271cfa..e107a73f7ab1e 100644 --- a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/CountGroupingAggregatorFunction.java +++ b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/CountGroupingAggregatorFunction.java @@ -142,7 +142,6 @@ private void addRawInput(IntVector groups) { */ private void addRawInput(IntBlock groups) { for (int groupPosition = 0; groupPosition < groups.getPositionCount(); groupPosition++) { - // TODO remove the check one we don't emit null anymore if (groups.isNull(groupPosition)) { continue; } diff --git a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/blockhash/AddPage.java b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/blockhash/AddPage.java index 4e051c73a3643..9a48ea9e5673a 100644 --- a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/blockhash/AddPage.java +++ b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/blockhash/AddPage.java @@ -171,6 +171,6 @@ private void rollover(int position) { @Override public void close() { - Releasables.closeExpectNoException(ords, addInput); + Releasables.closeExpectNoException(ords); } } diff --git a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/blockhash/BlockHash.java b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/blockhash/BlockHash.java index abd11f98e7376..fe1a07e8e16a6 100644 --- a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/blockhash/BlockHash.java +++ b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/blockhash/BlockHash.java @@ -47,6 +47,9 @@ public abstract sealed class BlockHash implements Releasable, SeenGroupIds // /** * Add all values for the "group by" columns in the page to the hash and * pass the ordinals to the provided {@link GroupingAggregatorFunction.AddInput}. + *

+ * This call will not {@link GroupingAggregatorFunction.AddInput#close} {@code addInput}. + *

*/ public abstract void add(Page page, GroupingAggregatorFunction.AddInput addInput); diff --git a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/ConstantNullVector.java b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/ConstantNullVector.java index 9bcd8a19c0132..236012a674ef6 100644 --- a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/ConstantNullVector.java +++ b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/ConstantNullVector.java @@ -114,6 +114,18 @@ public int max() { throw new UnsupportedOperationException("null vector"); } + @Override + public boolean allTrue() { + assert false : "null vector"; + throw new UnsupportedOperationException("null vector"); + } + + @Override + public boolean allFalse() { + assert false : "null vector"; + throw new UnsupportedOperationException("null vector"); + } + @Override public ElementType elementType() { return ElementType.NULL; diff --git a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-ArrayVector.java.st b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-ArrayVector.java.st index 9b5b8b65e8c66..3bb13674ce477 100644 --- a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-ArrayVector.java.st +++ b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-ArrayVector.java.st @@ -240,6 +240,33 @@ $if(int)$ } return max; } + +$elseif(boolean)$ + /** + * Are all values {@code true}? This will scan all values to check and always answer accurately. + */ + @Override + public boolean allTrue() { + for (int i = 0; i < getPositionCount(); i++) { + if (values[i] == false) { + return false; + } + } + return true; + } + + /** + * Are all values {@code false}? This will scan all values to check and always answer accurately. + */ + @Override + public boolean allFalse() { + for (int i = 0; i < getPositionCount(); i++) { + if (values[i]) { + return false; + } + } + return true; + } $endif$ @Override diff --git a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-BigArrayVector.java.st b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-BigArrayVector.java.st index b509313b079dd..106d0769ebb07 100644 --- a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-BigArrayVector.java.st +++ b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-BigArrayVector.java.st @@ -119,6 +119,33 @@ $if(int)$ } return max; } + +$elseif(boolean)$ + /** + * Are all values {@code true}? This will scan all values to check and always answer accurately. + */ + @Override + public boolean allTrue() { + for (int i = 0; i < getPositionCount(); i++) { + if (values.get(i) == false) { + return false; + } + } + return true; + } + + /** + * Are all values {@code false}? This will scan all values to check and always answer accurately. + */ + @Override + public boolean allFalse() { + for (int i = 0; i < getPositionCount(); i++) { + if (values.get(i)) { + return false; + } + } + return true; + } $endif$ @Override diff --git a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-ConstantVector.java.st b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-ConstantVector.java.st index 72999ffd96fae..5d0d4c8a956f3 100644 --- a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-ConstantVector.java.st +++ b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-ConstantVector.java.st @@ -147,6 +147,23 @@ $if(int)$ public int max() { return value; } + +$elseif(boolean)$ + /** + * Are all values {@code true}? This will scan all values to check and always answer accurately. + */ + @Override + public boolean allTrue() { + return value; + } + + /** + * Are all values {@code false}? This will scan all values to check and always answer accurately. + */ + @Override + public boolean allFalse() { + return value == false; + } $endif$ @Override diff --git a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-Vector.java.st b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-Vector.java.st index e19c1788cdb6b..c556cba7ef2e4 100644 --- a/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-Vector.java.st +++ b/x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/X-Vector.java.st @@ -72,6 +72,17 @@ $if(int)$ * The maximum value in the Vector. An empty Vector will return {@link Integer#MIN_VALUE}. */ int max(); + +$elseif(boolean)$ + /** + * Are all values {@code true}? This will scan all values to check and always answer accurately. + */ + boolean allTrue(); + + /** + * Are all values {@code false}? This will scan all values to check and always answer accurately. + */ + boolean allFalse(); $endif$ /** diff --git a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/ConstantBooleanExpressionEvaluator.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/ConstantBooleanExpressionEvaluator.java new file mode 100644 index 0000000000000..9700a0200f755 --- /dev/null +++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/ConstantBooleanExpressionEvaluator.java @@ -0,0 +1,42 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +package org.elasticsearch.compute; + +import org.elasticsearch.compute.data.Block; +import org.elasticsearch.compute.data.BlockFactory; +import org.elasticsearch.compute.data.BooleanVector; +import org.elasticsearch.compute.data.Page; +import org.elasticsearch.compute.operator.EvalOperator; + +import static org.elasticsearch.test.ESTestCase.randomBoolean; + +/** + * An {@link EvalOperator.ExpressionEvaluator} that evaluates to a constant boolean value. + */ +public record ConstantBooleanExpressionEvaluator(BlockFactory factory, boolean value) implements EvalOperator.ExpressionEvaluator { + public static EvalOperator.ExpressionEvaluator.Factory factory(boolean value) { + return ctx -> new ConstantBooleanExpressionEvaluator(ctx.blockFactory(), value); + } + + @Override + public Block eval(Page page) { + if (randomBoolean()) { + return factory.newConstantBooleanVector(value, page.getPositionCount()).asBlock(); + } + try (BooleanVector.Builder builder = factory.newBooleanVectorFixedBuilder(page.getPositionCount())) { + for (int p = 0; p < page.getPositionCount(); p++) { + builder.appendBoolean(value); + } + return builder.build().asBlock(); + } + } + + @Override + public void close() {} + +} diff --git a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/AggregatorFunctionTestCase.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/AggregatorFunctionTestCase.java index 275038e6d2f02..a4eb252dbf35c 100644 --- a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/AggregatorFunctionTestCase.java +++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/AggregatorFunctionTestCase.java @@ -8,6 +8,7 @@ package org.elasticsearch.compute.aggregation; import org.apache.lucene.util.BytesRef; +import org.elasticsearch.compute.ConstantBooleanExpressionEvaluator; import org.elasticsearch.compute.data.Block; import org.elasticsearch.compute.data.BlockFactory; import org.elasticsearch.compute.data.BlockTestUtils; @@ -34,6 +35,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.function.Function; import java.util.stream.DoubleStream; import java.util.stream.IntStream; import java.util.stream.LongStream; @@ -58,8 +60,17 @@ protected final int aggregatorIntermediateBlockCount() { @Override protected Operator.OperatorFactory simpleWithMode(AggregatorMode mode) { + return simpleWithMode(mode, Function.identity()); + } + + private Operator.OperatorFactory simpleWithMode( + AggregatorMode mode, + Function wrap + ) { List channels = mode.isInputPartial() ? range(0, aggregatorIntermediateBlockCount()).boxed().toList() : List.of(0); - return new AggregationOperator.AggregationOperatorFactory(List.of(aggregatorFunction(channels).aggregatorFactory(mode)), mode); + AggregatorFunctionSupplier supplier = aggregatorFunction(channels); + Aggregator.Factory factory = wrap.apply(supplier).aggregatorFactory(mode); + return new AggregationOperator.AggregationOperatorFactory(List.of(factory), mode); } @Override @@ -141,6 +152,7 @@ public final void testEmptyInput() { List results = drive(simple().get(driverContext), List.of().iterator(), driverContext); assertThat(results, hasSize(1)); + assertOutputFromEmpty(results.get(0).getBlock(0)); } public final void testEmptyInputInitialFinal() { @@ -166,6 +178,31 @@ public final void testEmptyInputInitialIntermediateFinal() { assertOutputFromEmpty(results.get(0).getBlock(0)); } + public void testAllFiltered() { + Operator.OperatorFactory factory = simpleWithMode( + AggregatorMode.SINGLE, + agg -> new FilteredAggregatorFunctionSupplier(agg, ConstantBooleanExpressionEvaluator.factory(false)) + ); + DriverContext driverContext = driverContext(); + List input = CannedSourceOperator.collectPages(simpleInput(driverContext.blockFactory(), 10)); + List results = drive(factory.get(driverContext), input.iterator(), driverContext); + assertThat(results, hasSize(1)); + assertOutputFromEmpty(results.get(0).getBlock(0)); + } + + public void testNoneFiltered() { + Operator.OperatorFactory factory = simpleWithMode( + AggregatorMode.SINGLE, + agg -> new FilteredAggregatorFunctionSupplier(agg, ConstantBooleanExpressionEvaluator.factory(true)) + ); + DriverContext driverContext = driverContext(); + List input = CannedSourceOperator.collectPages(simpleInput(driverContext.blockFactory(), 10)); + List origInput = BlockTestUtils.deepCopyOf(input, TestBlockFactory.getNonBreakingInstance()); + List results = drive(factory.get(driverContext), input.iterator(), driverContext); + assertThat(results, hasSize(1)); + assertSimpleOutput(origInput, results); + } + // Returns an intermediate state that is equivalent to what the local execution planner will emit // if it determines that certain shards have no relevant data. List nullIntermediateState(BlockFactory blockFactory) { diff --git a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/CountDistinctBooleanGroupingAggregatorFunctionTests.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/CountDistinctBooleanGroupingAggregatorFunctionTests.java index 66ecbb6eb1130..c39fe32620ff9 100644 --- a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/CountDistinctBooleanGroupingAggregatorFunctionTests.java +++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/CountDistinctBooleanGroupingAggregatorFunctionTests.java @@ -9,7 +9,9 @@ import org.elasticsearch.compute.data.Block; import org.elasticsearch.compute.data.BlockFactory; +import org.elasticsearch.compute.data.ElementType; import org.elasticsearch.compute.data.LongBlock; +import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.LongBooleanTupleBlockSourceOperator; import org.elasticsearch.compute.operator.SourceOperator; @@ -53,4 +55,13 @@ protected void assertOutputFromNullOnly(Block b, int position) { assertThat(b.getValueCount(position), equalTo(1)); assertThat(((LongBlock) b).getLong(b.getFirstValueIndex(position)), equalTo(0L)); } + + @Override + protected void assertOutputFromAllFiltered(Block b) { + assertThat(b.elementType(), equalTo(ElementType.LONG)); + LongVector v = (LongVector) b.asVector(); + for (int p = 0; p < v.getPositionCount(); p++) { + assertThat(v.getLong(p), equalTo(0L)); + } + } } diff --git a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/CountDistinctBytesRefGroupingAggregatorFunctionTests.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/CountDistinctBytesRefGroupingAggregatorFunctionTests.java index cbc2a5227d9ea..dd739d2189ba8 100644 --- a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/CountDistinctBytesRefGroupingAggregatorFunctionTests.java +++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/CountDistinctBytesRefGroupingAggregatorFunctionTests.java @@ -10,7 +10,9 @@ import org.apache.lucene.util.BytesRef; import org.elasticsearch.compute.data.Block; import org.elasticsearch.compute.data.BlockFactory; +import org.elasticsearch.compute.data.ElementType; import org.elasticsearch.compute.data.LongBlock; +import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.LongBytesRefTupleBlockSourceOperator; import org.elasticsearch.compute.operator.SourceOperator; @@ -58,4 +60,13 @@ protected void assertOutputFromNullOnly(Block b, int position) { assertThat(b.getValueCount(position), equalTo(1)); assertThat(((LongBlock) b).getLong(b.getFirstValueIndex(position)), equalTo(0L)); } + + @Override + protected void assertOutputFromAllFiltered(Block b) { + assertThat(b.elementType(), equalTo(ElementType.LONG)); + LongVector v = (LongVector) b.asVector(); + for (int p = 0; p < v.getPositionCount(); p++) { + assertThat(v.getLong(p), equalTo(0L)); + } + } } diff --git a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/CountDistinctDoubleGroupingAggregatorFunctionTests.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/CountDistinctDoubleGroupingAggregatorFunctionTests.java index 56a0d863038bc..7b6f928d57ddb 100644 --- a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/CountDistinctDoubleGroupingAggregatorFunctionTests.java +++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/CountDistinctDoubleGroupingAggregatorFunctionTests.java @@ -9,7 +9,9 @@ import org.elasticsearch.compute.data.Block; import org.elasticsearch.compute.data.BlockFactory; +import org.elasticsearch.compute.data.ElementType; import org.elasticsearch.compute.data.LongBlock; +import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.LongDoubleTupleBlockSourceOperator; import org.elasticsearch.compute.operator.SourceOperator; @@ -57,4 +59,13 @@ protected void assertOutputFromNullOnly(Block b, int position) { assertThat(b.getValueCount(position), equalTo(1)); assertThat(((LongBlock) b).getLong(b.getFirstValueIndex(position)), equalTo(0L)); } + + @Override + protected void assertOutputFromAllFiltered(Block b) { + assertThat(b.elementType(), equalTo(ElementType.LONG)); + LongVector v = (LongVector) b.asVector(); + for (int p = 0; p < v.getPositionCount(); p++) { + assertThat(v.getLong(p), equalTo(0L)); + } + } } diff --git a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/CountDistinctFloatGroupingAggregatorFunctionTests.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/CountDistinctFloatGroupingAggregatorFunctionTests.java index 03a11bb976b21..6b4a8f2900aaa 100644 --- a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/CountDistinctFloatGroupingAggregatorFunctionTests.java +++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/CountDistinctFloatGroupingAggregatorFunctionTests.java @@ -9,7 +9,9 @@ import org.elasticsearch.compute.data.Block; import org.elasticsearch.compute.data.BlockFactory; +import org.elasticsearch.compute.data.ElementType; import org.elasticsearch.compute.data.LongBlock; +import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.LongFloatTupleBlockSourceOperator; import org.elasticsearch.compute.operator.SourceOperator; @@ -57,4 +59,13 @@ protected void assertOutputFromNullOnly(Block b, int position) { assertThat(b.getValueCount(position), equalTo(1)); assertThat(((LongBlock) b).getLong(b.getFirstValueIndex(position)), equalTo(0L)); } + + @Override + protected void assertOutputFromAllFiltered(Block b) { + assertThat(b.elementType(), equalTo(ElementType.LONG)); + LongVector v = (LongVector) b.asVector(); + for (int p = 0; p < v.getPositionCount(); p++) { + assertThat(v.getLong(p), equalTo(0L)); + } + } } diff --git a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/CountDistinctIntGroupingAggregatorFunctionTests.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/CountDistinctIntGroupingAggregatorFunctionTests.java index 229ec49bcffa8..cfd3357a14c03 100644 --- a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/CountDistinctIntGroupingAggregatorFunctionTests.java +++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/CountDistinctIntGroupingAggregatorFunctionTests.java @@ -9,7 +9,9 @@ import org.elasticsearch.compute.data.Block; import org.elasticsearch.compute.data.BlockFactory; +import org.elasticsearch.compute.data.ElementType; import org.elasticsearch.compute.data.LongBlock; +import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.LongIntBlockSourceOperator; import org.elasticsearch.compute.operator.SourceOperator; @@ -57,4 +59,13 @@ protected void assertOutputFromNullOnly(Block b, int position) { assertThat(b.getValueCount(position), equalTo(1)); assertThat(((LongBlock) b).getLong(b.getFirstValueIndex(position)), equalTo(0L)); } + + @Override + protected void assertOutputFromAllFiltered(Block b) { + assertThat(b.elementType(), equalTo(ElementType.LONG)); + LongVector v = (LongVector) b.asVector(); + for (int p = 0; p < v.getPositionCount(); p++) { + assertThat(v.getLong(p), equalTo(0L)); + } + } } diff --git a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/CountDistinctLongGroupingAggregatorFunctionTests.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/CountDistinctLongGroupingAggregatorFunctionTests.java index 539ef35390663..55be7fe9a8ed3 100644 --- a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/CountDistinctLongGroupingAggregatorFunctionTests.java +++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/CountDistinctLongGroupingAggregatorFunctionTests.java @@ -9,7 +9,9 @@ import org.elasticsearch.compute.data.Block; import org.elasticsearch.compute.data.BlockFactory; +import org.elasticsearch.compute.data.ElementType; import org.elasticsearch.compute.data.LongBlock; +import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.SourceOperator; import org.elasticsearch.compute.operator.TupleBlockSourceOperator; @@ -56,4 +58,13 @@ protected void assertOutputFromNullOnly(Block b, int position) { assertThat(b.getValueCount(position), equalTo(1)); assertThat(((LongBlock) b).getLong(b.getFirstValueIndex(position)), equalTo(0L)); } + + @Override + protected void assertOutputFromAllFiltered(Block b) { + assertThat(b.elementType(), equalTo(ElementType.LONG)); + LongVector v = (LongVector) b.asVector(); + for (int p = 0; p < v.getPositionCount(); p++) { + assertThat(v.getLong(p), equalTo(0L)); + } + } } diff --git a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/CountGroupingAggregatorFunctionTests.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/CountGroupingAggregatorFunctionTests.java index 1d658f80c4e29..06c267ff2d6ab 100644 --- a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/CountGroupingAggregatorFunctionTests.java +++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/CountGroupingAggregatorFunctionTests.java @@ -9,7 +9,9 @@ import org.elasticsearch.compute.data.Block; import org.elasticsearch.compute.data.BlockFactory; +import org.elasticsearch.compute.data.ElementType; import org.elasticsearch.compute.data.LongBlock; +import org.elasticsearch.compute.data.LongVector; import org.elasticsearch.compute.data.Page; import org.elasticsearch.compute.operator.LongDoubleTupleBlockSourceOperator; import org.elasticsearch.compute.operator.SourceOperator; @@ -58,4 +60,13 @@ protected void assertOutputFromNullOnly(Block b, int position) { assertThat(b.getValueCount(position), equalTo(1)); assertThat(((LongBlock) b).getLong(b.getFirstValueIndex(position)), equalTo(0L)); } + + @Override + protected void assertOutputFromAllFiltered(Block b) { + assertThat(b.elementType(), equalTo(ElementType.LONG)); + LongVector v = (LongVector) b.asVector(); + for (int p = 0; p < v.getPositionCount(); p++) { + assertThat(v.getLong(p), equalTo(0L)); + } + } } diff --git a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/FilteredAggregatorFunctionTests.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/FilteredAggregatorFunctionTests.java index 6ad3251d3c120..7e1575fb81726 100644 --- a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/FilteredAggregatorFunctionTests.java +++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/FilteredAggregatorFunctionTests.java @@ -93,4 +93,14 @@ public void checkUnclosed() { } assertThat(unclosed, empty()); } + + @Override + public void testNoneFiltered() { + assumeFalse("can't double filter. tests already filter.", true); + } + + @Override + public void testAllFiltered() { + assumeFalse("can't double filter. tests already filter.", true); + } } diff --git a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/GroupingAggregatorFunctionTestCase.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/GroupingAggregatorFunctionTestCase.java index de9337f5fce2c..316058e57e089 100644 --- a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/GroupingAggregatorFunctionTestCase.java +++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/GroupingAggregatorFunctionTestCase.java @@ -10,6 +10,7 @@ import org.apache.lucene.document.InetAddressPoint; import org.apache.lucene.util.BytesRef; import org.elasticsearch.common.util.BitArray; +import org.elasticsearch.compute.ConstantBooleanExpressionEvaluator; import org.elasticsearch.compute.aggregation.blockhash.BlockHash; import org.elasticsearch.compute.data.Block; import org.elasticsearch.compute.data.BlockFactory; @@ -42,6 +43,7 @@ import java.util.List; import java.util.SortedSet; import java.util.TreeSet; +import java.util.function.Function; import java.util.stream.DoubleStream; import java.util.stream.IntStream; import java.util.stream.LongStream; @@ -82,10 +84,17 @@ protected DataType acceptedDataType() { @Override protected final Operator.OperatorFactory simpleWithMode(AggregatorMode mode) { + return simpleWithMode(mode, Function.identity()); + } + + private Operator.OperatorFactory simpleWithMode( + AggregatorMode mode, + Function wrap + ) { List channels = mode.isInputPartial() ? range(1, 1 + aggregatorIntermediateBlockCount()).boxed().toList() : List.of(1); int emitChunkSize = between(100, 200); - AggregatorFunctionSupplier supplier = aggregatorFunction(channels); + AggregatorFunctionSupplier supplier = wrap.apply(aggregatorFunction(channels)); if (randomBoolean()) { supplier = chunkGroups(emitChunkSize, supplier); } @@ -353,6 +362,49 @@ public final void testNullOnlyInputInitialIntermediateFinal() { ); } + public final void testEmptyInput() { + DriverContext driverContext = driverContext(); + List results = drive(simple().get(driverContext), List.of().iterator(), driverContext); + + assertThat(results, hasSize(0)); + } + + public final void testAllFiltered() { + Operator.OperatorFactory factory = simpleWithMode( + AggregatorMode.SINGLE, + agg -> new FilteredAggregatorFunctionSupplier(agg, ConstantBooleanExpressionEvaluator.factory(false)) + ); + DriverContext driverContext = driverContext(); + List input = CannedSourceOperator.collectPages(simpleInput(driverContext.blockFactory(), 10)); + List results = drive(factory.get(driverContext), input.iterator(), driverContext); + assertThat(results, hasSize(1)); + assertOutputFromAllFiltered(results.get(0).getBlock(1)); + } + + public final void testNoneFiltered() { + Operator.OperatorFactory factory = simpleWithMode( + AggregatorMode.SINGLE, + agg -> new FilteredAggregatorFunctionSupplier(agg, ConstantBooleanExpressionEvaluator.factory(true)) + ); + DriverContext driverContext = driverContext(); + List input = CannedSourceOperator.collectPages(simpleInput(driverContext.blockFactory(), 10)); + List origInput = BlockTestUtils.deepCopyOf(input, TestBlockFactory.getNonBreakingInstance()); + List results = drive(factory.get(driverContext), input.iterator(), driverContext); + assertThat(results, hasSize(1)); + assertSimpleOutput(origInput, results); + } + + /** + * Asserts that the output from an empty input is a {@link Block} containing + * only {@code null}. Override for {@code count} style aggregations that + * return other sorts of results. + */ + protected void assertOutputFromAllFiltered(Block b) { + assertThat(b.areAllValuesNull(), equalTo(true)); + assertThat(b.isNull(0), equalTo(true)); + assertThat(b.getValueCount(0), equalTo(0)); + } + /** * Run the aggregation passing only null values. */ @@ -560,31 +612,34 @@ public AddInput prepareProcessPage(SeenGroupIds ignoredSeenGroupIds, Page page) @Override public void add(int positionOffset, IntBlock groupIds) { for (int offset = 0; offset < groupIds.getPositionCount(); offset += emitChunkSize) { - IntBlock.Builder builder = blockFactory().newIntBlockBuilder(emitChunkSize); - int endP = Math.min(groupIds.getPositionCount(), offset + emitChunkSize); - for (int p = offset; p < endP; p++) { - int start = groupIds.getFirstValueIndex(p); - int count = groupIds.getValueCount(p); - switch (count) { - case 0 -> builder.appendNull(); - case 1 -> { - int group = groupIds.getInt(start); - seenGroupIds.set(group); - builder.appendInt(group); - } - default -> { - int end = start + count; - builder.beginPositionEntry(); - for (int i = start; i < end; i++) { - int group = groupIds.getInt(i); + try (IntBlock.Builder builder = blockFactory().newIntBlockBuilder(emitChunkSize)) { + int endP = Math.min(groupIds.getPositionCount(), offset + emitChunkSize); + for (int p = offset; p < endP; p++) { + int start = groupIds.getFirstValueIndex(p); + int count = groupIds.getValueCount(p); + switch (count) { + case 0 -> builder.appendNull(); + case 1 -> { + int group = groupIds.getInt(start); seenGroupIds.set(group); builder.appendInt(group); } - builder.endPositionEntry(); + default -> { + int end = start + count; + builder.beginPositionEntry(); + for (int i = start; i < end; i++) { + int group = groupIds.getInt(i); + seenGroupIds.set(group); + builder.appendInt(group); + } + builder.endPositionEntry(); + } } } + try (IntBlock chunked = builder.build()) { + delegateAddInput.add(positionOffset + offset, chunked); + } } - delegateAddInput.add(positionOffset + offset, builder.build()); } } diff --git a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/blockhash/AddPageTests.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/blockhash/AddPageTests.java index 810402d82c9d1..fb8b01e68c6cc 100644 --- a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/blockhash/AddPageTests.java +++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/blockhash/AddPageTests.java @@ -41,7 +41,6 @@ public void testSv() { } expected.add(added(3, 4)); assertThat(result.added, equalTo(expected)); - assertThat(result.closed, equalTo(true)); } public void testMvBlockEndsOnBatchBoundary() { @@ -69,7 +68,6 @@ public void testMvBlockEndsOnBatchBoundary() { * about. */ assertThat(result.added, equalTo(expected)); - assertThat(result.closed, equalTo(true)); } public void testMvPositionEndOnBatchBoundary() { @@ -92,7 +90,6 @@ public void testMvPositionEndOnBatchBoundary() { // Because the first position ended on a block boundary we uselessly emit an empty position there expected.add(new Added(0, List.of(List.of(), List.of(0, 2)))); assertThat(result.added, equalTo(expected)); - assertThat(result.closed, equalTo(true)); } public void testMv() { @@ -114,7 +111,6 @@ public void testMv() { } expected.add(new Added(1, List.of(List.of(2)))); assertThat(result.added, equalTo(expected)); - assertThat(result.closed, equalTo(true)); } /** @@ -158,8 +154,6 @@ Added added(int positionOffset, int... ords) { } private class TestAddInput implements GroupingAggregatorFunction.AddInput { - private boolean closed = false; - private final List added = new ArrayList<>(); @Override @@ -185,7 +179,7 @@ public void add(int positionOffset, IntVector groupIds) { @Override public void close() { - closed = true; + fail("shouldn't close"); } } diff --git a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/blockhash/BlockHashTests.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/blockhash/BlockHashTests.java index c4042ea15afc6..800683c696c0f 100644 --- a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/blockhash/BlockHashTests.java +++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/blockhash/BlockHashTests.java @@ -1168,7 +1168,9 @@ public void add(int positionOffset, IntVector groupIds) { } @Override - public void close() {} + public void close() { + fail("hashes should not close AddInput"); + } }); hash2.add(page, new GroupingAggregatorFunction.AddInput() { @Override @@ -1184,7 +1186,9 @@ public void add(int positionOffset, IntVector groupIds) { } @Override - public void close() {} + public void close() { + fail("hashes should not close AddInput"); + } }); assertThat(output1.size(), equalTo(output1.size())); for (int i = 0; i < output1.size(); i++) { @@ -1305,7 +1309,9 @@ public void add(int positionOffset, IntVector groupIds) { } @Override - public void close() {} + public void close() { + fail("hashes should not close AddInput"); + } }); if (blockHash instanceof LongLongBlockHash == false && blockHash instanceof BytesRefLongBlockHash == false diff --git a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/BasicBlockTests.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/BasicBlockTests.java index ad372da47d6b8..1fd670f836df3 100644 --- a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/BasicBlockTests.java +++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/BasicBlockTests.java @@ -829,10 +829,25 @@ public void testBooleanBlock() { BooleanVector.Builder vectorBuilder = blockFactory.newBooleanVectorBuilder( randomBoolean() ? randomIntBetween(1, positionCount) : positionCount ); - IntStream.range(0, positionCount).mapToObj(ii -> randomBoolean()).forEach(vectorBuilder::appendBoolean); + Boolean value = randomFrom(random(), null, true, false); + IntStream.range(0, positionCount).mapToObj(ii -> { + if (value == null) { + return randomBoolean(); + } + return value; + }).forEach(vectorBuilder::appendBoolean); BooleanVector vector = vectorBuilder.build(); assertSingleValueDenseBlock(vector.asBlock()); assertToMask(vector); + if (value != null) { + if (value) { + assertTrue(vector.allTrue()); + assertFalse(vector.allFalse()); + } else { + assertFalse(vector.allTrue()); + assertTrue(vector.allFalse()); + } + } releaseAndAssertBreaker(vector.asBlock()); } } @@ -867,6 +882,13 @@ public void testConstantBooleanBlock() { b -> assertThat(b, instanceOf(ConstantNullBlock.class)) ); assertEmptyLookup(blockFactory, block); + if (value) { + assertTrue(block.asVector().allTrue()); + assertFalse(block.asVector().allFalse()); + } else { + assertFalse(block.asVector().allTrue()); + assertTrue(block.asVector().allFalse()); + } releaseAndAssertBreaker(block); } } diff --git a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/BigArrayVectorTests.java b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/BigArrayVectorTests.java index 21a7615491e03..6225aa1a6f2a0 100644 --- a/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/BigArrayVectorTests.java +++ b/x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/data/BigArrayVectorTests.java @@ -37,7 +37,13 @@ public class BigArrayVectorTests extends SerializationTestCase { public void testBoolean() throws IOException { int positionCount = randomIntBetween(1, 16 * 1024); - Boolean[] values = IntStream.range(0, positionCount).mapToObj(i -> randomBoolean()).toArray(Boolean[]::new); + Boolean value = randomFrom(random(), null, true, false); + Boolean[] values = IntStream.range(0, positionCount).mapToObj(i -> { + if (value == null) { + return randomBoolean(); + } + return value; + }).toArray(Boolean[]::new); BitArray array = new BitArray(positionCount, bigArrays); IntStream.range(0, positionCount).filter(i -> values[i]).forEach(array::set); try (var vector = new BooleanBigArrayVector(array, positionCount, blockFactory)) { @@ -78,6 +84,15 @@ public void testBoolean() throws IOException { assertThat(mask.mask().getBoolean(p), equalTo(values[p])); } } + if (value != null) { + if (value) { + assertTrue(vector.allTrue()); + assertFalse(vector.allFalse()); + } else { + assertFalse(vector.allTrue()); + assertTrue(vector.allFalse()); + } + } } }