Search in sources :

Example 6 with ColumnAnalysis

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

the class SegmentMetadataQueryTest method testSegmentMetadataQueryWithAggregatorsMerge.

@Test
public void testSegmentMetadataQueryWithAggregatorsMerge() {
    final Map<String, AggregatorFactory> expectedAggregators = new HashMap<>();
    for (AggregatorFactory agg : TestIndex.METRIC_AGGS) {
        expectedAggregators.put(agg.getName(), agg.getCombiningFactory());
    }
    SegmentAnalysis mergedSegmentAnalysis = new SegmentAnalysis(differentIds ? "merged" : SegmentId.dummy("testSegment").toString(), null, ImmutableMap.of("placement", new ColumnAnalysis(ColumnType.STRING, ValueType.STRING.toString(), false, false, 0, 0, null, null, null)), 0, expectedSegmentAnalysis1.getNumRows() + expectedSegmentAnalysis2.getNumRows(), expectedAggregators, null, null, null);
    QueryToolChest toolChest = FACTORY.getToolchest();
    ExecutorService exec = Executors.newCachedThreadPool();
    QueryRunner myRunner = new FinalizeResultsQueryRunner<>(toolChest.mergeResults(FACTORY.mergeRunners(Execs.directExecutor(), Lists.newArrayList(toolChest.preMergeQueryDecoration(runner1), toolChest.preMergeQueryDecoration(runner2)))), toolChest);
    SegmentMetadataQuery query = Druids.newSegmentMetadataQueryBuilder().dataSource("testing").intervals("2013/2014").toInclude(new ListColumnIncluderator(Collections.singletonList("placement"))).analysisTypes(SegmentMetadataQuery.AnalysisType.AGGREGATORS).merge(true).build();
    TestHelper.assertExpectedObjects(ImmutableList.of(mergedSegmentAnalysis), myRunner.run(QueryPlus.wrap(query)), "failed SegmentMetadata merging query");
    exec.shutdownNow();
}
Also used : FinalizeResultsQueryRunner(org.apache.druid.query.FinalizeResultsQueryRunner) HashMap(java.util.HashMap) SegmentMetadataQuery(org.apache.druid.query.metadata.metadata.SegmentMetadataQuery) ListColumnIncluderator(org.apache.druid.query.metadata.metadata.ListColumnIncluderator) ColumnAnalysis(org.apache.druid.query.metadata.metadata.ColumnAnalysis) ExecutorService(java.util.concurrent.ExecutorService) SegmentAnalysis(org.apache.druid.query.metadata.metadata.SegmentAnalysis) QueryToolChest(org.apache.druid.query.QueryToolChest) AggregatorFactory(org.apache.druid.query.aggregation.AggregatorFactory) QueryRunner(org.apache.druid.query.QueryRunner) FinalizeResultsQueryRunner(org.apache.druid.query.FinalizeResultsQueryRunner) Test(org.junit.Test)

Example 7 with ColumnAnalysis

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

the class SegmentMetadataQueryTest method testFloatNullableColumn.

@Test
public void testFloatNullableColumn() {
    ColumnAnalysis analysis = new ColumnAnalysis(ColumnType.FLOAT, ValueType.FLOAT.toString(), false, NullHandling.replaceWithDefault() ? false : true, 19344, null, null, null, null);
    testSegmentMetadataQueryWithDefaultAnalysisMerge("floatNumericNull", analysis);
}
Also used : ColumnAnalysis(org.apache.druid.query.metadata.metadata.ColumnAnalysis) Test(org.junit.Test)

Example 8 with ColumnAnalysis

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

the class SegmentMetadataQueryTest method testSegmentMetadataQueryWithDefaultAnalysisMerge2.

@Test
public void testSegmentMetadataQueryWithDefaultAnalysisMerge2() {
    int size1 = 0;
    int size2 = 0;
    if (bitmaps) {
        size1 = mmap1 ? 6882 : 6808;
        size2 = mmap2 ? 6882 : 6808;
    }
    ColumnAnalysis analysis = new ColumnAnalysis(ColumnType.STRING, ValueType.STRING.toString(), false, false, size1 + size2, 3, "spot", "upfront", null);
    testSegmentMetadataQueryWithDefaultAnalysisMerge("market", analysis);
}
Also used : ColumnAnalysis(org.apache.druid.query.metadata.metadata.ColumnAnalysis) Test(org.junit.Test)

Example 9 with ColumnAnalysis

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

the class SegmentMetadataQueryTest method testDoubleNullableColumn.

