Java Code Examples for org.apache.hadoop.hive.metastore.api.StringColumnStatsData#setMaxColLen()

The following examples show how to use org.apache.hadoop.hive.metastore.api.StringColumnStatsData#setMaxColLen() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: presto   File: TestThriftMetastoreUtil.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testStringStatsToColumnStatistics()
{
    StringColumnStatsData stringColumnStatsData = new StringColumnStatsData();
    stringColumnStatsData.setMaxColLen(100);
    stringColumnStatsData.setAvgColLen(23.333);
    stringColumnStatsData.setNumNulls(1);
    stringColumnStatsData.setNumDVs(20);
    ColumnStatisticsObj columnStatisticsObj = new ColumnStatisticsObj("my_col", STRING_TYPE_NAME, stringStats(stringColumnStatsData));
    HiveColumnStatistics actual = fromMetastoreApiColumnStatistics(columnStatisticsObj, OptionalLong.of(2));

    assertEquals(actual.getIntegerStatistics(), Optional.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.of(100));
    assertEquals(actual.getTotalSizeInBytes(), OptionalLong.of(23));
    assertEquals(actual.getNullsCount(), OptionalLong.of(1));
    assertEquals(actual.getDistinctValuesCount(), OptionalLong.of(1));
}
 
Example 2
public static org.apache.hadoop.hive.metastore.api.ColumnStatisticsData getHiveStringColumnStatsData() {
  StringColumnStatsData statsData = new StringColumnStatsData();
  statsData.setAvgColLen(123.4);
  statsData.setMaxColLen(567L);
  statsData.setNumDVs(89L);
  statsData.setNumNulls(13L);
  org.apache.hadoop.hive.metastore.api.ColumnStatisticsData  statsWrapper =
          new org.apache.hadoop.hive.metastore.api.ColumnStatisticsData();
  statsWrapper.setStringStats(statsData);
  return statsWrapper;
}
 
Example 3
Source Project: presto   File: ThriftMetastoreUtil.java    License: Apache License 2.0 5 votes vote down vote up
private static ColumnStatisticsObj createStringStatistics(String columnName, HiveType columnType, HiveColumnStatistics statistics, OptionalLong rowCount)
{
    StringColumnStatsData data = new StringColumnStatsData();
    statistics.getNullsCount().ifPresent(data::setNumNulls);
    toMetastoreDistinctValuesCount(statistics.getDistinctValuesCount(), statistics.getNullsCount()).ifPresent(data::setNumDVs);
    data.setMaxColLen(statistics.getMaxValueSizeInBytes().orElse(0));
    data.setAvgColLen(getAverageColumnLength(statistics.getTotalSizeInBytes(), rowCount, statistics.getNullsCount()).orElse(0));
    return new ColumnStatisticsObj(columnName, columnType.toString(), stringStats(data));
}