Search in sources :

Example 1 with GroupByQueryRunnerFactory

use of org.apache.druid.query.groupby.GroupByQueryRunnerFactory in project druid by druid-io.

the class AggregationTestHelper method createGroupByQueryAggregationTestHelper.

public static AggregationTestHelper createGroupByQueryAggregationTestHelper(List<? extends Module> jsonModulesToRegister, GroupByQueryConfig config, TemporaryFolder tempFolder) {
    final ObjectMapper mapper = TestHelper.makeJsonMapper();
    final Pair<GroupByQueryRunnerFactory, Closer> factoryAndCloser = GroupByQueryRunnerTest.makeQueryRunnerFactory(mapper, config);
    final GroupByQueryRunnerFactory factory = factoryAndCloser.lhs;
    final Closer closer = factoryAndCloser.rhs;
    IndexIO indexIO = new IndexIO(mapper, new ColumnConfig() {

        @Override
        public int columnCacheSizeBytes() {
            return 0;
        }
    });
    return new AggregationTestHelper(mapper, new IndexMergerV9(mapper, indexIO, OffHeapMemorySegmentWriteOutMediumFactory.instance()), indexIO, factory.getToolchest(), factory, tempFolder, jsonModulesToRegister, closer, Collections.emptyMap());
}
Also used : Closer(org.apache.druid.java.util.common.io.Closer) GroupByQueryRunnerFactory(org.apache.druid.query.groupby.GroupByQueryRunnerFactory) IndexIO(org.apache.druid.segment.IndexIO) ColumnConfig(org.apache.druid.segment.column.ColumnConfig) IndexMergerV9(org.apache.druid.segment.IndexMergerV9) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with GroupByQueryRunnerFactory

use of org.apache.druid.query.groupby.GroupByQueryRunnerFactory in project druid by druid-io.

the class CachingClusteredClientTestUtils method createWarehouse.

/**
 * Returns a new {@link QueryToolChestWarehouse} for unit tests and a resourceCloser which should be closed at the end
 * of the test.
 */
public static Pair<QueryToolChestWarehouse, Closer> createWarehouse(ObjectMapper objectMapper) {
    final Pair<GroupByQueryRunnerFactory, Closer> factoryCloserPair = GroupByQueryRunnerTest.makeQueryRunnerFactory(new GroupByQueryConfig());
    final GroupByQueryRunnerFactory factory = factoryCloserPair.lhs;
    final Closer resourceCloser = factoryCloserPair.rhs;
    return Pair.of(new MapQueryToolChestWarehouse(ImmutableMap.<Class<? extends Query>, QueryToolChest>builder().put(TimeseriesQuery.class, new TimeseriesQueryQueryToolChest()).put(TopNQuery.class, new TopNQueryQueryToolChest(new TopNQueryConfig())).put(SearchQuery.class, new SearchQueryQueryToolChest(new SearchQueryConfig())).put(GroupByQuery.class, factory.getToolchest()).put(TimeBoundaryQuery.class, new TimeBoundaryQueryQueryToolChest()).build()), resourceCloser);
}
Also used : Closer(org.apache.druid.java.util.common.io.Closer) SearchQuery(org.apache.druid.query.search.SearchQuery) GroupByQueryRunnerFactory(org.apache.druid.query.groupby.GroupByQueryRunnerFactory) TimeseriesQuery(org.apache.druid.query.timeseries.TimeseriesQuery) TopNQuery(org.apache.druid.query.topn.TopNQuery) Query(org.apache.druid.query.Query) TimeBoundaryQuery(org.apache.druid.query.timeboundary.TimeBoundaryQuery) SearchQuery(org.apache.druid.query.search.SearchQuery) GroupByQuery(org.apache.druid.query.groupby.GroupByQuery) TimeseriesQuery(org.apache.druid.query.timeseries.TimeseriesQuery) SearchQueryConfig(org.apache.druid.query.search.SearchQueryConfig) GroupByQueryConfig(org.apache.druid.query.groupby.GroupByQueryConfig) TopNQueryQueryToolChest(org.apache.druid.query.topn.TopNQueryQueryToolChest) TimeseriesQueryQueryToolChest(org.apache.druid.query.timeseries.TimeseriesQueryQueryToolChest) QueryToolChest(org.apache.druid.query.QueryToolChest) TimeBoundaryQueryQueryToolChest(org.apache.druid.query.timeboundary.TimeBoundaryQueryQueryToolChest) SearchQueryQueryToolChest(org.apache.druid.query.search.SearchQueryQueryToolChest) TimeseriesQueryQueryToolChest(org.apache.druid.query.timeseries.TimeseriesQueryQueryToolChest) TimeBoundaryQuery(org.apache.druid.query.timeboundary.TimeBoundaryQuery) SearchQueryQueryToolChest(org.apache.druid.query.search.SearchQueryQueryToolChest) TopNQueryConfig(org.apache.druid.query.topn.TopNQueryConfig) MapQueryToolChestWarehouse(org.apache.druid.query.MapQueryToolChestWarehouse) TimeBoundaryQueryQueryToolChest(org.apache.druid.query.timeboundary.TimeBoundaryQueryQueryToolChest) TopNQueryQueryToolChest(org.apache.druid.query.topn.TopNQueryQueryToolChest)

