use of org.apache.hadoop.hive.metastore.model.MPartitionColumnStatistics in project hive by apache.
the class ObjectStore method updatePartitionColumnStatistics.
@Override
public boolean updatePartitionColumnStatistics(ColumnStatistics colStats, List<String> partVals) throws NoSuchObjectException, MetaException, InvalidObjectException, InvalidInputException {
boolean committed = false;
try {
openTransaction();
List<ColumnStatisticsObj> statsObjs = colStats.getStatsObj();
ColumnStatisticsDesc statsDesc = colStats.getStatsDesc();
Table table = ensureGetTable(statsDesc.getDbName(), statsDesc.getTableName());
Partition partition = convertToPart(getMPartition(statsDesc.getDbName(), statsDesc.getTableName(), partVals));
List<String> colNames = new ArrayList<>();
for (ColumnStatisticsObj statsObj : statsObjs) {
colNames.add(statsObj.getColName());
}
Map<String, MPartitionColumnStatistics> oldStats = getPartitionColStats(table, statsDesc.getPartName(), colNames);
MPartition mPartition = getMPartition(statsDesc.getDbName(), statsDesc.getTableName(), partVals);
if (partition == null) {
throw new NoSuchObjectException("Partition for which stats is gathered doesn't exist.");
}
for (ColumnStatisticsObj statsObj : statsObjs) {
MPartitionColumnStatistics mStatsObj = StatObjectConverter.convertToMPartitionColumnStatistics(mPartition, statsDesc, statsObj);
writeMPartitionColumnStatistics(table, partition, mStatsObj, oldStats.get(statsObj.getColName()));
}
Map<String, String> parameters = mPartition.getParameters();
StatsSetupConst.setColumnStatsState(parameters, colNames);
mPartition.setParameters(parameters);
committed = commitTransaction();
return committed;
} finally {
if (!committed) {
rollbackTransaction();
}
}
}
Aggregations