@Test
public void testDoubleNullableColumn() {
    ColumnAnalysis analysis = new ColumnAnalysis(ColumnType.DOUBLE, ValueType.DOUBLE.toString(), false, NullHandling.replaceWithDefault() ? false : true, 19344, null, null, null, null);
    testSegmentMetadataQueryWithDefaultAnalysisMerge("doubleNumericNull", analysis);
}
Also used : ColumnAnalysis(org.apache.druid.query.metadata.metadata.ColumnAnalysis) Test(org.junit.Test)

Example 10 with ColumnAnalysis

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

the class SegmentMetadataQueryTest method testSegmentMetadataQueryWithDefaultAnalysisMerge.

private void testSegmentMetadataQueryWithDefaultAnalysisMerge(String column, ColumnAnalysis analysis) {
    SegmentAnalysis mergedSegmentAnalysis = new SegmentAnalysis(differentIds ? "merged" : SegmentId.dummy("testSegment").toString(), ImmutableList.of(expectedSegmentAnalysis1.getIntervals().get(0)), ImmutableMap.of("__time", new ColumnAnalysis(ColumnType.LONG, ValueType.LONG.toString(), false, false, 12090 * 2, null, null, null, null), "index", new ColumnAnalysis(ColumnType.DOUBLE, ValueType.DOUBLE.toString(), false, false, 9672 * 2, null, null, null, null), column, analysis), expectedSegmentAnalysis1.getSize() + expectedSegmentAnalysis2.getSize(), expectedSegmentAnalysis1.getNumRows() + expectedSegmentAnalysis2.getNumRows(), null, null, null, null);
    QueryToolChest toolChest = FACTORY.getToolchest();
    ExecutorService exec = Executors.newCachedThreadPool();
    QueryRunner myRunner = new FinalizeResultsQueryRunner<>(toolChest.mergeResults(FACTORY.mergeRunners(Execs.directExecutor(), Lists.newArrayList(toolChest.preMergeQueryDecoration(runner1), toolChest.preMergeQueryDecoration(runner2)))), toolChest);
    Query query = testQuery.withColumns(new ListColumnIncluderator(Arrays.asList("__time", "index", column)));
    TestHelper.assertExpectedObjects(ImmutableList.of(mergedSegmentAnalysis), myRunner.run(QueryPlus.wrap(query)), "failed SegmentMetadata merging query");
    exec.shutdownNow();
}
Also used : FinalizeResultsQueryRunner(org.apache.druid.query.FinalizeResultsQueryRunner) SegmentMetadataQuery(org.apache.druid.query.metadata.metadata.SegmentMetadataQuery) Query(org.apache.druid.query.Query) ListColumnIncluderator(org.apache.druid.query.metadata.metadata.ListColumnIncluderator) ColumnAnalysis(org.apache.druid.query.metadata.metadata.ColumnAnalysis) ExecutorService(java.util.concurrent.ExecutorService) SegmentAnalysis(org.apache.druid.query.metadata.metadata.SegmentAnalysis) QueryToolChest(org.apache.druid.query.QueryToolChest) QueryRunner(org.apache.druid.query.QueryRunner) FinalizeResultsQueryRunner(org.apache.druid.query.FinalizeResultsQueryRunner)

Aggregations

ColumnAnalysis (org.apache.druid.query.metadata.metadata.ColumnAnalysis)30 SegmentAnalysis (org.apache.druid.query.metadata.metadata.SegmentAnalysis)19 Test (org.junit.Test)18 SegmentMetadataQuery (org.apache.druid.query.metadata.metadata.SegmentMetadataQuery)12 QueryRunner (org.apache.druid.query.QueryRunner)9 ListColumnIncluderator (org.apache.druid.query.metadata.metadata.ListColumnIncluderator)9 ExecutorService (java.util.concurrent.ExecutorService)8 FinalizeResultsQueryRunner (org.apache.druid.query.FinalizeResultsQueryRunner)8 QueryToolChest (org.apache.druid.query.QueryToolChest)8 Map (java.util.Map)4 TreeMap (java.util.TreeMap)4 TimestampSpec (org.apache.druid.data.input.impl.TimestampSpec)4 AggregatorFactory (org.apache.druid.query.aggregation.AggregatorFactory)4 RowSignature (org.apache.druid.segment.column.RowSignature)4 HashMap (java.util.HashMap)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 IOException (java.io.IOException)2 List (java.util.List)2 DimensionSchema (org.apache.druid.data.input.impl.DimensionSchema)2 Granularity (org.apache.druid.java.util.common.granularity.Granularity)2