Skip to content

Commit

Permalink
Return false when datatype is not comparable for InFilter.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sh-Zh-7 authored Jul 23, 2024
1 parent 1dbcdef commit b81f754
Showing 1 changed file with 31 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -790,19 +790,22 @@ public boolean canSkip(IMetadata metadata) {
}

if (statistics.isPresent()) {
T valuesMin = (T) statistics.get().getMinValue();
T valuesMax = (T) statistics.get().getMaxValue();
// All values are same
if (valuesMin.compareTo(valuesMax) == 0) {
return !candidates.contains(valuesMin);
} else {
if (candidates.size() != 0) {
// All values are less than min, or greater than max
if (candidatesMin.compareTo(valuesMax) > 0) {
return true;
}
if (candidatesMax.compareTo(valuesMin) < 0) {
return true;
Statistics<? extends Serializable> stat = statistics.get();
if (!statisticsNotAvailable(stat)) {
T valuesMin = (T) stat.getMinValue();
T valuesMax = (T) stat.getMaxValue();
// All values are same
if (valuesMin.compareTo(valuesMax) == 0) {
return !candidates.contains(valuesMin);
} else {
if (candidates.size() != 0) {
// All values are less than min, or greater than max
if (candidatesMin.compareTo(valuesMax) > 0) {
return true;
}
if (candidatesMax.compareTo(valuesMin) < 0) {
return true;
}
}
}
}
Expand All @@ -829,11 +832,14 @@ public boolean allSatisfy(IMetadata metadata) {

// All values are same
if (statistics.isPresent()) {
T valuesMin = (T) statistics.get().getMinValue();
T valuesMax = (T) statistics.get().getMaxValue();
// All values are same
if (valuesMin.compareTo(valuesMax) == 0) {
return candidates.contains(valuesMin);
Statistics<? extends Serializable> stat = statistics.get();
if (!statisticsNotAvailable(stat)) {
T valuesMin = (T) stat.getMinValue();
T valuesMax = (T) stat.getMaxValue();
// All values are same
if (valuesMin.compareTo(valuesMax) == 0) {
return candidates.contains(valuesMin);
}
}
}

Expand All @@ -858,6 +864,13 @@ public OperatorType getOperatorType() {
private boolean isAllNulls(Statistics<? extends Serializable> statistics) {
return statistics.getCount() == 0;
}

private static boolean statisticsNotAvailable(Statistics<?> statistics) {
return statistics.getType() == TSDataType.TEXT
|| statistics.getType() == TSDataType.BOOLEAN
|| statistics.getType() == TSDataType.BLOB
|| statistics.isEmpty();
}
}

public static final class ValueNotIn<T extends Comparable<T>> extends ValueColumnSetFilter<T> {
Expand Down

0 comments on commit b81f754

Please sign in to comment.