Search in sources :

Example 1 with SelectResultValue

use of io.druid.query.select.SelectResultValue in project druid by druid-io.

the class SketchAggregationTestWithSimpleData method testSimpleDataIngestAndSelectQuery.

@Test
public void testSimpleDataIngestAndSelectQuery() throws Exception {
    SketchModule sm = new SketchModule();
    sm.configure(null);
    AggregationTestHelper selectQueryAggregationTestHelper = AggregationTestHelper.createSelectQueryAggregationTestHelper(sm.getJacksonModules(), tempFolder);
    Sequence seq = selectQueryAggregationTestHelper.runQueryOnSegments(ImmutableList.of(s1, s2), readFileFromClasspathAsString("select_query.json"));
    Result<SelectResultValue> result = (Result<SelectResultValue>) Iterables.getOnlyElement(Sequences.toList(seq, Lists.newArrayList()));
    Assert.assertEquals(new DateTime("2014-10-20T00:00:00.000Z"), result.getTimestamp());
    Assert.assertEquals(100, result.getValue().getEvents().size());
    Assert.assertEquals("AgMDAAAazJMCAAAAAACAPzz9j7pWTMdROWGf15uY1nI=", result.getValue().getEvents().get(0).getEvent().get("pty_country"));
}
Also used : SelectResultValue(io.druid.query.select.SelectResultValue) AggregationTestHelper(io.druid.query.aggregation.AggregationTestHelper) Sequence(io.druid.java.util.common.guava.Sequence) DateTime(org.joda.time.DateTime) Result(io.druid.query.Result) Test(org.junit.Test) GroupByQueryRunnerTest(io.druid.query.groupby.GroupByQueryRunnerTest)

Example 2 with SelectResultValue

use of io.druid.query.select.SelectResultValue in project druid by druid-io.

the class CachingClusteredClientTest method makeSelectResults.

private Iterable<Result<SelectResultValue>> makeSelectResults(Set<String> dimensions, Set<String> metrics, Object... objects) {
    List<Result<SelectResultValue>> retVal = Lists.newArrayList();
    int index = 0;
    while (index < objects.length) {
        DateTime timestamp = (DateTime) objects[index++];
        List<EventHolder> values = Lists.newArrayList();
        while (index < objects.length && !(objects[index] instanceof DateTime)) {
            values.add(new EventHolder(null, 0, (Map) objects[index++]));
        }
        retVal.add(new Result<>(timestamp, new SelectResultValue(null, dimensions, metrics, values)));
    }
    return retVal;
}
Also used : SelectResultValue(io.druid.query.select.SelectResultValue) EventHolder(io.druid.query.select.EventHolder) Map(java.util.Map) TreeMap(java.util.TreeMap) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) DateTime(org.joda.time.DateTime) Result(io.druid.query.Result)

Example 3 with SelectResultValue

use of io.druid.query.select.SelectResultValue in project druid by druid-io.

the class SelectBenchmark method queryMultiQueryableIndex.

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void queryMultiQueryableIndex(Blackhole blackhole) throws Exception {
    SelectQuery queryCopy = query.withPagingSpec(PagingSpec.newSpec(pagingThreshold));
    String segmentName;
    List<QueryRunner<Result<SelectResultValue>>> singleSegmentRunners = Lists.newArrayList();
    QueryToolChest toolChest = factory.getToolchest();
    for (int i = 0; i < numSegments; i++) {
        segmentName = "qIndex" + i;
        QueryRunner<Result<SelectResultValue>> runner = QueryBenchmarkUtil.makeQueryRunner(factory, segmentName, new QueryableIndexSegment(segmentName, qIndexes.get(i)));
        singleSegmentRunners.add(toolChest.preMergeQueryDecoration(runner));
    }
    QueryRunner theRunner = toolChest.postMergeQueryDecoration(new FinalizeResultsQueryRunner<>(toolChest.mergeResults(factory.mergeRunners(executorService, singleSegmentRunners)), toolChest));
    boolean done = false;
    while (!done) {
        Sequence<Result<SelectResultValue>> queryResult = theRunner.run(queryCopy, Maps.<String, Object>newHashMap());
        List<Result<SelectResultValue>> results = Sequences.toList(queryResult, Lists.<Result<SelectResultValue>>newArrayList());
        SelectResultValue result = results.get(0).getValue();
        if (result.getEvents().size() == 0) {
            done = true;
        } else {
            for (EventHolder eh : result.getEvents()) {
                blackhole.consume(eh);
            }
            queryCopy = incrementQueryPagination(queryCopy, result);
        }
    }
}
Also used : QueryableIndexSegment(io.druid.segment.QueryableIndexSegment) SelectResultValue(io.druid.query.select.SelectResultValue) SelectQueryQueryToolChest(io.druid.query.select.SelectQueryQueryToolChest) QueryToolChest(io.druid.query.QueryToolChest) FinalizeResultsQueryRunner(io.druid.query.FinalizeResultsQueryRunner) QueryRunner(io.druid.query.QueryRunner) Result(io.druid.query.Result) SelectQuery(io.druid.query.select.SelectQuery) EventHolder(io.druid.query.select.EventHolder) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Example 4 with SelectResultValue

