use of org.apache.druid.query.lookup.LookupExtractionFn in project druid by druid-io.
the class InDimFilter method optimizeLookup.
private InDimFilter optimizeLookup() {
if (extractionFn instanceof LookupExtractionFn && ((LookupExtractionFn) extractionFn).isOptimize()) {
LookupExtractionFn exFn = (LookupExtractionFn) extractionFn;
LookupExtractor lookup = exFn.getLookup();
final Set<String> keys = new HashSet<>();
for (String value : values) {
// We cannot do an unapply()-based optimization if the selector value
// and the replaceMissingValuesWith value are the same, since we have to match on
// all values that are not present in the lookup.
final String convertedValue = NullHandling.emptyToNullIfNeeded(value);
if (!exFn.isRetainMissingValue() && Objects.equals(convertedValue, exFn.getReplaceMissingValueWith())) {
return this;
}
keys.addAll(lookup.unapply(convertedValue));
// If the selector value is overwritten in the lookup map, don't add selector value to keys.
if (exFn.isRetainMissingValue() && NullHandling.isNullOrEquivalent(lookup.apply(convertedValue))) {
keys.add(convertedValue);
}
}
if (keys.isEmpty()) {
return this;
} else {
return new InDimFilter(dimension, keys, null, filterTuning);
}
}
return this;
}
Aggregations