use of io.prestosql.plugin.hive.PartitionStatistics in project boostkit-bigdata by kunpengcompute.
the class ThriftHiveMetastore method updatePartitionStatistics.
@Override
public void updatePartitionStatistics(HiveIdentity identity, String databaseName, String tableName, String partitionName, Function<PartitionStatistics, PartitionStatistics> update) {
List<Partition> partitions = getPartitionsByNames(identity, databaseName, tableName, ImmutableList.of(partitionName));
if (partitions.size() != 1) {
throw new PrestoException(HiveErrorCode.HIVE_METASTORE_ERROR, "Metastore returned multiple partitions for name: " + partitionName);
}
Table table = getTable(identity, databaseName, tableName).orElseThrow(() -> new TableNotFoundException(new SchemaTableName(databaseName, tableName)));
PartitionStatistics currentStatistics = requireNonNull(getPartitionStatistics(identity, table, partitions).get(partitionName), "getPartitionStatistics() returned null");
PartitionStatistics updatedStatistics = update.apply(currentStatistics);
Partition originalPartition = getOnlyElement(partitions);
Partition modifiedPartition = originalPartition.deepCopy();
HiveBasicStatistics basicStatistics = updatedStatistics.getBasicStatistics();
modifiedPartition.setParameters(ThriftMetastoreUtil.updateStatisticsParameters(modifiedPartition.getParameters(), basicStatistics));
alterPartitionWithoutStatistics(identity, databaseName, tableName, modifiedPartition);
updatePartitionColumnStatistics(identity, modifiedPartition, databaseName, tableName, partitionName, basicStatistics, currentStatistics, updatedStatistics);
}
use of io.prestosql.plugin.hive.PartitionStatistics in project boostkit-bigdata by kunpengcompute.
the class FileHiveMetastore method getPartitionStatistics.
private synchronized PartitionStatistics getPartitionStatistics(HiveIdentity identity, List<String> partitionValues, Table table) {
Path partitionDirectory = getPartitionMetadataDirectory(table, ImmutableList.copyOf(partitionValues));
PartitionMetadata partitionMetadata = readSchemaFile("partition", partitionDirectory, partitionCodec).orElseThrow(() -> new PartitionNotFoundException(table.getSchemaTableName(), partitionValues));
HiveBasicStatistics basicStatistics = getHiveBasicStatistics(partitionMetadata.getParameters());
return new PartitionStatistics(basicStatistics, partitionMetadata.getColumnStatistics());
}
use of io.prestosql.plugin.hive.PartitionStatistics in project boostkit-bigdata by kunpengcompute.
the class SemiTransactionalHiveMetastore method updatePartitionStatistics.
// For HiveBasicStatistics, we only overwrite the original statistics if the new one is not empty.
// For HiveColumnStatistics, we always overwrite every statistics.
// TODO: Collect file count, on-disk size and in-memory size during ANALYZE
private PartitionStatistics updatePartitionStatistics(PartitionStatistics oldPartitionStats, PartitionStatistics newPartitionStats) {
HiveBasicStatistics oldBasicStatistics = oldPartitionStats.getBasicStatistics();
HiveBasicStatistics newBasicStatistics = newPartitionStats.getBasicStatistics();
HiveBasicStatistics updatedBasicStatistics = new HiveBasicStatistics(firstPresent(newBasicStatistics.getFileCount(), oldBasicStatistics.getFileCount()), firstPresent(newBasicStatistics.getRowCount(), oldBasicStatistics.getRowCount()), firstPresent(newBasicStatistics.getInMemoryDataSizeInBytes(), oldBasicStatistics.getInMemoryDataSizeInBytes()), firstPresent(newBasicStatistics.getOnDiskDataSizeInBytes(), oldBasicStatistics.getOnDiskDataSizeInBytes()));
return new PartitionStatistics(updatedBasicStatistics, newPartitionStats.getColumnStatistics());
}
use of io.prestosql.plugin.hive.PartitionStatistics in project boostkit-bigdata by kunpengcompute.
the class InMemoryThriftMetastore method getPartitionStatistics.
private ImmutableMap<String, PartitionStatistics> getPartitionStatistics(HiveIdentity identity, String databaseName, String tableName, Set<String> partitionNames) {
ImmutableMap.Builder<String, PartitionStatistics> result = ImmutableMap.builder();
for (String partitionName : partitionNames) {
PartitionName partitionKey = PartitionName.partition(databaseName, tableName, partitionName);
PartitionStatistics statistics = partitionColumnStatistics.get(partitionKey);
if (statistics == null) {
statistics = new PartitionStatistics(createEmptyStatistics(), ImmutableMap.of());
}
result.put(partitionName, statistics);
}
return result.build();
}
use of io.prestosql.plugin.hive.PartitionStatistics in project boostkit-bigdata by kunpengcompute.
the class InMemoryThriftMetastore method getTableStatistics.
private PartitionStatistics getTableStatistics(HiveIdentity identity, String databaseName, String tableName) {
SchemaTableName schemaTableName = new SchemaTableName(databaseName, tableName);
PartitionStatistics statistics = columnStatistics.get(schemaTableName);
if (statistics == null) {
statistics = new PartitionStatistics(createEmptyStatistics(), ImmutableMap.of());
}
return statistics;
}
Aggregations