Skip to content

Commit

Permalink
DimFilterUtils: Exit filterShards early when filter is null. (apache#…
Browse files Browse the repository at this point in the history
…16774)

When the filter is null, there is no need to run the converter on
all the input objects.
  • Loading branch information
gianm authored Jul 23, 2024
1 parent b645d09 commit 8b8ca0d
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.apache.druid.query.filter;

import com.google.common.base.Function;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.RangeSet;
import org.apache.druid.query.planning.DataSourceAnalysis;
import org.apache.druid.timeline.partition.ShardSpec;
Expand Down Expand Up @@ -116,13 +117,19 @@ public static <T> Set<T> filterShards(
final Map<String, Optional<RangeSet<String>>> dimensionRangeCache
)
{
if (dimFilter == null) {
// ImmutableSet retains order from "input".
return ImmutableSet.copyOf(input);
}

// LinkedHashSet retains order from "input".
Set<T> retSet = new LinkedHashSet<>();

for (T obj : input) {
ShardSpec shard = converter.apply(obj);
boolean include = true;

if (dimFilter != null && shard != null) {
if (shard != null) {
Map<String, RangeSet<String>> filterDomain = new HashMap<>();
List<String> dimensions = shard.getDomainDimensions();
for (String dimension : dimensions) {
Expand Down

0 comments on commit 8b8ca0d

Please sign in to comment.