Skip to content

Commit cf600e5

Browse files
committed
wip
1 parent 62c0629 commit cf600e5

File tree

2 files changed

+110
-1
lines changed

2 files changed

+110
-1
lines changed

test/framework/src/main/java/org/elasticsearch/index/mapper/TestBlock.java

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public SingletonOrdsBuilder appendOrd(int value) {
150150

151151
@Override
152152
public BlockLoader.AggregateMetricDoubleBuilder aggregateMetricDoubleBuilder(int count) {
153-
return null;
153+
return new AggregateMetricDoubleBlockBuilder();
154154
}
155155
};
156156
}
@@ -243,4 +243,81 @@ public void close() {
243243
// TODO assert that we close the test block builders
244244
}
245245
}
246+
247+
/**
248+
* Test implementation of {@link org.elasticsearch.index.mapper.BlockLoader.AggregateMetricDoubleBuilder}.
249+
* The implementation here is fairly close to the production one.
250+
*/
251+
private static class AggregateMetricDoubleBlockBuilder implements BlockLoader.AggregateMetricDoubleBuilder {
252+
private final DoubleBuilder min = new DoubleBuilder();
253+
private final DoubleBuilder max = new DoubleBuilder();
254+
private final DoubleBuilder sum = new DoubleBuilder();
255+
private final IntBuilder count = new IntBuilder();
256+
257+
private static class DoubleBuilder extends TestBlock.Builder implements BlockLoader.DoubleBuilder {
258+
@Override
259+
public BlockLoader.DoubleBuilder appendDouble(double value) {
260+
add(value);
261+
return this;
262+
}
263+
}
264+
265+
private static class IntBuilder extends TestBlock.Builder implements BlockLoader.IntBuilder {
266+
@Override
267+
public BlockLoader.IntBuilder appendInt(int value) {
268+
add(value);
269+
return this;
270+
}
271+
}
272+
273+
@Override
274+
public BlockLoader.DoubleBuilder min() {
275+
return min;
276+
}
277+
278+
@Override
279+
public BlockLoader.DoubleBuilder max() {
280+
return max;
281+
}
282+
283+
@Override
284+
public BlockLoader.DoubleBuilder sum() {
285+
return sum;
286+
}
287+
288+
@Override
289+
public BlockLoader.IntBuilder count() {
290+
return count;
291+
}
292+
293+
@Override
294+
public BlockLoader.Block build() {
295+
var minBlock = max.build();
296+
var maxBlock = max.build();
297+
var sumBlock = max.build();
298+
var countBlock = max.build();
299+
300+
return new TestBlock(null);
301+
}
302+
303+
@Override
304+
public BlockLoader.Builder appendNull() {
305+
throw new UnsupportedOperationException();
306+
}
307+
308+
@Override
309+
public BlockLoader.Builder beginPositionEntry() {
310+
throw new UnsupportedOperationException();
311+
}
312+
313+
@Override
314+
public BlockLoader.Builder endPositionEntry() {
315+
throw new UnsupportedOperationException();
316+
}
317+
318+
@Override
319+
public void close() {
320+
321+
}
322+
}
246323
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
package org.elasticsearch.xpack.aggregatemetric.mapper;
9+
10+
import org.elasticsearch.index.mapper.BlockLoaderTestCase;
11+
import org.elasticsearch.plugins.Plugin;
12+
import org.elasticsearch.xpack.aggregatemetric.AggregateMetricMapperPlugin;
13+
14+
import java.util.Collection;
15+
import java.util.List;
16+
import java.util.Map;
17+
18+
public class AggregateMetricDoubleFieldBlockLoaderTests extends BlockLoaderTestCase {
19+
public AggregateMetricDoubleFieldBlockLoaderTests(Params params) {
20+
super("aggregate_metric_double", params);
21+
}
22+
23+
@Override
24+
protected Object expected(Map<String, Object> fieldMapping, Object value, TestContext testContext) {
25+
return null;
26+
}
27+
28+
@Override
29+
protected Collection<? extends Plugin> getPlugins() {
30+
return List.of(new AggregateMetricMapperPlugin());
31+
}
32+
}

0 commit comments

Comments
 (0)