public Type getType() { return values.getType(); }
private SortedRangeSet checkCompatibility(ValueSet other) { if (!getType().equals(other.getType())) { throw new IllegalStateException(String.format("Mismatched types: %s vs %s", getType(), other.getType())); } if (!(other instanceof SortedRangeSet)) { throw new IllegalStateException(String.format("ValueSet is not a SortedRangeSet: %s", other.getClass())); } return (SortedRangeSet) other; }
private EquatableValueSet checkCompatibility(ValueSet other) { if (!getType().equals(other.getType())) { throw new IllegalStateException(String.format("Mismatched types: %s vs %s", getType(), other.getType())); } if (!(other instanceof EquatableValueSet)) { throw new IllegalStateException(String.format("ValueSet is not a EquatableValueSet: %s", other.getClass())); } return (EquatableValueSet) other; }
private AllOrNoneValueSet checkCompatibility(ValueSet other) { if (!getType().equals(other.getType())) { throw new IllegalArgumentException(String.format("Mismatched types: %s vs %s", getType(), other.getType())); } if (!(other instanceof AllOrNoneValueSet)) { throw new IllegalArgumentException(String.format("ValueSet is not a AllOrNoneValueSet: %s", other.getClass())); } return (AllOrNoneValueSet) other; } }
private static TupleDomain<HiveColumnHandle> toCompactTupleDomain(TupleDomain<ColumnHandle> effectivePredicate, int threshold) { ImmutableMap.Builder<HiveColumnHandle, Domain> builder = ImmutableMap.builder(); effectivePredicate.getDomains().ifPresent(domains -> { for (Map.Entry<ColumnHandle, Domain> entry : domains.entrySet()) { HiveColumnHandle hiveColumnHandle = (HiveColumnHandle) entry.getKey(); ValueSet values = entry.getValue().getValues(); ValueSet compactValueSet = values.getValuesProcessor().<Optional<ValueSet>>transform( ranges -> ranges.getRangeCount() > threshold ? Optional.of(ValueSet.ofRanges(ranges.getSpan())) : Optional.empty(), discreteValues -> discreteValues.getValues().size() > threshold ? Optional.of(ValueSet.all(values.getType())) : Optional.empty(), allOrNone -> Optional.empty()) .orElse(values); builder.put(hiveColumnHandle, Domain.create(compactValueSet, entry.getValue().isNullAllowed())); } }); return TupleDomain.withColumnDomains(builder.build()); }
/** * Reduces the number of discrete components in the Domain if there are too many. */ public Domain simplify() { ValueSet simplifiedValueSet = values.getValuesProcessor().<Optional<ValueSet>>transform( ranges -> { if (ranges.getOrderedRanges().size() <= 32) { return Optional.empty(); } return Optional.of(ValueSet.ofRanges(ranges.getSpan())); }, discreteValues -> { if (discreteValues.getValues().size() <= 32) { return Optional.empty(); } return Optional.of(ValueSet.all(values.getType())); }, allOrNone -> Optional.empty()) .orElse(values); return Domain.create(simplifiedValueSet, nullAllowed); }