Search in sources :

Example 11 with AndFilter

use of org.apache.druid.segment.filter.AndFilter in project druid by druid-io.

the class JoinFilterAnalyzerTest method test_filterPushDown_factConcatExpressionToCountryLeftFilterOnChannelAndCountryName.

@Test
public void test_filterPushDown_factConcatExpressionToCountryLeftFilterOnChannelAndCountryName() {
    JoinableClause factExprToCountry = new JoinableClause(FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX, new IndexedTableJoinable(countriesTable), JoinType.LEFT, JoinConditionAnalysis.forExpression(StringUtils.format("\"%scountryIsoCode\" == concat(countryIsoCode, regionIsoCode)", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX), FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX, ExprMacroTable.nil()));
    List<JoinableClause> joinableClauses = ImmutableList.of(factExprToCountry);
    Filter filter = new AndFilter(ImmutableList.of(new SelectorFilter("channel", "#en.wikipedia"), new SelectorFilter("c1.countryName", "Usca")));
    JoinFilterPreAnalysis joinFilterPreAnalysis = makeDefaultConfigPreAnalysis(filter, joinableClauses, VirtualColumns.EMPTY);
    HashJoinSegmentStorageAdapter adapter = new HashJoinSegmentStorageAdapter(factSegment.asStorageAdapter(), joinableClauses, joinFilterPreAnalysis);
    JoinTestHelper.verifyCursors(adapter.makeCursors(filter, Intervals.ETERNITY, VirtualColumns.EMPTY, Granularities.ALL, false, null), ImmutableList.of("page", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "countryName"), ImmutableList.of(new Object[] { "President of India", "Usca" }, new Object[] { "Otjiwarongo Airport", "Usca" }, new Object[] { "Carlo Curti", "Usca" }));
    ExpressionVirtualColumn expectedVirtualColumn = new ExpressionVirtualColumn("JOIN-FILTER-PUSHDOWN-VIRTUAL-COLUMN-0", "concat(countryIsoCode, regionIsoCode)", ColumnType.STRING, ExprMacroTable.nil());
    JoinFilterSplit expectedFilterSplit = new JoinFilterSplit(new AndFilter(ImmutableList.of(new SelectorFilter("channel", "#en.wikipedia"), new InDimFilter("JOIN-FILTER-PUSHDOWN-VIRTUAL-COLUMN-0", ImmutableSet.of("USCA"), null, null).toFilter())), new SelectorFilter("c1.countryName", "Usca"), ImmutableSet.of(expectedVirtualColumn));
    JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis);
    Assert.assertEquals(expectedFilterSplit.getBaseTableFilter(), actualFilterSplit.getBaseTableFilter());
    Assert.assertEquals(expectedFilterSplit.getJoinTableFilter(), actualFilterSplit.getJoinTableFilter());
    ExpressionVirtualColumn actualVirtualColumn = (ExpressionVirtualColumn) actualFilterSplit.getPushDownVirtualColumns().iterator().next();
    compareExpressionVirtualColumns(expectedVirtualColumn, actualVirtualColumn);
}
Also used : AndFilter(org.apache.druid.segment.filter.AndFilter) SelectorFilter(org.apache.druid.segment.filter.SelectorFilter) ExpressionVirtualColumn(org.apache.druid.segment.virtual.ExpressionVirtualColumn) JoinFilterPreAnalysis(org.apache.druid.segment.join.filter.JoinFilterPreAnalysis) FalseFilter(org.apache.druid.segment.filter.FalseFilter) OrFilter(org.apache.druid.segment.filter.OrFilter) BoundDimFilter(org.apache.druid.query.filter.BoundDimFilter) SelectorFilter(org.apache.druid.segment.filter.SelectorFilter) AndFilter(org.apache.druid.segment.filter.AndFilter) BoundFilter(org.apache.druid.segment.filter.BoundFilter) InDimFilter(org.apache.druid.query.filter.InDimFilter) ExpressionDimFilter(org.apache.druid.query.filter.ExpressionDimFilter) Filter(org.apache.druid.query.filter.Filter) JoinFilterSplit(org.apache.druid.segment.join.filter.JoinFilterSplit) IndexedTableJoinable(org.apache.druid.segment.join.table.IndexedTableJoinable) InDimFilter(org.apache.druid.query.filter.InDimFilter) Test(org.junit.Test)

