richardstartin commented on code in PR #10254: URL: https://github.com/apache/pinot/pull/10254#discussion_r1101868818
########## pinot-core/src/main/java/org/apache/pinot/core/operator/filter/predicate/PredicateUtils.java: ########## @@ -139,10 +143,40 @@ public static IntSet getDictIdSet(BaseInPredicate inPredicate, Dictionary dictio } break; case STRING: - for (String value : values) { - int dictId = dictionary.indexOf(value); - if (dictId >= 0) { - dictIdSet.add(dictId); + if (values.size() > RequestContextUtils.THRESHOLD_OF_LARGE_IN_CLAUSE_VALUES) { + if (bloomFilter != null) { + for (String value : values) { + if (bloomFilter.mightContain(value)) { + int dictId = dictionary.indexOf(value); + if (dictId >= 0) { + dictIdSet.add(dictId); + } + } + } + } else { + int valueIdx = 0; + int dictIdx = 0; + while (valueIdx < values.size() && dictIdx < dictionary.length()) { + String value = values.get(valueIdx); + String dictValue = dictionary.getStringValue(dictIdx); + int compareResult = value.compareTo(dictValue); Review Comment: I think batching in the dictionary should give some nice opportunities to optimise things, control thresholds etc. ```java void getDictIds(List<String> strings, IntConsumer dictIds) { if (strings.size() < SPARSE_THRESHOLD) { for (String string : strings) { int dictId = indexOf(string); if (dictId >= 0) dictIds.acceptInt(dictId); } } else { int i, j = 0; byte[] utf8 = null; boolean needNewUtf8 = true; while (i < strings.size() && j < length()) { if (needNewUtf8) { utf8 = strings.get(i).getBytes(UTF_8); needNewUtf8 = true; } int comparison = _valueReader.compareUtf8Bytes(j, _numBytesPerValue, utf8); if (comparison == 0) { dictIds.acceptInt(j); j++; i++; } else if (comparison < 0) { i++; } else { j++; needNewUtf8 = false; } } } } ... BitSet dictIds = new BitSet(); dictionary.getDictIds(sortedValues, dictIds::add); ``` I think the bloom filter threshold should be managed outside the dictionary, though. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org