Example 3 with GroupByQueryRunnerFactory

use of org.apache.druid.query.groupby.GroupByQueryRunnerFactory in project druid by druid-io.

the class QueryStackTests method createQueryRunnerFactoryConglomerate.

public static QueryRunnerFactoryConglomerate createQueryRunnerFactoryConglomerate(final Closer closer, final DruidProcessingConfig processingConfig, final Supplier<Integer> minTopNThresholdSupplier) {
    final CloseableStupidPool<ByteBuffer> stupidPool = new CloseableStupidPool<>("TopNQueryRunnerFactory-bufferPool", () -> ByteBuffer.allocate(COMPUTE_BUFFER_SIZE));
    closer.register(stupidPool);
    final Pair<GroupByQueryRunnerFactory, Closer> factoryCloserPair = GroupByQueryRunnerTest.makeQueryRunnerFactory(GroupByQueryRunnerTest.DEFAULT_MAPPER, new GroupByQueryConfig() {

        @Override
        public String getDefaultStrategy() {
            return GroupByStrategySelector.STRATEGY_V2;
        }
    }, processingConfig);
    final GroupByQueryRunnerFactory groupByQueryRunnerFactory = factoryCloserPair.lhs;
    closer.register(factoryCloserPair.rhs);
    final QueryRunnerFactoryConglomerate conglomerate = new DefaultQueryRunnerFactoryConglomerate(ImmutableMap.<Class<? extends Query>, QueryRunnerFactory>builder().put(SegmentMetadataQuery.class, new SegmentMetadataQueryRunnerFactory(new SegmentMetadataQueryQueryToolChest(new SegmentMetadataQueryConfig("P1W")), QueryRunnerTestHelper.NOOP_QUERYWATCHER)).put(ScanQuery.class, new ScanQueryRunnerFactory(new ScanQueryQueryToolChest(new ScanQueryConfig(), new DefaultGenericQueryMetricsFactory()), new ScanQueryEngine(), new ScanQueryConfig())).put(TimeseriesQuery.class, new TimeseriesQueryRunnerFactory(new TimeseriesQueryQueryToolChest(), new TimeseriesQueryEngine(), QueryRunnerTestHelper.NOOP_QUERYWATCHER)).put(TopNQuery.class, new TopNQueryRunnerFactory(stupidPool, new TopNQueryQueryToolChest(new TopNQueryConfig() {

        @Override
        public int getMinTopNThreshold() {
            return minTopNThresholdSupplier.get();
        }
    }), QueryRunnerTestHelper.NOOP_QUERYWATCHER)).put(GroupByQuery.class, groupByQueryRunnerFactory).build());
    return conglomerate;
}
Also used : ScanQueryConfig(org.apache.druid.query.scan.ScanQueryConfig) ScanQuery(org.apache.druid.query.scan.ScanQuery) TimeseriesQueryQueryToolChest(org.apache.druid.query.timeseries.TimeseriesQueryQueryToolChest) QueryRunnerFactoryConglomerate(org.apache.druid.query.QueryRunnerFactoryConglomerate) DefaultQueryRunnerFactoryConglomerate(org.apache.druid.query.DefaultQueryRunnerFactoryConglomerate) TimeseriesQueryEngine(org.apache.druid.query.timeseries.TimeseriesQueryEngine) SegmentMetadataQueryRunnerFactory(org.apache.druid.query.metadata.SegmentMetadataQueryRunnerFactory) TopNQuery(org.apache.druid.query.topn.TopNQuery) TopNQueryRunnerFactory(org.apache.druid.query.topn.TopNQueryRunnerFactory) TopNQueryQueryToolChest(org.apache.druid.query.topn.TopNQueryQueryToolChest) DefaultGenericQueryMetricsFactory(org.apache.druid.query.DefaultGenericQueryMetricsFactory) SegmentMetadataQueryConfig(org.apache.druid.query.metadata.SegmentMetadataQueryConfig) ScanQueryRunnerFactory(org.apache.druid.query.scan.ScanQueryRunnerFactory) Closer(org.apache.druid.java.util.common.io.Closer) GroupByQueryRunnerFactory(org.apache.druid.query.groupby.GroupByQueryRunnerFactory) GroupByQueryConfig(org.apache.druid.query.groupby.GroupByQueryConfig) DefaultQueryRunnerFactoryConglomerate(org.apache.druid.query.DefaultQueryRunnerFactoryConglomerate) ScanQueryEngine(org.apache.druid.query.scan.ScanQueryEngine) CloseableStupidPool(org.apache.druid.collections.CloseableStupidPool) ByteBuffer(java.nio.ByteBuffer) TimeseriesQueryRunnerFactory(org.apache.druid.query.timeseries.TimeseriesQueryRunnerFactory) ScanQueryQueryToolChest(org.apache.druid.query.scan.ScanQueryQueryToolChest) TopNQueryConfig(org.apache.druid.query.topn.TopNQueryConfig) SegmentMetadataQueryQueryToolChest(org.apache.druid.query.metadata.SegmentMetadataQueryQueryToolChest)