Example 12 with AndFilter

use of org.apache.druid.segment.filter.AndFilter in project druid by druid-io.

the class JoinFilterAnalyzerTest method test_filterPushDown_factToCountryFullWithFilterOnNullsUsingLookup.

@Test
public void test_filterPushDown_factToCountryFullWithFilterOnNullsUsingLookup() {
    List<JoinableClause> joinableClauses = ImmutableList.of(factToCountryNameUsingIsoCodeLookup(JoinType.FULL));
    Filter originalFilter = new AndFilter(ImmutableList.of(new SelectorFilter("channel", null), new SelectorFilter(FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "v", null)));
    JoinFilterPreAnalysis joinFilterPreAnalysis = makeDefaultConfigPreAnalysis(originalFilter, joinableClauses, VirtualColumns.EMPTY);
    HashJoinSegmentStorageAdapter adapter = new HashJoinSegmentStorageAdapter(factSegment.asStorageAdapter(), joinableClauses, joinFilterPreAnalysis);
    JoinTestHelper.verifyCursors(adapter.makeCursors(originalFilter, Intervals.ETERNITY, VirtualColumns.EMPTY, Granularities.ALL, false, null), ImmutableList.of("page", "countryIsoCode", "countryNumber", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "k", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "v"), ImmutableList.of());
    JoinFilterSplit expectedFilterSplit = new JoinFilterSplit(null, new AndFilter(ImmutableList.of(new SelectorFilter("channel", null), new SelectorFilter(FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "v", null))), ImmutableSet.of());
    JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis);
    Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
}
Also used : AndFilter(org.apache.druid.segment.filter.AndFilter) SelectorFilter(org.apache.druid.segment.filter.SelectorFilter) JoinFilterPreAnalysis(org.apache.druid.segment.join.filter.JoinFilterPreAnalysis) FalseFilter(org.apache.druid.segment.filter.FalseFilter) OrFilter(org.apache.druid.segment.filter.OrFilter) BoundDimFilter(org.apache.druid.query.filter.BoundDimFilter) SelectorFilter(org.apache.druid.segment.filter.SelectorFilter) AndFilter(org.apache.druid.segment.filter.AndFilter) BoundFilter(org.apache.druid.segment.filter.BoundFilter) InDimFilter(org.apache.druid.query.filter.InDimFilter) ExpressionDimFilter(org.apache.druid.query.filter.ExpressionDimFilter) Filter(org.apache.druid.query.filter.Filter) JoinFilterSplit(org.apache.druid.segment.join.filter.JoinFilterSplit) Test(org.junit.Test)

Example 13 with AndFilter

use of org.apache.druid.segment.filter.AndFilter in project druid by druid-io.

the class JoinFilterAnalyzerTest method test_filterPushDown_factToCountryRightWithFilterOnNullColumnsUsingLookup.

