readLock.unlock();
}
}
public static TableStat computeStatFromUnionBlock(SubQuery subQuery) {
TableStat stat = new TableStat();
TableStat childStat;
long avgRows = 0, numBytes = 0, numRows = 0;
int numBlocks = 0, numPartitions = 0;
List<ColumnStat> columnStats = Lists.newArrayList();
MasterPlan masterPlan = subQuery.getMasterPlan();
Iterator<ExecutionBlock> it = masterPlan.getChilds(subQuery.getBlock()).iterator();
while (it.hasNext()) {
ExecutionBlock block = it.next();
SubQuery childSubQuery = subQuery.context.getSubQuery(block.getId());
childStat = childSubQuery.getTableStat();
avgRows += childStat.getAvgRows();
columnStats.addAll(childStat.getColumnStats());
numBlocks += childStat.getNumBlocks();
numBytes += childStat.getNumBytes();
numPartitions += childStat.getNumPartitions();
numRows += childStat.getNumRows();
}
stat.setColumnStats(columnStats);
stat.setNumBlocks(numBlocks);
stat.setNumBytes(numBytes);