Search in sources :

Example 61 with CountAggregatorFactory

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

the class LimitedBufferHashGrouperTest method makeGrouper.

private static LimitedBufferHashGrouper<Integer> makeGrouper(TestColumnSelectorFactory columnSelectorFactory, int bufferSize) {
    LimitedBufferHashGrouper<Integer> grouper = new LimitedBufferHashGrouper<>(Suppliers.ofInstance(ByteBuffer.allocate(bufferSize)), GrouperTestUtil.intKeySerde(), AggregatorAdapters.factorizeBuffered(columnSelectorFactory, ImmutableList.of(new LongSumAggregatorFactory("valueSum", "value"), new CountAggregatorFactory("count"))), Integer.MAX_VALUE, 0.5f, 2, LIMIT, false);
    grouper.init();
    return grouper;
}
Also used : CountAggregatorFactory(org.apache.druid.query.aggregation.CountAggregatorFactory) LongSumAggregatorFactory(org.apache.druid.query.aggregation.LongSumAggregatorFactory)

Example 62 with CountAggregatorFactory

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

the class CachingClusteredClientTest method testOutOfOrderSequenceMerging.

@Test
public void testOutOfOrderSequenceMerging() {
    List<Sequence<Result<TopNResultValue>>> sequences = ImmutableList.of(Sequences.simple(makeTopNResultsWithoutRename(DateTimes.of("2011-01-07"), "a", 50, 4991, "b", 50, 4990, "c", 50, 4989, DateTimes.of("2011-01-08"), "a", 50, 4988, "b", 50, 4987, "c", 50, 4986, DateTimes.of("2011-01-09"), "a", 50, 4985, "b", 50, 4984, "c", 50, 4983)), Sequences.simple(makeTopNResultsWithoutRename(DateTimes.of("2011-01-06T01"), "a", 50, 4991, "b", 50, 4990, "c", 50, 4989, DateTimes.of("2011-01-07T01"), "a", 50, 4991, "b", 50, 4990, "c", 50, 4989, DateTimes.of("2011-01-08T01"), "a", 50, 4988, "b", 50, 4987, "c", 50, 4986, DateTimes.of("2011-01-09T01"), "a", 50, 4985, "b", 50, 4984, "c", 50, 4983)));
    TestHelper.assertExpectedResults(makeTopNResultsWithoutRename(DateTimes.of("2011-01-06T01"), "a", 50, 4991, "b", 50, 4990, "c", 50, 4989, DateTimes.of("2011-01-07"), "a", 50, 4991, "b", 50, 4990, "c", 50, 4989, DateTimes.of("2011-01-07T01"), "a", 50, 4991, "b", 50, 4990, "c", 50, 4989, DateTimes.of("2011-01-08"), "a", 50, 4988, "b", 50, 4987, "c", 50, 4986, DateTimes.of("2011-01-08T01"), "a", 50, 4988, "b", 50, 4987, "c", 50, 4986, DateTimes.of("2011-01-09"), "a", 50, 4985, "b", 50, 4984, "c", 50, 4983, DateTimes.of("2011-01-09T01"), "a", 50, 4985, "b", 50, 4984, "c", 50, 4983), mergeSequences(new TopNQueryBuilder().dataSource("test").intervals("2011-01-06/2011-01-10").dimension("a").metric("b").threshold(3).aggregators(new CountAggregatorFactory("b")).randomQueryId().build(), sequences));
}
Also used : TopNResultValue(org.apache.druid.query.topn.TopNResultValue) TopNQueryBuilder(org.apache.druid.query.topn.TopNQueryBuilder) CountAggregatorFactory(org.apache.druid.query.aggregation.CountAggregatorFactory) Sequence(org.apache.druid.java.util.common.guava.Sequence) Test(org.junit.Test)

Example 63 with CountAggregatorFactory

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

the class SimpleTestIndex method makeRealtimeIndex.