@Test
public void test_filterPushDown_factToCountryRightWithFilterOnNullColumnsUsingLookup() {
    List<JoinableClause> joinableClauses = ImmutableList.of(factToCountryNameUsingIsoCodeLookup(JoinType.RIGHT));
    Filter originalFilter = new AndFilter(ImmutableList.of(new SelectorFilter("channel", null), new SelectorFilter(FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "v", null)));
    JoinFilterPreAnalysis joinFilterPreAnalysis = makeDefaultConfigPreAnalysis(originalFilter, joinableClauses, VirtualColumns.EMPTY);
    HashJoinSegmentStorageAdapter adapter = new HashJoinSegmentStorageAdapter(factSegment.asStorageAdapter(), joinableClauses, joinFilterPreAnalysis);
    JoinTestHelper.verifyCursors(adapter.makeCursors(originalFilter, Intervals.ETERNITY, VirtualColumns.EMPTY, Granularities.ALL, false, null), ImmutableList.of("page", "countryIsoCode", "countryNumber", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "k", FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "v"), ImmutableList.of());
    JoinFilterSplit expectedFilterSplit = new JoinFilterSplit(null, new AndFilter(ImmutableList.of(new SelectorFilter("channel", null), new SelectorFilter(FACT_TO_COUNTRY_ON_ISO_CODE_PREFIX + "v", null))), ImmutableSet.of());
    JoinFilterSplit actualFilterSplit = JoinFilterAnalyzer.splitFilter(joinFilterPreAnalysis);
    Assert.assertEquals(expectedFilterSplit, actualFilterSplit);
}
Also used : AndFilter(org.apache.druid.segment.filter.AndFilter) SelectorFilter(org.apache.druid.segment.filter.SelectorFilter) JoinFilterPreAnalysis(org.apache.druid.segment.join.filter.JoinFilterPreAnalysis) FalseFilter(org.apache.druid.segment.filter.FalseFilter) OrFilter(org.apache.druid.segment.filter.OrFilter) BoundDimFilter(org.apache.druid.query.filter.BoundDimFilter) SelectorFilter(org.apache.druid.segment.filter.SelectorFilter) AndFilter(org.apache.druid.segment.filter.AndFilter) BoundFilter(org.apache.druid.segment.filter.BoundFilter) InDimFilter(org.apache.druid.query.filter.InDimFilter) ExpressionDimFilter(org.apache.druid.query.filter.ExpressionDimFilter) Filter(org.apache.druid.query.filter.Filter) JoinFilterSplit(org.apache.druid.segment.join.filter.JoinFilterSplit) Test(org.junit.Test)

Example 14 with AndFilter

use of org.apache.druid.segment.filter.AndFilter in project druid by druid-io.

the class FilterPartitionBenchmark method readAndFilter.

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void readAndFilter(Blackhole blackhole) {
    Filter andFilter = new AndFilter(ImmutableList.of(new SelectorFilter("dimUniform", "199"), new NoBitmapSelectorDimFilter("dimUniform", "super-199", JS_EXTRACTION_FN).toFilter()));
    StorageAdapter sa = new QueryableIndexStorageAdapter(qIndex);
    Sequence<Cursor> cursors = makeCursors(sa, andFilter);
    readCursors(cursors, blackhole);
}
Also used : AndFilter(org.apache.druid.segment.filter.AndFilter) SelectorFilter(org.apache.druid.segment.filter.SelectorFilter) DimensionPredicateFilter(org.apache.druid.segment.filter.DimensionPredicateFilter) SelectorDimFilter(org.apache.druid.query.filter.SelectorDimFilter) OrFilter(org.apache.druid.segment.filter.OrFilter) AndDimFilter(org.apache.druid.query.filter.AndDimFilter) SelectorFilter(org.apache.druid.segment.filter.SelectorFilter) DimFilter(org.apache.druid.query.filter.DimFilter) BoundFilter(org.apache.druid.segment.filter.BoundFilter) BoundDimFilter(org.apache.druid.query.filter.BoundDimFilter) AndFilter(org.apache.druid.segment.filter.AndFilter) OrDimFilter(org.apache.druid.query.filter.OrDimFilter) Filter(org.apache.druid.query.filter.Filter) StorageAdapter(org.apache.druid.segment.StorageAdapter) QueryableIndexStorageAdapter(org.apache.druid.segment.QueryableIndexStorageAdapter) QueryableIndexStorageAdapter(org.apache.druid.segment.QueryableIndexStorageAdapter) Cursor(org.apache.druid.segment.Cursor) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Example 15 with AndFilter

use of org.apache.druid.segment.filter.AndFilter in project druid by druid-io.

