use of com.facebook.presto.common.predicate.ValueSet in project presto by prestodb.
the class HiveSplitManager method getIntegerColumnStatisticsValueSet.
private Optional<ValueSet> getIntegerColumnStatisticsValueSet(HiveColumnStatistics statistics, Type type) {
if (!statistics.getIntegerStatistics().isPresent()) {
return Optional.empty();
}
IntegerStatistics hiveColumnStatistics = statistics.getIntegerStatistics().get();
ValueSet result = ValueSet.all(type);
if (hiveColumnStatistics.getMin().isPresent()) {
result = result.intersect(SortedRangeSet.copyOf(type, ImmutableList.of(Range.greaterThanOrEqual(type, hiveColumnStatistics.getMin().getAsLong()))));
}
if (hiveColumnStatistics.getMax().isPresent()) {
result = result.intersect(SortedRangeSet.copyOf(type, ImmutableList.of(Range.lessThanOrEqual(type, hiveColumnStatistics.getMax().getAsLong()))));
}
return Optional.of(result);
}
use of com.facebook.presto.common.predicate.ValueSet in project presto by prestodb.
the class HiveSplitManager method getDecimalColumnStatisticsValueSet.
private Optional<ValueSet> getDecimalColumnStatisticsValueSet(HiveColumnStatistics statistics, Type type) {
if (!statistics.getDecimalStatistics().isPresent()) {
return Optional.empty();
}
DecimalStatistics hiveColumnStatistics = statistics.getDecimalStatistics().get();
ValueSet result = ValueSet.all(type);
if (hiveColumnStatistics.getMin().isPresent()) {
Object min = isShortDecimal(type) ? hiveColumnStatistics.getMin().get().longValue() : encodeScaledValue(hiveColumnStatistics.getMin().get());
result = result.intersect(SortedRangeSet.copyOf(type, ImmutableList.of(Range.greaterThanOrEqual(type, min))));
}
if (hiveColumnStatistics.getMax().isPresent()) {
Object max = isShortDecimal(type) ? hiveColumnStatistics.getMax().get().longValue() : encodeScaledValue(hiveColumnStatistics.getMax().get());
result = result.intersect(SortedRangeSet.copyOf(type, ImmutableList.of(Range.lessThanOrEqual(type, max))));
}
return Optional.of(result);
}
use of com.facebook.presto.common.predicate.ValueSet in project presto by prestodb.
the class HiveSplitManager method getFloatColumnStatisticsValueSet.
private Optional<ValueSet> getFloatColumnStatisticsValueSet(HiveColumnStatistics statistics, Type type) {
if (!statistics.getDoubleStatistics().isPresent()) {
return Optional.empty();
}
DoubleStatistics hiveColumnStatistics = statistics.getDoubleStatistics().get();
ValueSet result = ValueSet.all(type);
if (hiveColumnStatistics.getMin().isPresent()) {
result = result.intersect(SortedRangeSet.copyOf(type, ImmutableList.of(Range.greaterThanOrEqual(type, (long) floatToIntBits((float) hiveColumnStatistics.getMin().getAsDouble())))));
}
if (hiveColumnStatistics.getMax().isPresent()) {
result = result.intersect(SortedRangeSet.copyOf(type, ImmutableList.of(Range.lessThanOrEqual(type, (long) floatToIntBits((float) hiveColumnStatistics.getMax().getAsDouble())))));
}
return Optional.of(result);
}
use of com.facebook.presto.common.predicate.ValueSet in project presto by prestodb.
the class HiveSplitManager method getDateColumnStatisticsValueSet.
private Optional<ValueSet> getDateColumnStatisticsValueSet(HiveColumnStatistics statistics, Type type) {
if (!statistics.getDateStatistics().isPresent()) {
return Optional.empty();
}
DateStatistics hiveColumnStatistics = statistics.getDateStatistics().get();
ValueSet result = ValueSet.all(type);
if (hiveColumnStatistics.getMin().isPresent()) {
result = result.intersect(SortedRangeSet.copyOf(type, ImmutableList.of(Range.greaterThanOrEqual(type, hiveColumnStatistics.getMin().get().toEpochDay()))));
}
if (hiveColumnStatistics.getMax().isPresent()) {
result = result.intersect(SortedRangeSet.copyOf(type, ImmutableList.of(Range.lessThanOrEqual(type, hiveColumnStatistics.getMax().get().toEpochDay()))));
}
return Optional.of(result);
}
use of com.facebook.presto.common.predicate.ValueSet in project presto by prestodb.
the class HiveSplitManager method getDoubleColumnStatisticsValueSet.
private Optional<ValueSet> getDoubleColumnStatisticsValueSet(HiveColumnStatistics statistics, Type type) {
if (!statistics.getDoubleStatistics().isPresent()) {
return Optional.empty();
}
DoubleStatistics hiveColumnStatistics = statistics.getDoubleStatistics().get();
ValueSet result = ValueSet.all(type);
if (hiveColumnStatistics.getMin().isPresent()) {
result = result.intersect(SortedRangeSet.copyOf(type, ImmutableList.of(Range.greaterThanOrEqual(type, hiveColumnStatistics.getMin().getAsDouble()))));
}
if (hiveColumnStatistics.getMax().isPresent()) {
result = result.intersect(SortedRangeSet.copyOf(type, ImmutableList.of(Range.lessThanOrEqual(type, hiveColumnStatistics.getMax().getAsDouble()))));
}
return Optional.of(result);
}
Aggregations