Search in sources :

Example 6 with ValueSet

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);
}
Also used : ValueSet(com.facebook.presto.common.predicate.ValueSet) IntegerStatistics(com.facebook.presto.hive.metastore.IntegerStatistics)

Example 7 with ValueSet

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);
}
Also used : DecimalStatistics(com.facebook.presto.hive.metastore.DecimalStatistics) ValueSet(com.facebook.presto.common.predicate.ValueSet)

Example 8 with ValueSet

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);
}
Also used : DoubleStatistics(com.facebook.presto.hive.metastore.DoubleStatistics) ValueSet(com.facebook.presto.common.predicate.ValueSet)

Example 9 with ValueSet

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);
}
Also used : DateStatistics(com.facebook.presto.hive.metastore.DateStatistics) ValueSet(com.facebook.presto.common.predicate.ValueSet)

Example 10 with ValueSet

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);
}
Also used : DoubleStatistics(com.facebook.presto.hive.metastore.DoubleStatistics) ValueSet(com.facebook.presto.common.predicate.ValueSet)

Aggregations

ValueSet (com.facebook.presto.common.predicate.ValueSet)13 Domain (com.facebook.presto.common.predicate.Domain)6 Range (com.facebook.presto.common.predicate.Range)6 TupleDomain (com.facebook.presto.common.predicate.TupleDomain)6 ColumnHandle (com.facebook.presto.spi.ColumnHandle)5 Instant (java.time.Instant)4 Test (org.testng.annotations.Test)4 PrometheusSplitManager.decimalSecondString (com.facebook.presto.plugin.prometheus.PrometheusSplitManager.decimalSecondString)3 Duration (java.time.Duration)3 TemporalAmount (java.time.temporal.TemporalAmount)3 Marker (com.facebook.presto.common.predicate.Marker)2 SortedRangeSet (com.facebook.presto.common.predicate.SortedRangeSet)2 DoubleStatistics (com.facebook.presto.hive.metastore.DoubleStatistics)2 ImmutableMap.toImmutableMap (com.google.common.collect.ImmutableMap.toImmutableMap)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 Map (java.util.Map)2 Subfield (com.facebook.presto.common.Subfield)1 DiscreteValues (com.facebook.presto.common.predicate.DiscreteValues)1 EquatableValueSet (com.facebook.presto.common.predicate.EquatableValueSet)1 NullableValue (com.facebook.presto.common.predicate.NullableValue)1