Example 4 with GroupByQueryRunnerFactory

use of org.apache.druid.query.groupby.GroupByQueryRunnerFactory in project druid by druid-io.

the class MapVirtualColumnGroupByTest method setup.

@Before
public void setup() throws IOException {
    final IncrementalIndex incrementalIndex = MapVirtualColumnTestBase.generateIndex();
    final GroupByStrategySelector strategySelector = new GroupByStrategySelector(GroupByQueryConfig::new, null, new GroupByStrategyV2(new DruidProcessingConfig() {

        @Override
        public String getFormatString() {
            return null;
        }

        @Override
        public int intermediateComputeSizeBytes() {
            return 10 * 1024 * 1024;
        }

        @Override
        public int getNumMergeBuffers() {
            return 1;
        }

        @Override
        public int getNumThreads() {
            return 1;
        }
    }, GroupByQueryConfig::new, new StupidPool<>("map-virtual-column-groupby-test", () -> ByteBuffer.allocate(1024)), new DefaultBlockingPool<>(() -> ByteBuffer.allocate(1024), 1), new DefaultObjectMapper(), QueryRunnerTestHelper.NOOP_QUERYWATCHER));
    final GroupByQueryRunnerFactory factory = new GroupByQueryRunnerFactory(strategySelector, new GroupByQueryQueryToolChest(strategySelector));
    runner = QueryRunnerTestHelper.makeQueryRunner(factory, SegmentId.dummy("index"), new IncrementalIndexSegment(incrementalIndex, SegmentId.dummy("index")), "incremental");
}
Also used : GroupByStrategySelector(org.apache.druid.query.groupby.strategy.GroupByStrategySelector) GroupByQueryRunnerFactory(org.apache.druid.query.groupby.GroupByQueryRunnerFactory) IncrementalIndex(org.apache.druid.segment.incremental.IncrementalIndex) GroupByQueryConfig(org.apache.druid.query.groupby.GroupByQueryConfig) GroupByStrategyV2(org.apache.druid.query.groupby.strategy.GroupByStrategyV2) DefaultBlockingPool(org.apache.druid.collections.DefaultBlockingPool) StupidPool(org.apache.druid.collections.StupidPool) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper) DruidProcessingConfig(org.apache.druid.query.DruidProcessingConfig) GroupByQueryQueryToolChest(org.apache.druid.query.groupby.GroupByQueryQueryToolChest) Before(org.junit.Before)

Example 5 with GroupByQueryRunnerFactory

