@Test public void testAggregate() throws CloneNotSupportedException { Stat stat = new Stat(StatType.TABLE_NUM_ROWS); stat.incrementBy(100); assertEquals(100, stat.getValue()); Stat stat2 = (Stat) stat.clone(); stat2.incrementBy(100); assertEquals(200, stat2.getValue()); Stat stat3 = new Stat(StatType.TABLE_NUM_BLOCKS); stat3.incrementBy(50); assertEquals(50, stat3.getValue()); StatSet group = new StatSet(); group.putStat(stat); group.putStat(stat2); group.putStat(stat3); StatSet group2 = (StatSet) group.clone(); group2.getStat(StatType.TABLE_NUM_ROWS).incrementBy(100); StatSet agg = StatisticsUtil.aggregateStatSet( Lists.newArrayList(group, group2)); assertEquals(500, agg.getStat(StatType.TABLE_NUM_ROWS).getValue()); assertEquals(100, agg.getStat(StatType.TABLE_NUM_BLOCKS).getValue()); }
public static StatSet aggregateStatSet(List<StatSet> statSets) { StatSet aggregated = new StatSet(); for (StatSet statSet : statSets) { for (Stat stat : statSet.getAllStats()) { if (aggregated.containStat(stat.getType())) { aggregated.getStat(stat.getType()).incrementBy(stat.getValue()); } else { aggregated.putStat(stat); } } } return aggregated; }
StatisticsUtil { public static StatSet aggregateStatSet(List<StatSet> statSets) { StatSet aggregated = new StatSet(); for (StatSet statSet : statSets) { for (Stat stat : statSet.getAllStats()) { if (aggregated.containStat(stat.getType())) { aggregated.getStat(stat.getType()).incrementBy(stat.getValue()); } else { aggregated.putStat(stat); } } } return aggregated; } }
StatisticsUtil { public static StatSet aggregateStatSet(List<StatSet> statSets) { StatSet aggregated = new StatSet(); for (StatSet statSet : statSets) { for (Stat stat : statSet.getAllStats()) { if (aggregated.containStat(stat.getType())) { aggregated.getStat(stat.getType()).incrementBy(stat.getValue()); } else { aggregated.putStat(stat); } } } return aggregated; }  }
StatisticsUtil { public static StatSet aggregateStatSet(List<StatSet> statSets) { StatSet aggregated = new StatSet(); for (StatSet statSet : statSets) { for (Stat stat : statSet.getAllStats()) { if (aggregated.containStat(stat.getType())) { aggregated.getStat(stat.getType()).incrementBy(stat.getValue()); } else { aggregated.putStat(stat); } } } return aggregated; }  static StatSet aggregateStatSet(List<StatSet> statSets); static void aggregateTableStat(TableStats result, TableStats stats); static TableStats aggregateTableStat(List<TableStats> tableStatses); static List<ColumnStats> aggregateColumnStats(List<ColumnStats> stats1, List<ColumnStats> stats2); static List<ColumnStats> emptyColumnStats(Schema schema); }
StatisticsUtil { public static StatSet aggregateStatSet(List<StatSet> statSets) { StatSet aggregated = new StatSet(); for (StatSet statSet : statSets) { for (Stat stat : statSet.getAllStats()) { if (aggregated.containStat(stat.getType())) { aggregated.getStat(stat.getType()).incrementBy(stat.getValue()); } else { aggregated.putStat(stat); } } } return aggregated; }  static StatSet aggregateStatSet(List<StatSet> statSets); static void aggregateTableStat(TableStats result, TableStats stats); static TableStats aggregateTableStat(List<TableStats> tableStatses); static List<ColumnStats> aggregateColumnStats(List<ColumnStats> stats1, List<ColumnStats> stats2); static List<ColumnStats> emptyColumnStats(Schema schema);  }