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) {
|
||||
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);
|
||||
|
|
|
@ -177,7 +177,7 @@ public class StringDimensionIndexer implements DimensionIndexer<Integer, int[],
|
|||
this.idToIndex = new int[length];
|
||||
this.indexToId = new int[length];
|
||||
int index = 0;
|
||||
for (IntIterator iterator = sortedMap.values().iterator(); iterator.hasNext();) {
|
||||
for (IntIterator iterator = sortedMap.values().iterator(); iterator.hasNext(); ) {
|
||||
int id = iterator.nextInt();
|
||||
idToIndex[id] = index;
|
||||
indexToId[index] = id;
|
||||
|
@ -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…
Reference in New Issue