use of com.facebook.presto.hive.metastore.DoubleStatistics in project presto by prestodb.
the class TestThriftHiveMetastoreUtil method testEmptyDoubleStatsToColumnStatistics.
@Test
public void testEmptyDoubleStatsToColumnStatistics() {
DoubleColumnStatsData emptyDoubleColumnStatsData = new DoubleColumnStatsData();
ColumnStatisticsObj columnStatisticsObj = new ColumnStatisticsObj("my_col", DOUBLE_TYPE_NAME, doubleStats(emptyDoubleColumnStatsData));
HiveColumnStatistics actual = fromMetastoreApiColumnStatistics(columnStatisticsObj, OptionalLong.empty());
assertEquals(actual.getIntegerStatistics(), Optional.empty());
assertEquals(actual.getDoubleStatistics(), Optional.of(new DoubleStatistics(OptionalDouble.empty(), OptionalDouble.empty())));
assertEquals(actual.getDecimalStatistics(), Optional.empty());
assertEquals(actual.getDateStatistics(), Optional.empty());
assertEquals(actual.getBooleanStatistics(), Optional.empty());
assertEquals(actual.getMaxValueSizeInBytes(), OptionalLong.empty());
assertEquals(actual.getTotalSizeInBytes(), OptionalLong.empty());
assertEquals(actual.getNullsCount(), OptionalLong.empty());
assertEquals(actual.getDistinctValuesCount(), OptionalLong.empty());
}
use of com.facebook.presto.hive.metastore.DoubleStatistics in project presto by prestodb.
the class TestStatistics method testMergeDoubleColumnStatistics.
@Test
public void testMergeDoubleColumnStatistics() {
assertMergeHiveColumnStatistics(HiveColumnStatistics.builder().setDoubleStatistics(new DoubleStatistics(OptionalDouble.empty(), OptionalDouble.empty())).build(), HiveColumnStatistics.builder().setDoubleStatistics(new DoubleStatistics(OptionalDouble.empty(), OptionalDouble.empty())).build(), HiveColumnStatistics.builder().setDoubleStatistics(new DoubleStatistics(OptionalDouble.empty(), OptionalDouble.empty())).build());
assertMergeHiveColumnStatistics(HiveColumnStatistics.builder().setDoubleStatistics(new DoubleStatistics(OptionalDouble.of(1), OptionalDouble.of(2))).build(), HiveColumnStatistics.builder().setDoubleStatistics(new DoubleStatistics(OptionalDouble.empty(), OptionalDouble.empty())).build(), HiveColumnStatistics.builder().setDoubleStatistics(new DoubleStatistics(OptionalDouble.of(1), OptionalDouble.of(2))).build());
assertMergeHiveColumnStatistics(HiveColumnStatistics.builder().setDoubleStatistics(new DoubleStatistics(OptionalDouble.of(1), OptionalDouble.of(2))).build(), HiveColumnStatistics.builder().setDoubleStatistics(new DoubleStatistics(OptionalDouble.of(0), OptionalDouble.of(3))).build(), HiveColumnStatistics.builder().setDoubleStatistics(new DoubleStatistics(OptionalDouble.of(0), OptionalDouble.of(3))).build());
}
use of com.facebook.presto.hive.metastore.DoubleStatistics in project presto by prestodb.
the class TestThriftHiveMetastoreUtil method testDoubleStatsToColumnStatistics.
@Test
public void testDoubleStatsToColumnStatistics() {
DoubleColumnStatsData doubleColumnStatsData = new DoubleColumnStatsData();
doubleColumnStatsData.setLowValue(0);
doubleColumnStatsData.setHighValue(100);
doubleColumnStatsData.setNumNulls(1);
doubleColumnStatsData.setNumDVs(20);
ColumnStatisticsObj columnStatisticsObj = new ColumnStatisticsObj("my_col", DOUBLE_TYPE_NAME, doubleStats(doubleColumnStatsData));
HiveColumnStatistics actual = fromMetastoreApiColumnStatistics(columnStatisticsObj, OptionalLong.of(1000));
assertEquals(actual.getIntegerStatistics(), Optional.empty());
assertEquals(actual.getDoubleStatistics(), Optional.of(new DoubleStatistics(OptionalDouble.of(0), OptionalDouble.of(100))));
assertEquals(actual.getDecimalStatistics(), Optional.empty());
assertEquals(actual.getDateStatistics(), Optional.empty());
assertEquals(actual.getBooleanStatistics(), Optional.empty());
assertEquals(actual.getMaxValueSizeInBytes(), OptionalLong.empty());
assertEquals(actual.getTotalSizeInBytes(), OptionalLong.empty());
assertEquals(actual.getNullsCount(), OptionalLong.of(1));
assertEquals(actual.getDistinctValuesCount(), OptionalLong.of(19));
}
use of com.facebook.presto.hive.metastore.DoubleStatistics 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.hive.metastore.DoubleStatistics 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