Skip to content

Commit

Permalink
fix rangeSet intersect in PartitionPredicateToRange
Browse files Browse the repository at this point in the history
  • Loading branch information
feiniaofeiafei committed Dec 27, 2024
1 parent 8e09e1b commit 16b75c6
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,7 @@ public RangeSet<MultiColumnBound> visitAnd(And and, Void context) {
intersects = childRanges;
continue;
}

for (Range<MultiColumnBound> childRange : childRanges.asRanges()) {
intersects = intersects.subRangeSet(childRange);
if (intersects.isEmpty()) {
break;
}
}
intersects = intersection(childRanges, intersects);
if (intersects.isEmpty()) {
break;
}
Expand Down Expand Up @@ -264,4 +258,12 @@ private RangeSet<MultiColumnBound> toRangeSet(SlotReference slotReference,
Range<MultiColumnBound> range = Range.range(lowerBound, lowerBoundType, upperBound, upperBoundType);
return ImmutableRangeSet.of(range);
}

public static <T extends Comparable<?>> RangeSet<T> intersection(RangeSet<T> rangeSet1, RangeSet<T> rangeSet2) {
RangeSet<T> result = TreeRangeSet.create();
for (Range<T> range : rangeSet1.asRanges()) {
result.addAll(rangeSet2.subRangeSet(range));
}
return result;
}
}

0 comments on commit 16b75c6

Please sign in to comment.