Search in sources :

Example 11 with SearchQueryDimFilter

use of io.druid.query.filter.SearchQueryDimFilter in project druid by druid-io.

the class SearchQueryFilterTest method testSingleValueStringColumnWithoutNulls.

@Test
public void testSingleValueStringColumnWithoutNulls() {
    assertFilterMatches(new SearchQueryDimFilter("dim0", specForValue(""), null), ImmutableList.of("0", "1", "2", "3", "4", "5"));
    assertFilterMatches(new SearchQueryDimFilter("dim0", specForValue("0"), null), ImmutableList.of("0"));
    assertFilterMatches(new SearchQueryDimFilter("dim0", specForValue("5"), null), ImmutableList.of("5"));
}
Also used : SearchQueryDimFilter(io.druid.query.filter.SearchQueryDimFilter) Test(org.junit.Test)

Example 12 with SearchQueryDimFilter

use of io.druid.query.filter.SearchQueryDimFilter in project druid by druid-io.

the class SearchQueryFilterTest method testSearchQueryWithExtractionFn.

@Test
public void testSearchQueryWithExtractionFn() {
    String nullJsFn = "function(str) { if (str === null) { return 'NOT_NULL_ANYMORE'; } else { return str;} }";
    ExtractionFn changeNullFn = new JavaScriptExtractionFn(nullJsFn, false, JavaScriptConfig.getEnabledInstance());
    assertFilterMatches(new SearchQueryDimFilter("dim1", specForValue("ANYMORE"), changeNullFn), ImmutableList.of("0"));
    assertFilterMatches(new SearchQueryDimFilter("dim1", specForValue("ab"), changeNullFn), ImmutableList.<String>of("4", "5"));
    assertFilterMatches(new SearchQueryDimFilter("dim2", specForValue("ANYMORE"), changeNullFn), ImmutableList.of("1", "2", "5"));
    assertFilterMatches(new SearchQueryDimFilter("dim2", specForValue("a"), changeNullFn), ImmutableList.of("0", "3"));
    assertFilterMatches(new SearchQueryDimFilter("dim3", specForValue("ANYMORE"), changeNullFn), ImmutableList.of("0", "1", "2", "3", "4", "5"));
    assertFilterMatches(new SearchQueryDimFilter("dim3", specForValue("a"), changeNullFn), ImmutableList.<String>of());
    assertFilterMatches(new SearchQueryDimFilter("dim4", specForValue("ANYMORE"), changeNullFn), ImmutableList.of("0", "1", "2", "3", "4", "5"));
    assertFilterMatches(new SearchQueryDimFilter("dim4", specForValue("a"), changeNullFn), ImmutableList.<String>of());
}
Also used : JavaScriptExtractionFn(io.druid.query.extraction.JavaScriptExtractionFn) ExtractionFn(io.druid.query.extraction.ExtractionFn) JavaScriptExtractionFn(io.druid.query.extraction.JavaScriptExtractionFn) SearchQueryDimFilter(io.druid.query.filter.SearchQueryDimFilter) Test(org.junit.Test)

Example 13 with SearchQueryDimFilter

use of io.druid.query.filter.SearchQueryDimFilter in project druid by druid-io.

the class SearchQueryFilterTest method testMissingColumnSpecifiedInDimensionList.

@Test
public void testMissingColumnSpecifiedInDimensionList() {
    assertFilterMatches(new SearchQueryDimFilter("dim3", specForValue(""), null), ImmutableList.<String>of());
    assertFilterMatches(new SearchQueryDimFilter("dim3", specForValue("a"), null), ImmutableList.<String>of());
    assertFilterMatches(new SearchQueryDimFilter("dim3", specForValue("b"), null), ImmutableList.<String>of());
    assertFilterMatches(new SearchQueryDimFilter("dim3", specForValue("c"), null), ImmutableList.<String>of());
}
Also used : SearchQueryDimFilter(io.druid.query.filter.SearchQueryDimFilter) Test(org.junit.Test)

Example 14 with SearchQueryDimFilter

use of io.druid.query.filter.SearchQueryDimFilter in project druid by druid-io.

the class SearchQueryFilterTest method testSingleValueStringColumnWithNulls.

@Test
public void testSingleValueStringColumnWithNulls() {
    // SearchQueryFilter always returns false for null row values.
    assertFilterMatches(new SearchQueryDimFilter("dim1", specForValue(""), null), ImmutableList.of("1", "2", "3", "4", "5"));
    assertFilterMatches(new SearchQueryDimFilter("dim1", specForValue("10"), null), ImmutableList.of("1"));
    assertFilterMatches(new SearchQueryDimFilter("dim1", specForValue("2"), null), ImmutableList.of("2"));
    assertFilterMatches(new SearchQueryDimFilter("dim1", specForValue("1"), null), ImmutableList.of("1", "3"));
    assertFilterMatches(new SearchQueryDimFilter("dim1", specForValue("def"), null), ImmutableList.of("4"));
    assertFilterMatches(new SearchQueryDimFilter("dim1", specForValue("abc"), null), ImmutableList.of("5"));
    assertFilterMatches(new SearchQueryDimFilter("dim1", specForValue("ab"), null), ImmutableList.<String>of("4", "5"));
}
Also used : SearchQueryDimFilter(io.druid.query.filter.SearchQueryDimFilter) Test(org.junit.Test)

