diff --git a/processing/src/test/java/io/druid/segment/filter/BaseFilterTest.java b/processing/src/test/java/io/druid/segment/filter/BaseFilterTest.java index 1d4f7ee5c06..a6307342ae1 100644 --- a/processing/src/test/java/io/druid/segment/filter/BaseFilterTest.java +++ b/processing/src/test/java/io/druid/segment/filter/BaseFilterTest.java @@ -21,6 +21,7 @@ package io.druid.segment.filter; import com.google.common.base.Function; import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; @@ -75,16 +76,19 @@ public abstract class BaseFilterTest protected final Function> finisher; protected StorageAdapter adapter; protected Closeable closeable; + protected boolean optimize; public BaseFilterTest( List rows, IndexBuilder indexBuilder, - Function> finisher + Function> finisher, + boolean optimize ) { this.rows = rows; this.indexBuilder = indexBuilder; this.finisher = finisher; + this.optimize = optimize; } @Before @@ -186,21 +190,24 @@ public abstract class BaseFilterTest for (Map.Entry bitmapSerdeFactoryEntry : bitmapSerdeFactories.entrySet()) { for (Map.Entry indexMergerEntry : indexMergers.entrySet()) { for (Map.Entry>> finisherEntry : finishers.entrySet()) { - final String testName = String.format( - "bitmaps[%s], indexMerger[%s], finisher[%s]", - bitmapSerdeFactoryEntry.getKey(), - indexMergerEntry.getKey(), - finisherEntry.getKey() - ); - final IndexBuilder indexBuilder = IndexBuilder.create() - .indexSpec(new IndexSpec( - bitmapSerdeFactoryEntry.getValue(), - null, - null - )) - .indexMerger(indexMergerEntry.getValue()); + for (boolean optimize : ImmutableList.of(false, true)) { + final String testName = String.format( + "bitmaps[%s], indexMerger[%s], finisher[%s], optimize[%s]", + bitmapSerdeFactoryEntry.getKey(), + indexMergerEntry.getKey(), + finisherEntry.getKey(), + optimize + ); + final IndexBuilder indexBuilder = IndexBuilder.create() + .indexSpec(new IndexSpec( + bitmapSerdeFactoryEntry.getValue(), + null, + null + )) + .indexMerger(indexMergerEntry.getValue()); - constructors.add(new Object[]{testName, indexBuilder, finisherEntry.getValue()}); + constructors.add(new Object[]{testName, indexBuilder, finisherEntry.getValue(), optimize}); + } } } } @@ -213,7 +220,7 @@ public abstract class BaseFilterTest */ protected List selectColumnValuesMatchingFilter(final DimFilter filter, final String selectColumn) { - final Cursor cursor = makeCursor(Filters.toFilter(filter)); + final Cursor cursor = makeCursor(Filters.toFilter(maybeOptimize(filter))); final List values = Lists.newArrayList(); final DimensionSelector selector = cursor.makeDimensionSelector( new DefaultDimensionSpec(selectColumn, selectColumn) @@ -233,7 +240,7 @@ public abstract class BaseFilterTest final Cursor cursor = makeCursor(null); final Aggregator agg = new FilteredAggregatorFactory( new CountAggregatorFactory("count"), - filter + maybeOptimize(filter) ).factorize(cursor); for (; !cursor.isDone(); cursor.advance()) { @@ -243,6 +250,14 @@ public abstract class BaseFilterTest return agg.getLong(); } + private DimFilter maybeOptimize(final DimFilter dimFilter) + { + if (dimFilter == null) { + return null; + } + return optimize ? dimFilter.optimize() : dimFilter; + } + private Cursor makeCursor(final Filter filter) { final Sequence cursors = adapter.makeCursors( diff --git a/processing/src/test/java/io/druid/segment/filter/BoundFilterTest.java b/processing/src/test/java/io/druid/segment/filter/BoundFilterTest.java index 98dcd9520bf..61dc4145989 100644 --- a/processing/src/test/java/io/druid/segment/filter/BoundFilterTest.java +++ b/processing/src/test/java/io/druid/segment/filter/BoundFilterTest.java @@ -67,10 +67,11 @@ public class BoundFilterTest extends BaseFilterTest public BoundFilterTest( String testName, IndexBuilder indexBuilder, - Function> finisher + Function> finisher, + boolean optimize ) { - super(ROWS, indexBuilder, finisher); + super(ROWS, indexBuilder, finisher, optimize); } @Test diff --git a/processing/src/test/java/io/druid/segment/filter/InFilterTest.java b/processing/src/test/java/io/druid/segment/filter/InFilterTest.java index 99e0d99d0fc..852cfe7ece5 100644 --- a/processing/src/test/java/io/druid/segment/filter/InFilterTest.java +++ b/processing/src/test/java/io/druid/segment/filter/InFilterTest.java @@ -80,10 +80,11 @@ public class InFilterTest extends BaseFilterTest public InFilterTest( String testName, IndexBuilder indexBuilder, - Function> finisher + Function> finisher, + boolean optimize ) { - super(ROWS, indexBuilder, finisher); + super(ROWS, indexBuilder, finisher, optimize); } @Before diff --git a/processing/src/test/java/io/druid/segment/filter/NotFilterTest.java b/processing/src/test/java/io/druid/segment/filter/NotFilterTest.java index 212bf51a4ab..a919449c80d 100644 --- a/processing/src/test/java/io/druid/segment/filter/NotFilterTest.java +++ b/processing/src/test/java/io/druid/segment/filter/NotFilterTest.java @@ -68,10 +68,11 @@ public class NotFilterTest extends BaseFilterTest public NotFilterTest( String testName, IndexBuilder indexBuilder, - Function> finisher + Function> finisher, + boolean optimize ) { - super(ROWS, indexBuilder, finisher); + super(ROWS, indexBuilder, finisher, optimize); } @Test diff --git a/processing/src/test/java/io/druid/segment/filter/SelectorFilterTest.java b/processing/src/test/java/io/druid/segment/filter/SelectorFilterTest.java index 0fa88dd0a93..8dcbdb4f3ee 100644 --- a/processing/src/test/java/io/druid/segment/filter/SelectorFilterTest.java +++ b/processing/src/test/java/io/druid/segment/filter/SelectorFilterTest.java @@ -71,10 +71,11 @@ public class SelectorFilterTest extends BaseFilterTest public SelectorFilterTest( String testName, IndexBuilder indexBuilder, - Function> finisher + Function> finisher, + boolean optimize ) { - super(ROWS, indexBuilder, finisher); + super(ROWS, indexBuilder, finisher, optimize); } @Test