Search in sources :

Example 1 with SuppressedAggregatorFactory

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

the class PerSegmentQueryOptimizeTest method testFilteredAggregatorOptimize.

@Test
public void testFilteredAggregatorOptimize() {
    LongSumAggregatorFactory longSumAggregatorFactory = new LongSumAggregatorFactory("test", "test");
    FilteredAggregatorFactory aggregatorFactory = new FilteredAggregatorFactory(longSumAggregatorFactory, new IntervalDimFilter(ColumnHolder.TIME_COLUMN_NAME, Collections.singletonList(Intervals.utc(1000, 2000)), null));
    Interval exclude = Intervals.utc(2000, 3000);
    Interval include = Intervals.utc(1500, 1600);
    Interval partial = Intervals.utc(1500, 2500);
    AggregatorFactory excludedAgg = aggregatorFactory.optimizeForSegment(getOptimizationContext(exclude));
    AggregatorFactory expectedSuppressedAgg = new SuppressedAggregatorFactory(longSumAggregatorFactory);
    Assert.assertEquals(expectedSuppressedAgg, excludedAgg);
    AggregatorFactory includedAgg = aggregatorFactory.optimizeForSegment(getOptimizationContext(include));
    Assert.assertEquals(longSumAggregatorFactory, includedAgg);
    AggregatorFactory partialAgg = aggregatorFactory.optimizeForSegment(getOptimizationContext(partial));
    AggregatorFactory expectedPartialFilteredAgg = new FilteredAggregatorFactory(longSumAggregatorFactory, new IntervalDimFilter(ColumnHolder.TIME_COLUMN_NAME, Collections.singletonList(Intervals.utc(1500, 2000)), null));
    Assert.assertEquals(expectedPartialFilteredAgg, partialAgg);
}
Also used : FilteredAggregatorFactory(org.apache.druid.query.aggregation.FilteredAggregatorFactory) LongSumAggregatorFactory(org.apache.druid.query.aggregation.LongSumAggregatorFactory) SuppressedAggregatorFactory(org.apache.druid.query.aggregation.SuppressedAggregatorFactory) AggregatorFactory(org.apache.druid.query.aggregation.AggregatorFactory) FilteredAggregatorFactory(org.apache.druid.query.aggregation.FilteredAggregatorFactory) LongSumAggregatorFactory(org.apache.druid.query.aggregation.LongSumAggregatorFactory) IntervalDimFilter(org.apache.druid.query.filter.IntervalDimFilter) SuppressedAggregatorFactory(org.apache.druid.query.aggregation.SuppressedAggregatorFactory) Interval(org.joda.time.Interval) Test(org.junit.Test)

Aggregations

AggregatorFactory (org.apache.druid.query.aggregation.AggregatorFactory)1 FilteredAggregatorFactory (org.apache.druid.query.aggregation.FilteredAggregatorFactory)1 LongSumAggregatorFactory (org.apache.druid.query.aggregation.LongSumAggregatorFactory)1 SuppressedAggregatorFactory (org.apache.druid.query.aggregation.SuppressedAggregatorFactory)1 IntervalDimFilter (org.apache.druid.query.filter.IntervalDimFilter)1 Interval (org.joda.time.Interval)1 Test (org.junit.Test)1