Skip to content

Commit 5c4d965

Browse files
committed
fix tests
1 parent 2ccfd46 commit 5c4d965

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/AggregateMetricDoubleBlockBuilder.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,22 +249,24 @@ public void appendValue(double value) {
249249
public Block build() {
250250
Block[] blocks = new Block[4];
251251
Block block = null;
252-
ConstantIntVector countVector = null;
252+
IntBlock countVector = null;
253253
boolean success = false;
254254
try {
255255
finish();
256256
block = valuesBuilder.build();
257-
countVector = new ConstantIntVector(1, block.getPositionCount(), blockFactory);
257+
countVector = blockFactory.newConstantIntBlockWith(1, block.getPositionCount());
258258
blocks[Metric.MIN.getIndex()] = block;
259259
blocks[Metric.MAX.getIndex()] = block;
260+
block.incRef();
260261
blocks[Metric.SUM.getIndex()] = block;
261-
blocks[Metric.COUNT.getIndex()] = countVector.asBlock();
262+
block.incRef();
263+
blocks[Metric.COUNT.getIndex()] = countVector;
262264
CompositeBlock compositeBlock = new CompositeBlock(blocks);
263265
success = true;
264266
return compositeBlock;
265267
} finally {
266268
if (success == false) {
267-
Releasables.closeExpectNoException(block, countVector);
269+
Releasables.closeExpectNoException(blocks);
268270
}
269271
}
270272
}

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToAggregateMetricDoubleTests.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ protected Expression build(Source source, List<Expression> args) {
4141

4242
@ParametersFactory
4343
public static Iterable<Object[]> parameters() {
44-
final String evaluatorStringLeft = "ToAggregateMetricDoubleEvaluator[field=Cast";
45-
final String evaluatorStringRight = "ToDoubleEvaluator[v=Attribute[channel=0]]]";
44+
final String evaluatorStringLeft = "ToAggregateMetricDoubleFrom";
45+
final String evaluatorStringRight = "Evaluator[field=Attribute[channel=0]]";
4646
final List<TestCaseSupplier> suppliers = new ArrayList<>();
4747

4848
TestCaseSupplier.forUnaryInt(
@@ -77,14 +77,9 @@ public static Iterable<Object[]> parameters() {
7777
);
7878
TestCaseSupplier.forUnaryDouble(
7979
suppliers,
80-
"ToAggregateMetricDoubleEvaluator[field=Attribute[channel=0]]",
80+
evaluatorStringLeft + "Double" + evaluatorStringRight,
8181
DataType.AGGREGATE_METRIC_DOUBLE,
82-
d -> {
83-
if (d == -0.0) {
84-
return new AggregateMetricDoubleBlockBuilder.AggregateMetricDoubleLiteral(d, d, 0.0, 1);
85-
}
86-
return new AggregateMetricDoubleBlockBuilder.AggregateMetricDoubleLiteral(d, d, d, 1);
87-
},
82+
d -> new AggregateMetricDoubleBlockBuilder.AggregateMetricDoubleLiteral(d, d, d, 1),
8883
Double.NEGATIVE_INFINITY,
8984
Double.POSITIVE_INFINITY,
9085
emptyList()

0 commit comments

Comments
 (0)