Search in sources :

Example 1 with AggregateCombiner

use of org.apache.druid.query.aggregation.AggregateCombiner in project druid by druid-io.

the class StringLastAggregationTest method testStringLastAggregateCombiner.

@Test
public void testStringLastAggregateCombiner() {
    TestObjectColumnSelector columnSelector = new TestObjectColumnSelector<>(pairs);
    AggregateCombiner stringFirstAggregateCombiner = combiningAggFactory.makeAggregateCombiner();
    stringFirstAggregateCombiner.reset(columnSelector);
    Assert.assertEquals(pairs[0], stringFirstAggregateCombiner.getObject());
    columnSelector.increment();
    stringFirstAggregateCombiner.fold(columnSelector);
    Assert.assertEquals(pairs[1], stringFirstAggregateCombiner.getObject());
    stringFirstAggregateCombiner.reset(columnSelector);
    Assert.assertEquals(pairs[1], stringFirstAggregateCombiner.getObject());
}
Also used : AggregateCombiner(org.apache.druid.query.aggregation.AggregateCombiner) TestObjectColumnSelector(org.apache.druid.query.aggregation.TestObjectColumnSelector) Test(org.junit.Test)

Example 2 with AggregateCombiner

use of org.apache.druid.query.aggregation.AggregateCombiner in project druid by druid-io.

the class StringFirstAggregationTest method testStringFirstAggregateCombiner.

@Test
public void testStringFirstAggregateCombiner() {
    TestObjectColumnSelector columnSelector = new TestObjectColumnSelector<>(pairs);
    AggregateCombiner stringFirstAggregateCombiner = combiningAggFactory.makeAggregateCombiner();
    stringFirstAggregateCombiner.reset(columnSelector);
    Assert.assertEquals(pairs[0], stringFirstAggregateCombiner.getObject());
    columnSelector.increment();
    stringFirstAggregateCombiner.fold(columnSelector);
    Assert.assertEquals(pairs[0], stringFirstAggregateCombiner.getObject());
    stringFirstAggregateCombiner.reset(columnSelector);
    Assert.assertEquals(pairs[1], stringFirstAggregateCombiner.getObject());
}
Also used : AggregateCombiner(org.apache.druid.query.aggregation.AggregateCombiner) TestObjectColumnSelector(org.apache.druid.query.aggregation.TestObjectColumnSelector) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Aggregations

AggregateCombiner (org.apache.druid.query.aggregation.AggregateCombiner)2 TestObjectColumnSelector (org.apache.druid.query.aggregation.TestObjectColumnSelector)2 Test (org.junit.Test)2 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)1