diff --git a/processing/src/main/java/io/druid/segment/DimensionSelectorUtils.java b/processing/src/main/java/io/druid/segment/DimensionSelectorUtils.java index 092675c8551..b1df53cd904 100644 --- a/processing/src/main/java/io/druid/segment/DimensionSelectorUtils.java +++ b/processing/src/main/java/io/druid/segment/DimensionSelectorUtils.java @@ -52,7 +52,7 @@ public final class DimensionSelectorUtils if (idLookup != null) { return makeDictionaryEncodedValueMatcherGeneric(selector, idLookup.lookupId(value), value == null); } else if (selector.getValueCardinality() >= 0 && selector.nameLookupPossibleInAdvance()) { - // Employ precomputed BitSet optimization + // Employ caching BitSet optimization return makeDictionaryEncodedValueMatcherGeneric(selector, Predicates.equalTo(value)); } else { return makeNonDictionaryEncodedValueMatcherGeneric(selector, value); diff --git a/processing/src/main/java/io/druid/segment/StringDimensionIndexer.java b/processing/src/main/java/io/druid/segment/StringDimensionIndexer.java index df28aa43f2e..e36b223731f 100644 --- a/processing/src/main/java/io/druid/segment/StringDimensionIndexer.java +++ b/processing/src/main/java/io/druid/segment/StringDimensionIndexer.java @@ -177,7 +177,7 @@ public class StringDimensionIndexer implements DimensionIndexer predicate) { - final BitSet predicateMatchingValueIds = DimensionSelectorUtils.makePredicateMatchingSet(this, predicate); + final BitSet checkedIds = new BitSet(maxId); + final BitSet matchingIds = new BitSet(maxId); final boolean matchNull = predicate.apply(null); + + // Lazy matcher; only check an id if matches() is called. return new ValueMatcher() { @Override @@ -522,8 +525,17 @@ public class StringDimensionIndexer implements DimensionIndexer