StatisticsUtil { public static void aggregateTableStat(TableStats result, TableStats stats) { if (stats.getColumnStats().size() > 0) { if (result.getColumnStats().size() == 0) { for (int i = 0; i < stats.getColumnStats().size(); i++) { result.addColumnStat(stats.getColumnStats().get(i)); } } else { for (int i = 0; i < stats.getColumnStats().size(); i++) { ColumnStats cs = stats.getColumnStats().get(i); ColumnStats agg = result.getColumnStats().get(i); if (cs == null) { LOG.warn("ERROR: One of column stats is NULL (expected column: " + agg.getColumn() + ")"); continue; } try { agg.setNumDistVals(agg.getNumDistValues() + cs.getNumDistValues()); agg.setNumNulls(agg.getNumNulls() + cs.getNumNulls()); if (!cs.minIsNotSet() && (agg.minIsNotSet() || agg.getMinValue().compareTo(cs.getMinValue()) > 0)) { agg.setMinValue(cs.getMinValue()); } if (!cs.maxIsNotSet() && (agg.maxIsNotSet() || agg.getMaxValue().compareTo(cs.getMaxValue()) < 0)) { agg.setMaxValue(stats.getColumnStats().get(i).getMaxValue()); } } catch (Exception e) { LOG.warn(e.getMessage(), e); } } } } result.setNumRows(result.getNumRows() + stats.getNumRows()); result.setNumBytes(result.getNumBytes() + stats.getNumBytes()); result.setReadBytes(result.getReadBytes() + stats.getReadBytes()); result.setNumBlocks(result.getNumBlocks() + stats.getNumBlocks()); result.setNumShuffleOutputs(result.getNumShuffleOutputs() + stats.getNumShuffleOutputs()); }  static StatSet aggregateStatSet(List<StatSet> statSets); static void aggregateTableStat(TableStats result, TableStats stats); static TableStats aggregateTableStat(List<TableStats> tableStatses);  }
@Test public void testEmptyAggregate() { TableStats stat1 = new TableStats(); TableStats stat2 = new TableStats(); TableStats stat3 = new TableStats(); assertNotNull(StatisticsUtil.aggregateTableStat( Lists.newArrayList(stat1, stat2, stat3))); }