mirror of
https://github.com/apache/druid.git
synced 2025-02-17 07:25:02 +00:00
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) {
|
||||
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);
|
||||
|
@ -496,7 +496,7 @@ public class StringDimensionIndexer implements DimensionIndexer<Integer, int[],
|
||||
return BooleanValueMatcher.of(false);
|
||||
}
|
||||
} else {
|
||||
// Employ precomputed BitSet optimization
|
||||
// Employ caching BitSet optimization
|
||||
return makeValueMatcher(Predicates.equalTo(value));
|
||||
}
|
||||
}
|
||||
@ -504,8 +504,11 @@ public class StringDimensionIndexer implements DimensionIndexer<Integer, int[],
|
||||
@Override
|
||||
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);
|
||||
|
||||
// Lazy matcher; only check an id if matches() is called.
|
||||
return new ValueMatcher()
|
||||
{
|
||||
@Override
|
||||
@ -522,9 +525,18 @@ public class StringDimensionIndexer implements DimensionIndexer<Integer, int[],
|
||||
}
|
||||
|
||||
for (int id : dimsInt) {
|
||||
if (predicateMatchingValueIds.get(id)) {
|
||||
if (checkedIds.get(id)) {
|
||||
if (matchingIds.get(id)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
final boolean matches = predicate.apply(lookupName(id));
|
||||
checkedIds.set(id);
|
||||
if (matches) {
|
||||
matchingIds.set(id);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ public class SimpleDictionaryEncodedColumn implements DictionaryEncodedColumn<St
|
||||
return BooleanValueMatcher.of(false);
|
||||
}
|
||||
} else {
|
||||
// Employ precomputed BitSet optimization
|
||||
// Employ caching BitSet optimization
|
||||
return makeValueMatcher(Predicates.equalTo(value));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user