use of org.apache.druid.query.aggregation.TestObjectColumnSelector in project druid by druid-io.
the class StringAnyBufferAggregatorTest method testBufferAggregateWithFoldCheck.
@Test
public void testBufferAggregateWithFoldCheck() {
final String[] strings = { "AAAA", "BBBB", "CCCC", "DDDD", "EEEE" };
Integer maxStringBytes = 1024;
TestObjectColumnSelector<String> objectColumnSelector = new TestObjectColumnSelector<>(strings);
StringAnyAggregatorFactory factory = new StringAnyAggregatorFactory("billy", "billy", maxStringBytes);
StringAnyBufferAggregator agg = new StringAnyBufferAggregator(objectColumnSelector, maxStringBytes);
ByteBuffer buf = ByteBuffer.allocate(factory.getMaxIntermediateSize());
int position = 0;
agg.init(buf, position);
// noinspection ForLoopReplaceableByForEach
for (int i = 0; i < strings.length; i++) {
aggregateBuffer(objectColumnSelector, agg, buf, position);
}
String result = ((String) agg.get(buf, position));
Assert.assertEquals(strings[0], result);
}
Aggregations