Search in sources :

Example 1 with SearchHit

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

the class CachingClusteredClientTest method makeSearchResults.

private Iterable<Result<SearchResultValue>> makeSearchResults(String dim, Object... objects) {
    List<Result<SearchResultValue>> retVal = new ArrayList<>();
    int index = 0;
    while (index < objects.length) {
        DateTime timestamp = (DateTime) objects[index++];
        List<SearchHit> values = new ArrayList<>();
        while (index < objects.length && !(objects[index] instanceof DateTime)) {
            values.add(new SearchHit(dim, objects[index++].toString(), (Integer) objects[index++]));
        }
        retVal.add(new Result<>(timestamp, new SearchResultValue(values)));
    }
    return retVal;
}
Also used : SearchResultValue(org.apache.druid.query.search.SearchResultValue) SearchHit(org.apache.druid.query.search.SearchHit) ArrayList(java.util.ArrayList) DateTime(org.joda.time.DateTime) Result(org.apache.druid.query.Result)

Example 2 with SearchHit

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

the class SearchBenchmark method querySingleIncrementalIndex.

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void querySingleIncrementalIndex(Blackhole blackhole, IncrementalIndexState state) {
    QueryRunner<SearchHit> runner = QueryBenchmarkUtil.makeQueryRunner(factory, SegmentId.dummy("incIndex"), new IncrementalIndexSegment(state.incIndex, SegmentId.dummy("incIndex")));
    List<Result<SearchResultValue>> results = SearchBenchmark.runQuery(factory, runner, query);
    blackhole.consume(results);
}
Also used : SearchHit(org.apache.druid.query.search.SearchHit) IncrementalIndexSegment(org.apache.druid.segment.IncrementalIndexSegment) Result(org.apache.druid.query.Result) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Example 3 with SearchHit

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

the class SchemalessTestSimpleTest method testFullOnSearch.

@Test
public void testFullOnSearch() {
    SearchQuery query = Druids.newSearchQueryBuilder().dataSource(dataSource).granularity(ALL_GRAN).intervals(fullOnInterval).query("a").build();
    List<Result<SearchResultValue>> expectedResults = Collections.singletonList(new Result<SearchResultValue>(DateTimes.of("2011-01-12T00:00:00.000Z"), new SearchResultValue(Arrays.asList(new SearchHit(placementishDimension, "a"), new SearchHit(qualityDimension, "automotive"), new SearchHit(placementDimension, "mezzanine"), new SearchHit(marketDimension, "total_market")))));
    QueryRunner runner = TestQueryRunners.makeSearchQueryRunner(segment);
    TestHelper.assertExpectedResults(expectedResults, runner.run(QueryPlus.wrap(query)));
}
Also used : SearchQuery(org.apache.druid.query.search.SearchQuery) SearchResultValue(org.apache.druid.query.search.SearchResultValue) SearchHit(org.apache.druid.query.search.SearchHit) QueryRunner(org.apache.druid.query.QueryRunner) Result(org.apache.druid.query.Result) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Aggregations

Result (org.apache.druid.query.Result)3 SearchHit (org.apache.druid.query.search.SearchHit)3 SearchResultValue (org.apache.druid.query.search.SearchResultValue)2 ArrayList (java.util.ArrayList)1 QueryRunner (org.apache.druid.query.QueryRunner)1 SearchQuery (org.apache.druid.query.search.SearchQuery)1 IncrementalIndexSegment (org.apache.druid.segment.IncrementalIndexSegment)1 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)1 DateTime (org.joda.time.DateTime)1 Test (org.junit.Test)1 Benchmark (org.openjdk.jmh.annotations.Benchmark)1 BenchmarkMode (org.openjdk.jmh.annotations.BenchmarkMode)1 OutputTimeUnit (org.openjdk.jmh.annotations.OutputTimeUnit)1