Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static ValueMatcher makeValueMatcherGeneric(DimensionSelector selector, S
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public SortedDimensionDictionary(List<String> idToValue, int length)
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;
Expand Down Expand Up @@ -496,16 +496,19 @@ public void inspectRuntimeShape(RuntimeShapeInspector inspector)
return BooleanValueMatcher.of(false);
}
} else {
// Employ precomputed BitSet optimization
// Employ caching BitSet optimization
return makeValueMatcher(Predicates.equalTo(value));
}
}

@Override
public ValueMatcher makeValueMatcher(final Predicate<String> predicate)
{
final BitSet predicateMatchingValueIds = DimensionSelectorUtils.makePredicateMatchingSet(this, predicate);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is DimensionSelectorUtils.makePredicateMatchingSet() still used or could be deleted?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's still used in one place: ForwardingFilteredDimensionSpec. I would like to rewrite that code to be lazy in a follow up PR, and delete DimensionSelectorUtils.makePredicateMatchingSet at that time. I didn't do it in this patch since I wanted to keep it small.

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
Expand All @@ -522,8 +525,17 @@ public boolean matches()
}

for (int id : dimsInt) {
if (predicateMatchingValueIds.get(id)) {
return true;
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public void inspectRuntimeShape(RuntimeShapeInspector inspector)
return BooleanValueMatcher.of(false);
}
} else {
// Employ precomputed BitSet optimization
// Employ caching BitSet optimization
return makeValueMatcher(Predicates.equalTo(value));
}
}
Expand Down