private static IncrementalIndex makeRealtimeIndex() {
    try {
        List<InputRow> inputRows = Lists.newArrayListWithExpectedSize(NUM_ROWS);
        for (int i = 1; i <= NUM_ROWS; i++) {
            double doubleVal = i + 0.7d;
            String stringVal = String.valueOf(doubleVal);
            inputRows.add(new MapBasedInputRow(DateTime.now(DateTimeZone.UTC), DIMENSIONS, ImmutableMap.of(DOUBLE_COL, doubleVal, SINGLE_VALUE_DOUBLE_AS_STRING_DIM, stringVal, MULTI_VALUE_DOUBLE_AS_STRING_DIM, Lists.newArrayList(stringVal, null, stringVal))));
        }
        return AggregationTestHelper.createIncrementalIndex(inputRows.iterator(), new NoopInputRowParser(null), new AggregatorFactory[] { new CountAggregatorFactory("count"), new DoubleSumAggregatorFactory(DOUBLE_COL, DOUBLE_COL) }, 0, Granularities.NONE, false, 100, false);
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}
Also used : CountAggregatorFactory(org.apache.druid.query.aggregation.CountAggregatorFactory) DoubleSumAggregatorFactory(org.apache.druid.query.aggregation.DoubleSumAggregatorFactory) MapBasedInputRow(org.apache.druid.data.input.MapBasedInputRow) InputRow(org.apache.druid.data.input.InputRow) MapBasedInputRow(org.apache.druid.data.input.MapBasedInputRow) NoopInputRowParser(org.apache.druid.data.input.impl.NoopInputRowParser)

Example 64 with CountAggregatorFactory

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

the class ConstantPostAggregatorTest method testResultArraySignature.

@Test
public void testResultArraySignature() {
    final TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource("dummy").intervals("2000/3000").granularity(Granularities.HOUR).aggregators(new CountAggregatorFactory("count")).postAggregators(new ConstantPostAggregator("a", 3L), new ConstantPostAggregator("b", 1.0f), new ConstantPostAggregator("c", 5.0)).build();
    Assert.assertEquals(RowSignature.builder().addTimeColumn().add("count", ColumnType.LONG).add("a", ColumnType.LONG).add("b", ColumnType.DOUBLE).add("c", ColumnType.DOUBLE).build(), new TimeseriesQueryQueryToolChest().resultArraySignature(query));
}
Also used : TimeseriesQuery(org.apache.druid.query.timeseries.TimeseriesQuery) CountAggregatorFactory(org.apache.druid.query.aggregation.CountAggregatorFactory) TimeseriesQueryQueryToolChest(org.apache.druid.query.timeseries.TimeseriesQueryQueryToolChest) Test(org.junit.Test)

Example 65 with CountAggregatorFactory

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

the class LongGreatestPostAggregatorTest method testResultArraySignature.

@Test
public void testResultArraySignature() {
    final TimeseriesQuery query = Druids.newTimeseriesQueryBuilder().dataSource("dummy").intervals("2000/3000").granularity(Granularities.HOUR).aggregators(new CountAggregatorFactory("count")).postAggregators(new LongGreatestPostAggregator("a", ImmutableList.of(new ConstantPostAggregator("_a", 3L), new ConstantPostAggregator("_b", 1.0f), new ConstantPostAggregator("_c", 5.0)))).build();
    Assert.assertEquals(RowSignature.builder().addTimeColumn().add("count", ColumnType.LONG).add("a", ColumnType.LONG).build(), new TimeseriesQueryQueryToolChest().resultArraySignature(query));
}
Also used : TimeseriesQuery(org.apache.druid.query.timeseries.TimeseriesQuery) CountAggregatorFactory(org.apache.druid.query.aggregation.CountAggregatorFactory) TimeseriesQueryQueryToolChest(org.apache.druid.query.timeseries.TimeseriesQueryQueryToolChest) Test(org.junit.Test)

Aggregations

CountAggregatorFactory (org.apache.druid.query.aggregation.CountAggregatorFactory)300 Test (org.junit.Test)249 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)103 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)81 LongSumAggregatorFactory (org.apache.druid.query.aggregation.LongSumAggregatorFactory)62 TimeseriesQuery (org.apache.druid.query.timeseries.TimeseriesQuery)50 TableDataSource (org.apache.druid.query.TableDataSource)44 QueryDataSource (org.apache.druid.query.QueryDataSource)41 TimeseriesQueryQueryToolChest (org.apache.druid.query.timeseries.TimeseriesQueryQueryToolChest)40 GroupByQuery (org.apache.druid.query.groupby.GroupByQuery)37 Result (org.apache.druid.query.Result)36 DoubleSumAggregatorFactory (org.apache.druid.query.aggregation.DoubleSumAggregatorFactory)35 FilteredAggregatorFactory (org.apache.druid.query.aggregation.FilteredAggregatorFactory)30 FieldAccessPostAggregator (org.apache.druid.query.aggregation.post.FieldAccessPostAggregator)30 AggregatorFactory (org.apache.druid.query.aggregation.AggregatorFactory)28 IncrementalIndexSegment (org.apache.druid.segment.IncrementalIndexSegment)27 DimensionsSpec (org.apache.druid.data.input.impl.DimensionsSpec)26 GroupByQueryRunnerTest (org.apache.druid.query.groupby.GroupByQueryRunnerTest)26 IncrementalIndex (org.apache.druid.segment.incremental.IncrementalIndex)26 Parameters (junitparams.Parameters)24