Search in sources :

Example 1 with SegmentMetadataQueryConfig

use of org.apache.druid.query.metadata.SegmentMetadataQueryConfig 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 2 with SegmentMetadataQueryConfig

use of org.apache.druid.query.metadata.SegmentMetadataQueryConfig in project druid by druid-io.

the class SegmentMetadataQueryConfigTest method testSerdeSegmentMetadataQueryConfig.

@Test
public void testSerdeSegmentMetadataQueryConfig() {
    Injector injector = Guice.createInjector(new Module() {

        @Override
        public void configure(Binder binder) {
            binder.install(new PropertiesModule(Collections.singletonList("test.runtime.properties")));
            binder.install(new ConfigModule());
            binder.install(new DruidGuiceExtensions());
            JsonConfigProvider.bind(binder, "druid.query.segmentMetadata", SegmentMetadataQueryConfig.class);
        }

        @Provides
        @LazySingleton
        public ObjectMapper jsonMapper() {
            return new DefaultObjectMapper();
        }
    });
    Properties props = injector.getInstance(Properties.class);
    SegmentMetadataQueryConfig config = injector.getInstance(SegmentMetadataQueryConfig.class);
    EnumSet<SegmentMetadataQuery.AnalysisType> expectedDefaultAnalysis = config.getDefaultAnalysisTypes();
    String actualDefaultAnalysis = props.getProperty("druid.query.segmentMetadata.defaultAnalysisTypes");
    Iterator<SegmentMetadataQuery.AnalysisType> it = expectedDefaultAnalysis.iterator();
    StringBuilder expectedDefaultAnalysisAsStringBuilder = new StringBuilder();
    expectedDefaultAnalysisAsStringBuilder.append('[');
    while (it.hasNext()) {
        SegmentMetadataQuery.AnalysisType e = it.next();
        expectedDefaultAnalysisAsStringBuilder.append("\"").append(e).append("\"");
        if (it.hasNext()) {
            expectedDefaultAnalysisAsStringBuilder.append(',').append(' ');
        }
    }
    expectedDefaultAnalysisAsStringBuilder.append(']');
    Assert.assertEquals(expectedDefaultAnalysisAsStringBuilder.toString(), actualDefaultAnalysis);
    Assert.assertEquals(props.getProperty("druid.query.segmentMetadata.defaultHistory"), config.getDefaultHistory().toString());
}
Also used : Provides(com.google.inject.Provides) Properties(java.util.Properties) Binder(com.google.inject.Binder) Injector(com.google.inject.Injector) SegmentMetadataQuery(org.apache.druid.query.metadata.metadata.SegmentMetadataQuery) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper) Module(com.google.inject.Module) SegmentMetadataQueryConfig(org.apache.druid.query.metadata.SegmentMetadataQueryConfig) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper) Test(org.junit.Test)

Example 3 with SegmentMetadataQueryConfig

use of org.apache.druid.query.metadata.SegmentMetadataQueryConfig in project druid by druid-io.

the class ClientInfoResourceTest method testGetDatasourceWithConfiguredDefaultInterval.

@Test
public void testGetDatasourceWithConfiguredDefaultInterval() {
    ClientInfoResource defaultResource = getResourceTestHelper(serverInventoryView, timelineServerView, new SegmentMetadataQueryConfig("P100Y"));
    Map<String, Object> expected = ImmutableMap.of(KEY_DIMENSIONS, ImmutableSet.of("d1", "d2", "d3", "d4", "d5"), KEY_METRICS, ImmutableSet.of("m1", "m2", "m3", "m4", "m5"));
    Map<String, Object> actual = defaultResource.getDatasource(dataSource, null, null);
    Assert.assertEquals(expected, actual);
}
Also used : SegmentMetadataQueryConfig(org.apache.druid.query.metadata.SegmentMetadataQueryConfig) Test(org.junit.Test)

Example 4 with SegmentMetadataQueryConfig

use of org.apache.druid.query.metadata.SegmentMetadataQueryConfig in project druid by druid-io.

the class ClientInfoResourceTest method setup.

