use of io.prestosql.spi.statistics.ColumnStatisticMetadata in project hetu-core by openlookeng.
the class HiveMetadata method createPartitionStatistics.
private PartitionStatistics createPartitionStatistics(ConnectorSession session, Map<String, Type> columnTypes, ComputedStatistics computedStatistics) {
Map<ColumnStatisticMetadata, Block> computedColumnStatistics = computedStatistics.getColumnStatistics();
Block rowCountBlock = Optional.ofNullable(computedStatistics.getTableStatistics().get(ROW_COUNT)).orElseThrow(() -> new VerifyException("rowCount not present"));
verify(!rowCountBlock.isNull(0), "rowCount must never be null");
long rowCount = BIGINT.getLong(rowCountBlock, 0);
HiveBasicStatistics rowCountOnlyBasicStatistics = new HiveBasicStatistics(OptionalLong.empty(), OptionalLong.of(rowCount), OptionalLong.empty(), OptionalLong.empty());
return createPartitionStatistics(session, rowCountOnlyBasicStatistics, columnTypes, computedColumnStatistics);
}
use of io.prestosql.spi.statistics.ColumnStatisticMetadata in project hetu-core by openlookeng.
the class TestStatisticAggregationsDescriptor method createTestDescriptor.
private static StatisticAggregationsDescriptor<Symbol> createTestDescriptor() {
StatisticAggregationsDescriptor.Builder<Symbol> builder = StatisticAggregationsDescriptor.builder();
PlanSymbolAllocator planSymbolAllocator = new PlanSymbolAllocator();
for (String column : COLUMNS) {
for (ColumnStatisticType type : ColumnStatisticType.values()) {
builder.addColumnStatistic(new ColumnStatisticMetadata(column, type), testSymbol(planSymbolAllocator));
}
builder.addGrouping(column, testSymbol(planSymbolAllocator));
}
builder.addTableStatistic(ROW_COUNT, testSymbol(planSymbolAllocator));
return builder.build();
}
use of io.prestosql.spi.statistics.ColumnStatisticMetadata in project hetu-core by openlookeng.
the class StatisticsUtils method fromComputedStatistics.
public static TableStatisticsData fromComputedStatistics(ConnectorSession session, Collection<ComputedStatistics> computedStatistics, long rowCount, Map<String, ColumnHandle> columnHandles, TypeManager typeManager) {
TableStatisticsData.Builder tableStatBuilder = TableStatisticsData.builder();
tableStatBuilder.setRowCount(rowCount);
// organize the column stats into a per-column view
Map<String, Map<ColumnStatisticType, Block>> perColumnStats = new HashMap<>();
for (ComputedStatistics stat : computedStatistics) {
for (Map.Entry<ColumnStatisticMetadata, Block> entry : stat.getColumnStatistics().entrySet()) {
perColumnStats.putIfAbsent(entry.getKey().getColumnName(), new HashMap<>());
perColumnStats.get(entry.getKey().getColumnName()).put(entry.getKey().getStatisticType(), entry.getValue());
}
}
// build the per-column statistics
for (Map.Entry<String, ColumnHandle> entry : columnHandles.entrySet()) {
Map<ColumnStatisticType, Block> columnStat = perColumnStats.get(entry.getKey());
if (columnStat == null) {
continue;
}
MemoryColumnHandle handle = (MemoryColumnHandle) entry.getValue();
Type columnType = handle.getType(typeManager);
tableStatBuilder.setColumnStatistics(handle.getColumnName(), fromComputedStatistics(session, columnStat, rowCount, columnType));
}
return tableStatBuilder.build();
}
Aggregations