Source:
<code>public Result<TopNResultValue> apply(Result<TopNResultValue> arg1, Result<TopNResultValue> arg2) { if (arg1 == null) { return merger.getResult(arg2, comparator); } if (arg2 == null) { return merger.getResult(arg1, comparator); } TopNResultValue arg1Vals = arg1.getValue(); TopNResultValue arg2Vals = arg2.getValue(); Map<String, DimensionAndMetricValueExtractor> retVals = new LinkedHashMap<String, DimensionAndMetricValueExtractor>(); String dimension = dimensionSpec.getOutputName(); String topNMetricName = topNMetricSpec.getMetricName(dimensionSpec); for (DimensionAndMetricValueExtractor arg1Val : arg1Vals) { retVals.put(arg1Val.getStringDimensionValue(dimension), arg1Val); } for (DimensionAndMetricValueExtractor arg2Val : arg2Vals) { final String dimensionValue = arg2Val.getStringDimensionValue(dimension); DimensionAndMetricValueExtractor arg1Val = retVals.get(dimensionValue); if (arg1Val != null) { Map<String, Object> retVal = new LinkedHashMap<String, Object>(aggregations.size() + 2); retVal.put(dimension, dimensionValue); for (AggregatorFactory factory : aggregations) { final String metricName = factory.getName(); retVal.put(metricName, factory.combine(arg1Val.getMetric(metricName), arg2Val.getMetric(metricName))); } for (PostAggregator postAgg : postAggregations) { <START> if (postAgg.getName().equals(topNMetricName)) { <END> retVal.put(postAgg.getName(), postAgg.compute(retVal)); } } retVals.put(dimensionValue, new DimensionAndMetricValueExtractor(retVal)); } else { retVals.put(dimensionValue, arg2Val); } } final DateTime timestamp; if (gran instanceof AllGranularity) { timestamp = arg1.getTimestamp(); } else { timestamp = gran.toDateTime(gran.truncate(arg1.getTimestamp().getMillis())); } TopNResultBuilder bob = topNMetricSpec.getResultBuilder(timestamp, dimSpec, threshold, comparator); for (DimensionAndMetricValueExtractor extractor : retVals.values()) { bob.addEntry(extractor); } return bob.build(); }</code><technical_language>issue here, this breaks dependent-post-aggregators</technical_language>

Target:
public Result<TopNResultValue> apply(Result<TopNResultValue> arg1, Result<TopNResultValue> arg2) { if (arg1 == null) { return merger.getResult(arg2, comparator); } if (arg2 == null) { return merger.getResult(arg1, comparator); } TopNResultValue arg1Vals = arg1.getValue(); TopNResultValue arg2Vals = arg2.getValue(); Map<String, DimensionAndMetricValueExtractor> retVals = new LinkedHashMap<String, DimensionAndMetricValueExtractor>(); String dimension = dimensionSpec.getOutputName(); String topNMetricName = topNMetricSpec.getMetricName(dimensionSpec); for (DimensionAndMetricValueExtractor arg1Val : arg1Vals) { retVals.put(arg1Val.getStringDimensionValue(dimension), arg1Val); } for (DimensionAndMetricValueExtractor arg2Val : arg2Vals) { final String dimensionValue = arg2Val.getStringDimensionValue(dimension); DimensionAndMetricValueExtractor arg1Val = retVals.get(dimensionValue); if (arg1Val != null) { Map<String, Object> retVal = new LinkedHashMap<String, Object>(aggregations.size() + 2); retVal.put(dimension, dimensionValue); for (AggregatorFactory factory : aggregations) { final String metricName = factory.getName(); retVal.put(metricName, factory.combine(arg1Val.getMetric(metricName), arg2Val.getMetric(metricName))); } for (PostAggregator postAgg : postAggregations) { retVal.put(postAgg.getName(), postAgg.compute(retVal)); } retVals.put(dimensionValue, new DimensionAndMetricValueExtractor(retVal)); } else { retVals.put(dimensionValue, arg2Val); } } final DateTime timestamp; if (gran instanceof AllGranularity) { timestamp = arg1.getTimestamp(); } else { timestamp = gran.toDateTime(gran.truncate(arg1.getTimestamp().getMillis())); } TopNResultBuilder bob = topNMetricSpec.getResultBuilder( timestamp, dimSpec, threshold, comparator, aggregations, postAggregations ); for (DimensionAndMetricValueExtractor extractor : retVals.values()) { bob.addEntry(extractor); } return bob.build(); }