Search in sources :

Example 1 with IntegerStatistics

use of com.facebook.presto.hive.metastore.IntegerStatistics in project presto by prestodb.

the class TestThriftHiveMetastoreUtil method testLongStatsToColumnStatistics.

@Test
public void testLongStatsToColumnStatistics() {
    LongColumnStatsData longColumnStatsData = new LongColumnStatsData();
    longColumnStatsData.setLowValue(0);
    longColumnStatsData.setHighValue(100);
    longColumnStatsData.setNumNulls(1);
    longColumnStatsData.setNumDVs(20);
    ColumnStatisticsObj columnStatisticsObj = new ColumnStatisticsObj("my_col", BIGINT_TYPE_NAME, longStats(longColumnStatsData));
    HiveColumnStatistics actual = fromMetastoreApiColumnStatistics(columnStatisticsObj, OptionalLong.of(1000));
    assertEquals(actual.getIntegerStatistics(), Optional.of(new IntegerStatistics(OptionalLong.of(0), OptionalLong.of(100))));
    assertEquals(actual.getDoubleStatistics(), Optional.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.of(1));
    assertEquals(actual.getDistinctValuesCount(), OptionalLong.of(19));
}
Also used : ColumnStatisticsObj(org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj) HiveColumnStatistics(com.facebook.presto.hive.metastore.HiveColumnStatistics) LongColumnStatsData(org.apache.hadoop.hive.metastore.api.LongColumnStatsData) IntegerStatistics(com.facebook.presto.hive.metastore.IntegerStatistics) Test(org.testng.annotations.Test)

Example 2 with IntegerStatistics

use of com.facebook.presto.hive.metastore.IntegerStatistics in project presto by prestodb.

the class TestThriftHiveMetastoreUtil method testEmptyLongStatsToColumnStatistics.

@Test
public void testEmptyLongStatsToColumnStatistics() {
    LongColumnStatsData emptyLongColumnStatsData = new LongColumnStatsData();
    ColumnStatisticsObj columnStatisticsObj = new ColumnStatisticsObj("my_col", BIGINT_TYPE_NAME, longStats(emptyLongColumnStatsData));
    HiveColumnStatistics actual = fromMetastoreApiColumnStatistics(columnStatisticsObj, OptionalLong.empty());
    assertEquals(actual.getIntegerStatistics(), Optional.of(new IntegerStatistics(OptionalLong.empty(), OptionalLong.empty())));
    assertEquals(actual.getDoubleStatistics(), Optional.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());
}
Also used : ColumnStatisticsObj(org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj) HiveColumnStatistics(com.facebook.presto.hive.metastore.HiveColumnStatistics) LongColumnStatsData(org.apache.hadoop.hive.metastore.api.LongColumnStatsData) IntegerStatistics(com.facebook.presto.hive.metastore.IntegerStatistics) Test(org.testng.annotations.Test)

Example 3 with IntegerStatistics

use of com.facebook.presto.hive.metastore.IntegerStatistics in project presto by prestodb.

the class TestStatistics method testMergeIntegerColumnStatistics.

@Test
public void testMergeIntegerColumnStatistics() {
    assertMergeHiveColumnStatistics(HiveColumnStatistics.builder().setIntegerStatistics(new IntegerStatistics(OptionalLong.empty(), OptionalLong.empty())).build(), HiveColumnStatistics.builder().setIntegerStatistics(new IntegerStatistics(OptionalLong.empty(), OptionalLong.empty())).build(), HiveColumnStatistics.builder().setIntegerStatistics(new IntegerStatistics(OptionalLong.empty(), OptionalLong.empty())).build());
    assertMergeHiveColumnStatistics(HiveColumnStatistics.builder().setIntegerStatistics(new IntegerStatistics(OptionalLong.of(1), OptionalLong.of(2))).build(), HiveColumnStatistics.builder().setIntegerStatistics(new IntegerStatistics(OptionalLong.empty(), OptionalLong.empty())).build(), HiveColumnStatistics.builder().setIntegerStatistics(new IntegerStatistics(OptionalLong.of(1), OptionalLong.of(2))).build());
    assertMergeHiveColumnStatistics(HiveColumnStatistics.builder().setIntegerStatistics(new IntegerStatistics(OptionalLong.of(1), OptionalLong.of(2))).build(), HiveColumnStatistics.builder().setIntegerStatistics(new IntegerStatistics(OptionalLong.of(0), OptionalLong.of(3))).build(), HiveColumnStatistics.builder().setIntegerStatistics(new IntegerStatistics(OptionalLong.of(0), OptionalLong.of(3))).build());
}
Also used : IntegerStatistics(com.facebook.presto.hive.metastore.IntegerStatistics) Test(org.testng.annotations.Test)

Example 4 with IntegerStatistics

use of com.facebook.presto.hive.metastore.IntegerStatistics 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)

Aggregations

IntegerStatistics (com.facebook.presto.hive.metastore.IntegerStatistics)4 Test (org.testng.annotations.Test)3 HiveColumnStatistics (com.facebook.presto.hive.metastore.HiveColumnStatistics)2 ColumnStatisticsObj (org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj)2 LongColumnStatsData (org.apache.hadoop.hive.metastore.api.LongColumnStatsData)2 ValueSet (com.facebook.presto.common.predicate.ValueSet)1