use of org.apache.druid.query.groupby.GroupByQueryRunnerFactory in project druid by druid-io.

the class FixedBucketsHistogramGroupByQueryTest method constructorFeeder.

@Parameterized.Parameters(name = "{0}")
public static Iterable<Object[]> constructorFeeder() {
    final GroupByQueryConfig v1Config = new GroupByQueryConfig() {

        @Override
        public String getDefaultStrategy() {
            return GroupByStrategySelector.STRATEGY_V1;
        }

        @Override
        public String toString() {
            return "v1";
        }
    };
    final GroupByQueryConfig v1SingleThreadedConfig = new GroupByQueryConfig() {

        @Override
        public boolean isSingleThreaded() {
            return true;
        }

        @Override
        public String getDefaultStrategy() {
            return GroupByStrategySelector.STRATEGY_V1;
        }

        @Override
        public String toString() {
            return "v1SingleThreaded";
        }
    };
    final GroupByQueryConfig v2Config = new GroupByQueryConfig() {

        @Override
        public String getDefaultStrategy() {
            return GroupByStrategySelector.STRATEGY_V2;
        }

        @Override
        public String toString() {
            return "v2";
        }
    };
    v1Config.setMaxIntermediateRows(10000);
    v1SingleThreadedConfig.setMaxIntermediateRows(10000);
    final List<Object[]> constructors = new ArrayList<>();
    final List<GroupByQueryConfig> configs = ImmutableList.of(v1Config, v1SingleThreadedConfig, v2Config);
    for (GroupByQueryConfig config : configs) {
        final Pair<GroupByQueryRunnerFactory, Closer> factoryAndCloser = GroupByQueryRunnerTest.makeQueryRunnerFactory(config);
        final GroupByQueryRunnerFactory factory = factoryAndCloser.lhs;
        RESOURCE_CLOSER.register(factoryAndCloser.rhs);
        for (QueryRunner<ResultRow> runner : QueryRunnerTestHelper.makeQueryRunners(factory)) {
            final String testName = StringUtils.format("config=%s, runner=%s", config.toString(), runner.toString());
            constructors.add(new Object[] { testName, factory, runner });
        }
    }
    return constructors;
}
Also used : Closer(org.apache.druid.java.util.common.io.Closer) ResultRow(org.apache.druid.query.groupby.ResultRow) GroupByQueryRunnerFactory(org.apache.druid.query.groupby.GroupByQueryRunnerFactory) GroupByQueryConfig(org.apache.druid.query.groupby.GroupByQueryConfig) ArrayList(java.util.ArrayList)

Aggregations

GroupByQueryRunnerFactory (org.apache.druid.query.groupby.GroupByQueryRunnerFactory)10 GroupByQueryConfig (org.apache.druid.query.groupby.GroupByQueryConfig)9 Closer (org.apache.druid.java.util.common.io.Closer)6 ByteBuffer (java.nio.ByteBuffer)4 DefaultBlockingPool (org.apache.druid.collections.DefaultBlockingPool)4 StupidPool (org.apache.druid.collections.StupidPool)4 GroupByQueryQueryToolChest (org.apache.druid.query.groupby.GroupByQueryQueryToolChest)4 GroupByStrategySelector (org.apache.druid.query.groupby.strategy.GroupByStrategySelector)4 GroupByStrategyV2 (org.apache.druid.query.groupby.strategy.GroupByStrategyV2)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 DefaultObjectMapper (org.apache.druid.jackson.DefaultObjectMapper)3 DruidProcessingConfig (org.apache.druid.query.DruidProcessingConfig)3 GroupByQueryEngine (org.apache.druid.query.groupby.GroupByQueryEngine)3 GroupByStrategyV1 (org.apache.druid.query.groupby.strategy.GroupByStrategyV1)3 SmileFactory (com.fasterxml.jackson.dataformat.smile.SmileFactory)2 ArrayList (java.util.ArrayList)2 OffheapBufferGenerator (org.apache.druid.offheap.OffheapBufferGenerator)2 HyperUniquesSerde (org.apache.druid.query.aggregation.hyperloglog.HyperUniquesSerde)2 ResultRow (org.apache.druid.query.groupby.ResultRow)2 TimeseriesQueryQueryToolChest (org.apache.druid.query.timeseries.TimeseriesQueryQueryToolChest)2