use of io.druid.java.util.common.Pair in project druid by druid-io.
the class AggregatorUtilTest method testNullPostAggregatorNames.
@Test
public void testNullPostAggregatorNames() {
AggregatorFactory agg1 = new DoubleSumAggregatorFactory("agg1", "value");
AggregatorFactory agg2 = new DoubleSumAggregatorFactory("agg2", "count");
PostAggregator postAgg1 = new ArithmeticPostAggregator(null, "*", Lists.<PostAggregator>newArrayList(new FieldAccessPostAggregator(null, "agg1"), new FieldAccessPostAggregator(null, "agg2")));
PostAggregator postAgg2 = new ArithmeticPostAggregator("postAgg", "/", Lists.<PostAggregator>newArrayList(new FieldAccessPostAggregator(null, "agg1"), new FieldAccessPostAggregator(null, "agg2")));
Assert.assertEquals(new Pair(Lists.newArrayList(agg1, agg2), Lists.newArrayList(postAgg2)), AggregatorUtil.condensedAggregators(Lists.newArrayList(agg1, agg2), Lists.newArrayList(postAgg1, postAgg2), "postAgg"));
}
use of io.druid.java.util.common.Pair in project druid by druid-io.
the class DoubleLastAggregationTest method testDoubleLastBufferAggregator.
@Test
public void testDoubleLastBufferAggregator() {
DoubleLastBufferAggregator agg = (DoubleLastBufferAggregator) doubleLastAggFactory.factorizeBuffered(colSelectorFactory);
ByteBuffer buffer = ByteBuffer.wrap(new byte[doubleLastAggFactory.getMaxIntermediateSize()]);
agg.init(buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
Pair<Long, Double> result = (Pair<Long, Double>) agg.get(buffer, 0);
Assert.assertEquals(times[0], result.lhs.longValue());
Assert.assertEquals(floatValues[0], result.rhs, 0.0001);
Assert.assertEquals((long) floatValues[0], agg.getLong(buffer, 0));
Assert.assertEquals(floatValues[0], agg.getFloat(buffer, 0), 0.0001);
}
use of io.druid.java.util.common.Pair in project druid by druid-io.
the class LongFirstAggregationTest method testLongFirstBufferAggregator.
@Test
public void testLongFirstBufferAggregator() {
LongFirstBufferAggregator agg = (LongFirstBufferAggregator) longFirstAggFactory.factorizeBuffered(colSelectorFactory);
ByteBuffer buffer = ByteBuffer.wrap(new byte[longFirstAggFactory.getMaxIntermediateSize()]);
agg.init(buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
Pair<Long, Long> result = (Pair<Long, Long>) agg.get(buffer, 0);
Assert.assertEquals(times[3], result.lhs.longValue());
Assert.assertEquals(longValues[3], result.rhs.longValue());
Assert.assertEquals(longValues[3], agg.getLong(buffer, 0));
Assert.assertEquals(longValues[3], agg.getFloat(buffer, 0), 0.0001);
}
use of io.druid.java.util.common.Pair in project druid by druid-io.
the class LongFirstAggregationTest method testLongFirstCombiningBufferAggregator.
@Test
public void testLongFirstCombiningBufferAggregator() {
LongFirstBufferAggregator agg = (LongFirstBufferAggregator) combiningAggFactory.factorizeBuffered(colSelectorFactory);
ByteBuffer buffer = ByteBuffer.wrap(new byte[longFirstAggFactory.getMaxIntermediateSize()]);
agg.init(buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
aggregate(agg, buffer, 0);
Pair<Long, Long> result = (Pair<Long, Long>) agg.get(buffer, 0);
Pair<Long, Long> expected = (Pair<Long, Long>) pairs[0];
Assert.assertEquals(expected.lhs, result.lhs);
Assert.assertEquals(expected.rhs, result.rhs);
Assert.assertEquals(expected.rhs.longValue(), agg.getLong(buffer, 0));
Assert.assertEquals(expected.rhs, agg.getFloat(buffer, 0), 0.0001);
}
use of io.druid.java.util.common.Pair in project druid by druid-io.
the class ServerManagerTest method testReferenceCounting.
@Test
public void testReferenceCounting() throws Exception {
loadQueryable("test", "3", new Interval("2011-04-04/2011-04-05"));
Future future = assertQueryable(Granularities.DAY, "test", new Interval("2011-04-04/2011-04-06"), ImmutableList.<Pair<String, Interval>>of(new Pair<String, Interval>("3", new Interval("2011-04-04/2011-04-05"))));
queryNotifyLatch.await(1000, TimeUnit.MILLISECONDS);
Assert.assertEquals(1, factory.getSegmentReferences().size());
for (ReferenceCountingSegment referenceCountingSegment : factory.getSegmentReferences()) {
Assert.assertEquals(1, referenceCountingSegment.getNumReferences());
}
queryWaitYieldLatch.countDown();
Assert.assertTrue(factory.getAdapters().size() == 1);
for (SegmentForTesting segmentForTesting : factory.getAdapters()) {
Assert.assertFalse(segmentForTesting.isClosed());
}
queryWaitLatch.countDown();
future.get();
dropQueryable("test", "3", new Interval("2011-04-04/2011-04-05"));
for (SegmentForTesting segmentForTesting : factory.getAdapters()) {
Assert.assertTrue(segmentForTesting.isClosed());
}
}
Aggregations