the class FilterPartitionBenchmark method readOrFilterCNF.

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void readOrFilterCNF(Blackhole blackhole) {
    Filter filter = new NoBitmapSelectorFilter("dimSequential", "199");
    Filter filter2 = new AndFilter(Arrays.asList(new SelectorFilter("dimMultivalEnumerated2", "Corundum"), new NoBitmapSelectorFilter("dimMultivalEnumerated", "Bar")));
    Filter orFilter = new OrFilter(Arrays.asList(filter, filter2));
    StorageAdapter sa = new QueryableIndexStorageAdapter(qIndex);
    Sequence<Cursor> cursors = makeCursors(sa, Filters.toCnf(orFilter));
    readCursors(cursors, blackhole);
}
Also used : AndFilter(org.apache.druid.segment.filter.AndFilter) SelectorFilter(org.apache.druid.segment.filter.SelectorFilter) DimensionPredicateFilter(org.apache.druid.segment.filter.DimensionPredicateFilter) SelectorDimFilter(org.apache.druid.query.filter.SelectorDimFilter) OrFilter(org.apache.druid.segment.filter.OrFilter) AndDimFilter(org.apache.druid.query.filter.AndDimFilter) SelectorFilter(org.apache.druid.segment.filter.SelectorFilter) DimFilter(org.apache.druid.query.filter.DimFilter) BoundFilter(org.apache.druid.segment.filter.BoundFilter) BoundDimFilter(org.apache.druid.query.filter.BoundDimFilter) AndFilter(org.apache.druid.segment.filter.AndFilter) OrDimFilter(org.apache.druid.query.filter.OrDimFilter) Filter(org.apache.druid.query.filter.Filter) StorageAdapter(org.apache.druid.segment.StorageAdapter) QueryableIndexStorageAdapter(org.apache.druid.segment.QueryableIndexStorageAdapter) QueryableIndexStorageAdapter(org.apache.druid.segment.QueryableIndexStorageAdapter) OrFilter(org.apache.druid.segment.filter.OrFilter) Cursor(org.apache.druid.segment.Cursor) BenchmarkMode(org.openjdk.jmh.annotations.BenchmarkMode) Benchmark(org.openjdk.jmh.annotations.Benchmark) OutputTimeUnit(org.openjdk.jmh.annotations.OutputTimeUnit)

Aggregations

Filter (org.apache.druid.query.filter.Filter)34 AndFilter (org.apache.druid.segment.filter.AndFilter)34 OrFilter (org.apache.druid.segment.filter.OrFilter)33 BoundDimFilter (org.apache.druid.query.filter.BoundDimFilter)30 BoundFilter (org.apache.druid.segment.filter.BoundFilter)30 SelectorFilter (org.apache.druid.segment.filter.SelectorFilter)30 ExpressionDimFilter (org.apache.druid.query.filter.ExpressionDimFilter)27 InDimFilter (org.apache.druid.query.filter.InDimFilter)27 FalseFilter (org.apache.druid.segment.filter.FalseFilter)27 JoinFilterPreAnalysis (org.apache.druid.segment.join.filter.JoinFilterPreAnalysis)27 JoinFilterSplit (org.apache.druid.segment.join.filter.JoinFilterSplit)26 Test (org.junit.Test)26 IndexedTableJoinable (org.apache.druid.segment.join.table.IndexedTableJoinable)5 ExpressionVirtualColumn (org.apache.druid.segment.virtual.ExpressionVirtualColumn)5 ArrayList (java.util.ArrayList)4 AndDimFilter (org.apache.druid.query.filter.AndDimFilter)3 BooleanFilter (org.apache.druid.query.filter.BooleanFilter)3 DimFilter (org.apache.druid.query.filter.DimFilter)3 OrDimFilter (org.apache.druid.query.filter.OrDimFilter)3 SelectorDimFilter (org.apache.druid.query.filter.SelectorDimFilter)3