use of org.apache.druid.query.groupby.epinephelinae.Grouper.Entry in project druid by druid-io.
the class ConcurrentGrouperTest method testAggregate.
@Test()
public void testAggregate() throws InterruptedException, ExecutionException, IOException {
final ConcurrentGrouper<Long> grouper = new ConcurrentGrouper<>(bufferSupplier, TEST_RESOURCE_HOLDER, KEY_SERDE_FACTORY, KEY_SERDE_FACTORY, NULL_FACTORY, new AggregatorFactory[] { new CountAggregatorFactory("cnt") }, 1024, 0.7f, 1, new LimitedTemporaryStorage(temporaryFolder.newFolder(), 1024 * 1024), new DefaultObjectMapper(), 8, null, false, MoreExecutors.listeningDecorator(SERVICE), 0, false, 0, 4, 8);
grouper.init();
final int numRows = 1000;
Future<?>[] futures = new Future[8];
for (int i = 0; i < 8; i++) {
futures[i] = SERVICE.submit(new Runnable() {
@Override
public void run() {
for (long i = 0; i < numRows; i++) {
grouper.aggregate(i);
}
}
});
}
for (Future eachFuture : futures) {
eachFuture.get();
}
final CloseableIterator<Entry<Long>> iterator = grouper.iterator(true);
final List<Entry<Long>> actual = Lists.newArrayList(iterator);
iterator.close();
Assert.assertTrue(TEST_RESOURCE_HOLDER.taken);
final List<Entry<Long>> expected = new ArrayList<>();
for (long i = 0; i < numRows; i++) {
expected.add(new Entry<>(i, new Object[] { 8L }));
}
Assert.assertEquals(expected, actual);
grouper.close();
}
Aggregations