@Before
public void setup() {
    VersionedIntervalTimeline<String, ServerSelector> timeline = new VersionedIntervalTimeline<>(Ordering.natural());
    DruidServer server = new DruidServer("name", "host", null, 1234, ServerType.HISTORICAL, "tier", 0);
    addSegment(timeline, server, "1960-02-13/1961-02-14", ImmutableList.of("d5"), ImmutableList.of("m5"), "v0");
    // segments within [2014-02-13, 2014-02-18]
    addSegment(timeline, server, "2014-02-13/2014-02-14", ImmutableList.of("d1"), ImmutableList.of("m1"), "v0");
    addSegment(timeline, server, "2014-02-14/2014-02-15", ImmutableList.of("d1"), ImmutableList.of("m1"), "v0");
    addSegment(timeline, server, "2014-02-16/2014-02-17", ImmutableList.of("d1"), ImmutableList.of("m1"), "v0");
    addSegment(timeline, server, "2014-02-17/2014-02-18", ImmutableList.of("d2"), ImmutableList.of("m2"), "v0");
    // segments within [2015-02-01, 2015-02-13]
    addSegment(timeline, server, "2015-02-01/2015-02-07", ImmutableList.of("d1"), ImmutableList.of("m1"), "v1");
    addSegment(timeline, server, "2015-02-07/2015-02-13", ImmutableList.of("d1"), ImmutableList.of("m1"), "v1");
    addSegmentWithShardSpec(timeline, server, "2015-02-03/2015-02-05", ImmutableList.of("d1", "d2"), ImmutableList.of("m1", "m2"), "v2", new NumberedShardSpec(0, 2));
    addSegmentWithShardSpec(timeline, server, "2015-02-03/2015-02-05", ImmutableList.of("d1", "d2", "d3"), ImmutableList.of("m1", "m2", "m3"), "v2", new NumberedShardSpec(1, 2));
    addSegment(timeline, server, "2015-02-09/2015-02-10", ImmutableList.of("d1", "d3"), ImmutableList.of("m1", "m3"), "v2");
    addSegment(timeline, server, "2015-02-11/2015-02-12", ImmutableList.of("d3"), ImmutableList.of("m3"), "v2");
    // segments within [2015-03-13, 2015-03-19]
    addSegment(timeline, server, "2015-03-13/2015-03-19", ImmutableList.of("d1"), ImmutableList.of("m1"), "v3");
    addSegment(timeline, server, "2015-03-13/2015-03-14", ImmutableList.of("d1"), ImmutableList.of("m1"), "v4");
    addSegment(timeline, server, "2015-03-14/2015-03-15", ImmutableList.of("d1"), ImmutableList.of("m1"), "v5");
    addSegment(timeline, server, "2015-03-15/2015-03-16", ImmutableList.of("d1"), ImmutableList.of("m1"), "v6");
    // imcomplete segment
    addSegmentWithShardSpec(timeline, server, "2015-04-03/2015-04-05", ImmutableList.of("d4"), ImmutableList.of("m4"), "v7", new NumberedShardSpec(0, 2));
    serverInventoryView = EasyMock.createMock(FilteredServerInventoryView.class);
    EasyMock.expect(serverInventoryView.getInventory()).andReturn(ImmutableList.of(server)).anyTimes();
    timelineServerView = EasyMock.createMock(TimelineServerView.class);
    EasyMock.expect(timelineServerView.getTimeline(EasyMock.anyObject(DataSourceAnalysis.class))).andReturn((Optional) Optional.of(timeline));
    EasyMock.replay(serverInventoryView, timelineServerView);
    resource = getResourceTestHelper(serverInventoryView, timelineServerView, new SegmentMetadataQueryConfig());
}
Also used : FilteredServerInventoryView(org.apache.druid.client.FilteredServerInventoryView) ServerSelector(org.apache.druid.client.selector.ServerSelector) VersionedIntervalTimeline(org.apache.druid.timeline.VersionedIntervalTimeline) DruidServer(org.apache.druid.client.DruidServer) TimelineServerView(org.apache.druid.client.TimelineServerView) DataSourceAnalysis(org.apache.druid.query.planning.DataSourceAnalysis) NumberedShardSpec(org.apache.druid.timeline.partition.NumberedShardSpec) SegmentMetadataQueryConfig(org.apache.druid.query.metadata.SegmentMetadataQueryConfig) Before(org.junit.Before)

Aggregations

SegmentMetadataQueryConfig (org.apache.druid.query.metadata.SegmentMetadataQueryConfig)4 Test (org.junit.Test)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Binder (com.google.inject.Binder)1 Injector (com.google.inject.Injector)1 Module (com.google.inject.Module)1 Provides (com.google.inject.Provides)1 ByteBuffer (java.nio.ByteBuffer)1 Properties (java.util.Properties)1 DruidServer (org.apache.druid.client.DruidServer)1 FilteredServerInventoryView (org.apache.druid.client.FilteredServerInventoryView)1 TimelineServerView (org.apache.druid.client.TimelineServerView)1 ServerSelector (org.apache.druid.client.selector.ServerSelector)1 CloseableStupidPool (org.apache.druid.collections.CloseableStupidPool)1 DefaultObjectMapper (org.apache.druid.jackson.DefaultObjectMapper)1 Closer (org.apache.druid.java.util.common.io.Closer)1 DefaultGenericQueryMetricsFactory (org.apache.druid.query.DefaultGenericQueryMetricsFactory)1 DefaultQueryRunnerFactoryConglomerate (org.apache.druid.query.DefaultQueryRunnerFactoryConglomerate)1 QueryRunnerFactoryConglomerate (org.apache.druid.query.QueryRunnerFactoryConglomerate)1 GroupByQueryConfig (org.apache.druid.query.groupby.GroupByQueryConfig)1