use of io.druid.query.select.SelectResultValue in project druid by druid-io.

the class MapVirtualColumnTest method checkSelectQuery.

private void checkSelectQuery(SelectQuery searchQuery, List<Map> expected) throws Exception {
    List<Result<SelectResultValue>> results = Sequences.toList(runner.run(searchQuery, ImmutableMap.of()), Lists.<Result<SelectResultValue>>newArrayList());
    Assert.assertEquals(1, results.size());
    List<EventHolder> events = results.get(0).getValue().getEvents();
    Assert.assertEquals(expected.size(), events.size());
    for (int i = 0; i < events.size(); i++) {
        Map event = events.get(i).getEvent();
        event.remove(EventHolder.timestampKey);
        Assert.assertEquals(expected.get(i), event);
    }
}
Also used : SelectResultValue(io.druid.query.select.SelectResultValue) EventHolder(io.druid.query.select.EventHolder) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Result(io.druid.query.Result)

Example 5 with SelectResultValue

use of io.druid.query.select.SelectResultValue in project druid by druid-io.

the class SelectBenchmark method queryIncrementalIndex.

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void queryIncrementalIndex(Blackhole blackhole) throws Exception {
    SelectQuery queryCopy = query.withPagingSpec(PagingSpec.newSpec(pagingThreshold));
    String segmentId = "incIndex";
    QueryRunner<Row> runner = QueryBenchmarkUtil.makeQueryRunner(factory, segmentId, new IncrementalIndexSegment(incIndexes.get(0), segmentId));
    boolean done = false;
    while (!done) {
        List<Result<SelectResultValue>> results = SelectBenchmark.runQuery(factory, runner, queryCopy);
        SelectResultValue result = results.get(0).getValue();
        if (result.getEvents().size() == 0) {
            done = true;
        } else {
            for (EventHolder eh : result.getEvents()) {
                blackhole.consume(eh);
            }
            queryCopy = incrementQueryPagination(queryCopy, result);
        }
    }
}
Also used : SelectQuery(io.druid.query.select.SelectQuery) SelectResultValue(io.druid.query.select.SelectResultValue) IncrementalIndexSegment(io.druid.segment.IncrementalIndexSegment) InputRow(io.druid.data.input.InputRow) Row(io.druid.data.input.Row) EventHolder(io.druid.query.select.EventHolder) Result(io.druid.query.Result) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Aggregations

Result (io.druid.query.Result)8 SelectResultValue (io.druid.query.select.SelectResultValue)8 EventHolder (io.druid.query.select.EventHolder)6 SelectQuery (io.druid.query.select.SelectQuery)4 Sequence (io.druid.java.util.common.guava.Sequence)3 Map (java.util.Map)3 Benchmark (org.openjdk.jmh.annotations.Benchmark)3 BenchmarkMode (org.openjdk.jmh.annotations.BenchmarkMode)3 OutputTimeUnit (org.openjdk.jmh.annotations.OutputTimeUnit)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 QueryableIndexSegment (io.druid.segment.QueryableIndexSegment)2 DateTime (org.joda.time.DateTime)2 Test (org.junit.Test)2 InputRow (io.druid.data.input.InputRow)1 Row (io.druid.data.input.Row)1 ISE (io.druid.java.util.common.ISE)1 FinalizeResultsQueryRunner (io.druid.query.FinalizeResultsQueryRunner)1 QueryRunner (io.druid.query.QueryRunner)1 QueryToolChest (io.druid.query.QueryToolChest)1 AggregationTestHelper (io.druid.query.aggregation.AggregationTestHelper)1