Search in sources :

Example 1 with SelectorFilter

use of io.druid.segment.filter.SelectorFilter in project druid by druid-io.

the class IncrementalIndexStorageAdapterTest method testResetSanity.

@Test
public void testResetSanity() throws IOException {
    IncrementalIndex index = indexCreator.createIndex();
    DateTime t = DateTime.now();
    Interval interval = new Interval(t.minusMinutes(1), t.plusMinutes(1));
    index.add(new MapBasedInputRow(t.minus(1).getMillis(), Lists.newArrayList("billy"), ImmutableMap.<String, Object>of("billy", "hi")));
    index.add(new MapBasedInputRow(t.minus(1).getMillis(), Lists.newArrayList("sally"), ImmutableMap.<String, Object>of("sally", "bo")));
    IncrementalIndexStorageAdapter adapter = new IncrementalIndexStorageAdapter(index);
    for (boolean descending : Arrays.asList(false, true)) {
        Sequence<Cursor> cursorSequence = adapter.makeCursors(new SelectorFilter("sally", "bo"), interval, VirtualColumns.EMPTY, Granularities.NONE, descending);
        Cursor cursor = Sequences.toList(Sequences.limit(cursorSequence, 1), Lists.<Cursor>newArrayList()).get(0);
        DimensionSelector dimSelector;
        dimSelector = cursor.makeDimensionSelector(new DefaultDimensionSpec("sally", "sally"));
        Assert.assertEquals("bo", dimSelector.lookupName(dimSelector.getRow().get(0)));
        index.add(new MapBasedInputRow(t.minus(1).getMillis(), Lists.newArrayList("sally"), ImmutableMap.<String, Object>of("sally", "ah")));
        // Cursor reset should not be affected by out of order values
        cursor.reset();
        dimSelector = cursor.makeDimensionSelector(new DefaultDimensionSpec("sally", "sally"));
        Assert.assertEquals("bo", dimSelector.lookupName(dimSelector.getRow().get(0)));
    }
}
Also used : DimensionSelector(io.druid.segment.DimensionSelector) Cursor(io.druid.segment.Cursor) DateTime(org.joda.time.DateTime) DefaultDimensionSpec(io.druid.query.dimension.DefaultDimensionSpec) SelectorFilter(io.druid.segment.filter.SelectorFilter) MapBasedInputRow(io.druid.data.input.MapBasedInputRow) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 2 with SelectorFilter

use of io.druid.segment.filter.SelectorFilter in project druid by druid-io.

the class FilterPartitionBenchmark method readOrFilter.

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void readOrFilter(Blackhole blackhole) throws Exception {
    Filter filter = new NoBitmapSelectorFilter("dimSequential", "199");
    Filter filter2 = new AndFilter(Arrays.<Filter>asList(new SelectorFilter("dimMultivalEnumerated2", "Corundum"), new NoBitmapSelectorFilter("dimMultivalEnumerated", "Bar")));
    Filter orFilter = new OrFilter(Arrays.<Filter>asList(filter, filter2));
    StorageAdapter sa = new QueryableIndexStorageAdapter(qIndex);
    Sequence<Cursor> cursors = makeCursors(sa, orFilter);
    Sequence<List<String>> stringListSeq = readCursors(cursors, blackhole);
    List<String> strings = Sequences.toList(Sequences.limit(stringListSeq, 1), Lists.<List<String>>newArrayList()).get(0);
    for (String st : strings) {
        blackhole.consume(st);
    }
}
Also used : QueryableIndexStorageAdapter(io.druid.segment.QueryableIndexStorageAdapter) StorageAdapter(io.druid.segment.StorageAdapter) QueryableIndexStorageAdapter(io.druid.segment.QueryableIndexStorageAdapter) OrFilter(io.druid.segment.filter.OrFilter) Cursor(io.druid.segment.Cursor) AndFilter(io.druid.segment.filter.AndFilter) SelectorFilter(io.druid.segment.filter.SelectorFilter) AndFilter(io.druid.segment.filter.AndFilter) BoundFilter(io.druid.segment.filter.BoundFilter) DimensionPredicateFilter(io.druid.segment.filter.DimensionPredicateFilter) BoundDimFilter(io.druid.query.filter.BoundDimFilter) SelectorFilter(io.druid.segment.filter.SelectorFilter) OrDimFilter(io.druid.query.filter.OrDimFilter) SelectorDimFilter(io.druid.query.filter.SelectorDimFilter) DimFilter(io.druid.query.filter.DimFilter) Filter(io.druid.query.filter.Filter) OrFilter(io.druid.segment.filter.OrFilter) AndDimFilter(io.druid.query.filter.AndDimFilter) List(java.util.List) ArrayList(java.util.ArrayList) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Example 3 with SelectorFilter

use of io.druid.segment.filter.SelectorFilter in project druid by druid-io.

