Search in sources :

Example 6 with BySegmentResultValue

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

the class SegmentMetadataQueryTest method testBySegmentResults.

@Test
public void testBySegmentResults() {
    Result<BySegmentResultValue> bySegmentResult = new Result<BySegmentResultValue>(expectedSegmentAnalysis1.getIntervals().get(0).getStart(), new BySegmentResultValueClass(Collections.singletonList(expectedSegmentAnalysis1), expectedSegmentAnalysis1.getId(), testQuery.getIntervals().get(0)));
    QueryToolChest toolChest = FACTORY.getToolchest();
    QueryRunner singleSegmentQueryRunner = toolChest.preMergeQueryDecoration(runner1);
    ExecutorService exec = Executors.newCachedThreadPool();
    QueryRunner myRunner = new FinalizeResultsQueryRunner<>(toolChest.mergeResults(FACTORY.mergeRunners(Execs.directExecutor(), // the bug surfaces only when ordering is used which happens only when you have 2 things to compare
    Lists.newArrayList(singleSegmentQueryRunner, singleSegmentQueryRunner))), toolChest);
    TestHelper.assertExpectedObjects(ImmutableList.of(bySegmentResult, bySegmentResult), myRunner.run(QueryPlus.wrap(testQuery.withOverriddenContext(ImmutableMap.of(QueryContexts.BY_SEGMENT_KEY, true)))), "failed SegmentMetadata bySegment query");
    exec.shutdownNow();
}
Also used : BySegmentResultValue(org.apache.druid.query.BySegmentResultValue) FinalizeResultsQueryRunner(org.apache.druid.query.FinalizeResultsQueryRunner) ExecutorService(java.util.concurrent.ExecutorService) BySegmentResultValueClass(org.apache.druid.query.BySegmentResultValueClass) QueryToolChest(org.apache.druid.query.QueryToolChest) QueryRunner(org.apache.druid.query.QueryRunner) FinalizeResultsQueryRunner(org.apache.druid.query.FinalizeResultsQueryRunner) Result(org.apache.druid.query.Result) Test(org.junit.Test)

Aggregations

BySegmentResultValue (org.apache.druid.query.BySegmentResultValue)6 FinalizeResultsQueryRunner (org.apache.druid.query.FinalizeResultsQueryRunner)6 QueryRunner (org.apache.druid.query.QueryRunner)6 Result (org.apache.druid.query.Result)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)5 ExecutorService (java.util.concurrent.ExecutorService)5 QueryToolChest (org.apache.druid.query.QueryToolChest)5 LongSumAggregatorFactory (org.apache.druid.query.aggregation.LongSumAggregatorFactory)5 SelectorDimFilter (org.apache.druid.query.filter.SelectorDimFilter)5 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)5 PeriodGranularity (org.apache.druid.java.util.common.granularity.PeriodGranularity)4 ChainedExecutionQueryRunner (org.apache.druid.query.ChainedExecutionQueryRunner)4 LookupExtractionFn (org.apache.druid.query.lookup.LookupExtractionFn)4 Period (org.joda.time.Period)4 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)3 ExtractionDimensionSpec (org.apache.druid.query.dimension.ExtractionDimensionSpec)3 MapLookupExtractor (org.apache.druid.query.extraction.MapLookupExtractor)3 DimExtractionFn (org.apache.druid.query.extraction.DimExtractionFn)2 ExtractionFn (org.apache.druid.query.extraction.ExtractionFn)2