Example 15 with SearchQueryDimFilter

use of io.druid.query.filter.SearchQueryDimFilter in project druid by druid-io.

the class IncrementalIndexReadBenchmark method readWithFilters.

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void readWithFilters(Blackhole blackhole) throws Exception {
    DimFilter filter = new OrDimFilter(Arrays.asList(new BoundDimFilter("dimSequential", "-1", "-1", true, true, null, null, StringComparators.ALPHANUMERIC), new JavaScriptDimFilter("dimSequential", "function(x) { return false }", null, JavaScriptConfig.getEnabledInstance()), new RegexDimFilter("dimSequential", "X", null), new SearchQueryDimFilter("dimSequential", new ContainsSearchQuerySpec("X", false), null), new InDimFilter("dimSequential", Arrays.asList("X"), null)));
    IncrementalIndexStorageAdapter sa = new IncrementalIndexStorageAdapter(incIndex);
    Sequence<Cursor> cursors = makeCursors(sa, filter);
    Cursor cursor = Sequences.toList(Sequences.limit(cursors, 1), Lists.<Cursor>newArrayList()).get(0);
    List<DimensionSelector> selectors = new ArrayList<>();
    selectors.add(cursor.makeDimensionSelector(new DefaultDimensionSpec("dimSequential", null)));
    selectors.add(cursor.makeDimensionSelector(new DefaultDimensionSpec("dimZipf", null)));
    selectors.add(cursor.makeDimensionSelector(new DefaultDimensionSpec("dimUniform", null)));
    selectors.add(cursor.makeDimensionSelector(new DefaultDimensionSpec("dimSequentialHalfNull", null)));
    cursor.reset();
    while (!cursor.isDone()) {
        for (DimensionSelector selector : selectors) {
            IndexedInts row = selector.getRow();
            blackhole.consume(selector.lookupName(row.get(0)));
        }
        cursor.advance();
    }
}
Also used : RegexDimFilter(io.druid.query.filter.RegexDimFilter) DimensionSelector(io.druid.segment.DimensionSelector) BoundDimFilter(io.druid.query.filter.BoundDimFilter) ContainsSearchQuerySpec(io.druid.query.search.search.ContainsSearchQuerySpec) ArrayList(java.util.ArrayList) Cursor(io.druid.segment.Cursor) DefaultDimensionSpec(io.druid.query.dimension.DefaultDimensionSpec) IndexedInts(io.druid.segment.data.IndexedInts) OrDimFilter(io.druid.query.filter.OrDimFilter) InDimFilter(io.druid.query.filter.InDimFilter) IncrementalIndexStorageAdapter(io.druid.segment.incremental.IncrementalIndexStorageAdapter) SearchQueryDimFilter(io.druid.query.filter.SearchQueryDimFilter) JavaScriptDimFilter(io.druid.query.filter.JavaScriptDimFilter) JavaScriptDimFilter(io.druid.query.filter.JavaScriptDimFilter) RegexDimFilter(io.druid.query.filter.RegexDimFilter) SearchQueryDimFilter(io.druid.query.filter.SearchQueryDimFilter) BoundDimFilter(io.druid.query.filter.BoundDimFilter) InDimFilter(io.druid.query.filter.InDimFilter) OrDimFilter(io.druid.query.filter.OrDimFilter) DimFilter(io.druid.query.filter.DimFilter) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Aggregations

SearchQueryDimFilter (io.druid.query.filter.SearchQueryDimFilter)18 Test (org.junit.Test)16 BoundDimFilter (io.druid.query.filter.BoundDimFilter)12 JavaScriptDimFilter (io.druid.query.filter.JavaScriptDimFilter)12 RegexDimFilter (io.druid.query.filter.RegexDimFilter)12 ContainsSearchQuerySpec (io.druid.query.search.search.ContainsSearchQuerySpec)12 InDimFilter (io.druid.query.filter.InDimFilter)11 SelectorDimFilter (io.druid.query.filter.SelectorDimFilter)9 ArrayList (java.util.ArrayList)7 LookupExtractionFn (io.druid.query.lookup.LookupExtractionFn)5 MapLookupExtractor (io.druid.query.extraction.MapLookupExtractor)4 OrDimFilter (io.druid.query.filter.OrDimFilter)4 DefaultDimensionSpec (io.druid.query.dimension.DefaultDimensionSpec)3 ExtractionFn (io.druid.query.extraction.ExtractionFn)3 JavaScriptExtractionFn (io.druid.query.extraction.JavaScriptExtractionFn)3 DimFilter (io.druid.query.filter.DimFilter)3 LookupExtractor (io.druid.query.lookup.LookupExtractor)3 HashMap (java.util.HashMap)3 LongSumAggregatorFactory (io.druid.query.aggregation.LongSumAggregatorFactory)2 AndDimFilter (io.druid.query.filter.AndDimFilter)2