the class FilterPartitionBenchmark method readOrFilterCNF.

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void readOrFilterCNF(Blackhole blackhole) throws Exception {
    Filter filter = new NoBitmapSelectorFilter("dimSequential", "199");
    Filter filter2 = new AndFilter(Arrays.<Filter>asList(new SelectorFilter("dimMultivalEnumerated2", "Corundum"), new NoBitmapSelectorFilter("dimMultivalEnumerated", "Bar")));
    Filter orFilter = new OrFilter(Arrays.<Filter>asList(filter, filter2));
    StorageAdapter sa = new QueryableIndexStorageAdapter(qIndex);
    Sequence<Cursor> cursors = makeCursors(sa, Filters.convertToCNF(orFilter));
    Sequence<List<String>> stringListSeq = readCursors(cursors, blackhole);
    List<String> strings = Sequences.toList(Sequences.limit(stringListSeq, 1), Lists.<List<String>>newArrayList()).get(0);
    for (String st : strings) {
        blackhole.consume(st);
    }
}
Also used : QueryableIndexStorageAdapter(io.druid.segment.QueryableIndexStorageAdapter) StorageAdapter(io.druid.segment.StorageAdapter) QueryableIndexStorageAdapter(io.druid.segment.QueryableIndexStorageAdapter) OrFilter(io.druid.segment.filter.OrFilter) Cursor(io.druid.segment.Cursor) AndFilter(io.druid.segment.filter.AndFilter) SelectorFilter(io.druid.segment.filter.SelectorFilter) AndFilter(io.druid.segment.filter.AndFilter) BoundFilter(io.druid.segment.filter.BoundFilter) DimensionPredicateFilter(io.druid.segment.filter.DimensionPredicateFilter) BoundDimFilter(io.druid.query.filter.BoundDimFilter) SelectorFilter(io.druid.segment.filter.SelectorFilter) OrDimFilter(io.druid.query.filter.OrDimFilter) SelectorDimFilter(io.druid.query.filter.SelectorDimFilter) DimFilter(io.druid.query.filter.DimFilter) Filter(io.druid.query.filter.Filter) OrFilter(io.druid.segment.filter.OrFilter) AndDimFilter(io.druid.query.filter.AndDimFilter) List(java.util.List) ArrayList(java.util.ArrayList) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Example 4 with SelectorFilter

use of io.druid.segment.filter.SelectorFilter in project druid by druid-io.

the class FilterPartitionBenchmark method readWithPreFilter.

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void readWithPreFilter(Blackhole blackhole) throws Exception {
    Filter filter = new SelectorFilter("dimSequential", "199");
    StorageAdapter sa = new QueryableIndexStorageAdapter(qIndex);
    Sequence<Cursor> cursors = makeCursors(sa, filter);
    Sequence<List<String>> stringListSeq = readCursors(cursors, blackhole);
    List<String> strings = Sequences.toList(Sequences.limit(stringListSeq, 1), Lists.<List<String>>newArrayList()).get(0);
    for (String st : strings) {
        blackhole.consume(st);
    }
}
Also used : SelectorFilter(io.druid.segment.filter.SelectorFilter) AndFilter(io.druid.segment.filter.AndFilter) BoundFilter(io.druid.segment.filter.BoundFilter) DimensionPredicateFilter(io.druid.segment.filter.DimensionPredicateFilter) BoundDimFilter(io.druid.query.filter.BoundDimFilter) SelectorFilter(io.druid.segment.filter.SelectorFilter) OrDimFilter(io.druid.query.filter.OrDimFilter) SelectorDimFilter(io.druid.query.filter.SelectorDimFilter) DimFilter(io.druid.query.filter.DimFilter) Filter(io.druid.query.filter.Filter) OrFilter(io.druid.segment.filter.OrFilter) AndDimFilter(io.druid.query.filter.AndDimFilter) QueryableIndexStorageAdapter(io.druid.segment.QueryableIndexStorageAdapter) StorageAdapter(io.druid.segment.StorageAdapter) QueryableIndexStorageAdapter(io.druid.segment.QueryableIndexStorageAdapter) List(java.util.List) ArrayList(java.util.ArrayList) Cursor(io.druid.segment.Cursor) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Aggregations

Cursor (io.druid.segment.Cursor)4 SelectorFilter (io.druid.segment.filter.SelectorFilter)4 AndDimFilter (io.druid.query.filter.AndDimFilter)3 BoundDimFilter (io.druid.query.filter.BoundDimFilter)3 DimFilter (io.druid.query.filter.DimFilter)3 Filter (io.druid.query.filter.Filter)3 OrDimFilter (io.druid.query.filter.OrDimFilter)3 SelectorDimFilter (io.druid.query.filter.SelectorDimFilter)3 QueryableIndexStorageAdapter (io.druid.segment.QueryableIndexStorageAdapter)3 StorageAdapter (io.druid.segment.StorageAdapter)3 AndFilter (io.druid.segment.filter.AndFilter)3 BoundFilter (io.druid.segment.filter.BoundFilter)3 DimensionPredicateFilter (io.druid.segment.filter.DimensionPredicateFilter)3 OrFilter (io.druid.segment.filter.OrFilter)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Benchmark (org.openjdk.jmh.annotations.Benchmark)3 BenchmarkMode (org.openjdk.jmh.annotations.BenchmarkMode)3 OutputTimeUnit (org.openjdk.jmh.annotations.OutputTimeUnit)3 MapBasedInputRow (io.druid.data.input.MapBasedInputRow)1