mirror of https://github.com/apache/druid.git
Lazy-ify IncrementalIndex filtering too. (#5852)
* Lazy-ify IncrementalIndex filtering too. Follow-up to #5403, which only lazy-ified cursor-based filtering on QueryableIndex. * Fix logic error.
This commit is contained in:
parent
37409dc2f4
commit
3af95913a9
|
@ -52,7 +52,7 @@ public final class DimensionSelectorUtils
|
||||||
if (idLookup != null) {
|
if (idLookup != null) {
|
||||||
return makeDictionaryEncodedValueMatcherGeneric(selector, idLookup.lookupId(value), value == null);
|
return makeDictionaryEncodedValueMatcherGeneric(selector, idLookup.lookupId(value), value == null);
|
||||||
} else if (selector.getValueCardinality() >= 0 && selector.nameLookupPossibleInAdvance()) {
|
} else if (selector.getValueCardinality() >= 0 && selector.nameLookupPossibleInAdvance()) {
|
||||||
// Employ precomputed BitSet optimization
|
// Employ caching BitSet optimization
|
||||||
return makeDictionaryEncodedValueMatcherGeneric(selector, Predicates.equalTo(value));
|
return makeDictionaryEncodedValueMatcherGeneric(selector, Predicates.equalTo(value));
|
||||||
} else {
|
} else {
|
||||||
return makeNonDictionaryEncodedValueMatcherGeneric(selector, value);
|
return makeNonDictionaryEncodedValueMatcherGeneric(selector, value);
|
||||||
|
|
|
@ -496,7 +496,7 @@ public class StringDimensionIndexer implements DimensionIndexer<Integer, int[],
|
||||||
return BooleanValueMatcher.of(false);
|
return BooleanValueMatcher.of(false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Employ precomputed BitSet optimization
|
// Employ caching BitSet optimization
|
||||||
return makeValueMatcher(Predicates.equalTo(value));
|
return makeValueMatcher(Predicates.equalTo(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -504,8 +504,11 @@ public class StringDimensionIndexer implements DimensionIndexer<Integer, int[],
|
||||||
@Override
|
@Override
|
||||||
public ValueMatcher makeValueMatcher(final Predicate<String> predicate)
|
public ValueMatcher makeValueMatcher(final Predicate<String> 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);
|
final boolean matchNull = predicate.apply(null);
|
||||||
|
|
||||||
|
// Lazy matcher; only check an id if matches() is called.
|
||||||
return new ValueMatcher()
|
return new ValueMatcher()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
@ -522,9 +525,18 @@ public class StringDimensionIndexer implements DimensionIndexer<Integer, int[],
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int id : dimsInt) {
|
for (int id : dimsInt) {
|
||||||
if (predicateMatchingValueIds.get(id)) {
|
if (checkedIds.get(id)) {
|
||||||
|
if (matchingIds.get(id)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
final boolean matches = predicate.apply(lookupName(id));
|
||||||
|
checkedIds.set(id);
|
||||||
|
if (matches) {
|
||||||
|
matchingIds.set(id);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,7 +259,7 @@ public class SimpleDictionaryEncodedColumn implements DictionaryEncodedColumn<St
|
||||||
return BooleanValueMatcher.of(false);
|
return BooleanValueMatcher.of(false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Employ precomputed BitSet optimization
|
// Employ caching BitSet optimization
|
||||||
return makeValueMatcher(Predicates.equalTo(value));
|
return makeValueMatcher(Predicates.equalTo(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue