use of org.apache.druid.segment.QueryableIndexSegment in project druid by druid-io.
the class MultiValuedDimensionTest method testGroupByWithDimFilterEmptyResults.
@Test
public void testGroupByWithDimFilterEmptyResults() {
GroupByQuery query = GroupByQuery.builder().setDataSource("xx").setQuerySegmentSpec(new LegacySegmentSpec("1970/3000")).setGranularity(Granularities.ALL).setDimensions(new DefaultDimensionSpec("tags", "tags")).setAggregatorSpecs(new CountAggregatorFactory("count")).setDimFilter(new InDimFilter("product", ImmutableList.of("product_5"), null)).setContext(context).build();
Sequence<ResultRow> result = helper.runQueryOnSegmentsObjs(ImmutableList.of(new QueryableIndexSegment(queryableIndexNullSampler, SegmentId.dummy("sid1")), new IncrementalIndexSegment(incrementalIndexNullSampler, SegmentId.dummy("sid2"))), query);
List<ResultRow> expectedResults = Collections.singletonList(GroupByQueryRunnerTestHelper.createExpectedRow(query, "1970-01-01T00:00:00.000Z", "tags", null, "count", 2L));
TestHelper.assertExpectedObjects(expectedResults, result.toList(), "filter-empty");
}
use of org.apache.druid.segment.QueryableIndexSegment in project druid by druid-io.
the class MultiValuedDimensionTest method testTopNWithDimFilterAndWithFilteredDimSpec.
@Test
public void testTopNWithDimFilterAndWithFilteredDimSpec() {
TopNQuery query = new TopNQueryBuilder().dataSource("xx").granularity(Granularities.ALL).dimension(new ListFilteredDimensionSpec(new DefaultDimensionSpec("tags", "tags"), ImmutableSet.of("t3"), null)).metric("count").intervals(QueryRunnerTestHelper.FULL_ON_INTERVAL_SPEC).aggregators(new CountAggregatorFactory("count")).threshold(5).filters(new SelectorDimFilter("tags", "t3", null)).build();
try (CloseableStupidPool<ByteBuffer> pool = TestQueryRunners.createDefaultNonBlockingPool()) {
QueryRunnerFactory factory = new TopNQueryRunnerFactory(pool, new TopNQueryQueryToolChest(new TopNQueryConfig()), QueryRunnerTestHelper.NOOP_QUERYWATCHER);
QueryRunner<Result<TopNResultValue>> runner = QueryRunnerTestHelper.makeQueryRunner(factory, new QueryableIndexSegment(queryableIndex, SegmentId.dummy("sid1")), null);
Sequence<Result<TopNResultValue>> result = runner.run(QueryPlus.wrap(query));
List<Result<TopNResultValue>> expectedResults = Collections.singletonList(new Result<TopNResultValue>(DateTimes.of("2011-01-12T00:00:00.000Z"), new TopNResultValue(Collections.<Map<String, Object>>singletonList(ImmutableMap.of("tags", "t3", "count", 2L)))));
TestHelper.assertExpectedObjects(expectedResults, result.toList(), "filteredDim");
}
}
use of org.apache.druid.segment.QueryableIndexSegment in project druid by druid-io.
the class GroupByLimitPushDownInsufficientBufferTest method getRunner1.
private List<QueryRunner<ResultRow>> getRunner1() {
List<QueryRunner<ResultRow>> runners = new ArrayList<>();
QueryableIndex index = groupByIndices.get(0);
QueryRunner<ResultRow> runner = makeQueryRunner(groupByFactory, SegmentId.dummy(index.toString()), new QueryableIndexSegment(index, SegmentId.dummy(index.toString())));
runners.add(groupByFactory.getToolchest().preMergeQueryDecoration(runner));
return runners;
}
use of org.apache.druid.segment.QueryableIndexSegment in project druid by druid-io.
the class GroupByMultiSegmentTest method makeGroupByMultiRunners.
private List<QueryRunner<ResultRow>> makeGroupByMultiRunners() {
List<QueryRunner<ResultRow>> runners = new ArrayList<>();
for (QueryableIndex qindex : groupByIndices) {
QueryRunner<ResultRow> runner = makeQueryRunner(groupByFactory, SegmentId.dummy(qindex.toString()), new QueryableIndexSegment(qindex, SegmentId.dummy(qindex.toString())));
runners.add(groupByFactory.getToolchest().preMergeQueryDecoration(runner));
}
return runners;
}
use of org.apache.druid.segment.QueryableIndexSegment in project druid by druid-io.
the class GroupByLimitPushDownMultiNodeMergeTest method getRunner2.
private List<QueryRunner<ResultRow>> getRunner2(int qIndexNumber) {
List<QueryRunner<ResultRow>> runners = new ArrayList<>();
QueryableIndex index2 = groupByIndices.get(qIndexNumber);
QueryRunner<ResultRow> tooSmallRunner = makeQueryRunner(groupByFactory2, SegmentId.dummy(index2.toString()), new QueryableIndexSegment(index2, SegmentId.dummy(index2.toString())));
runners.add(groupByFactory2.getToolchest().preMergeQueryDecoration(tooSmallRunner));
return runners;
}
Aggregations