Revert "fix npe in topNBinaryFn with post aggs"

This reverts commit bbedde3418.
This commit is contained in:
nishantmonu51 2014-04-22 11:10:55 +05:30
parent 357cd66f66
commit 7bafb71841
2 changed files with 6 additions and 35 deletions

View File

@ -90,19 +90,7 @@ public class TopNBinaryFn implements BinaryFn<Result<TopNResultValue>, Result<To
TopNResultValue arg2Vals = arg2.getValue();
for (DimensionAndMetricValueExtractor arg1Val : arg1Vals) {
final String dimensionValue = arg1Val.getStringDimensionValue(dimension);
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, arg1Val.getMetric(metricName));
}
for (PostAggregator postAgg : postAggregations) {
retVal.put(postAgg.getName(), postAgg.compute(retVal));
}
retVals.put(dimensionValue, new DimensionAndMetricValueExtractor(retVal));
retVals.put(arg1Val.getStringDimensionValue(dimension), arg1Val);
}
for (DimensionAndMetricValueExtractor arg2Val : arg2Vals) {
final String dimensionValue = arg2Val.getStringDimensionValue(dimension);
@ -124,18 +112,7 @@ public class TopNBinaryFn implements BinaryFn<Result<TopNResultValue>, Result<To
retVals.put(dimensionValue, new DimensionAndMetricValueExtractor(retVal));
} else {
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, arg2Val.getMetric(metricName));
}
for (PostAggregator postAgg : postAggregations) {
retVal.put(postAgg.getName(), postAgg.compute(retVal));
}
retVals.put(dimensionValue, new DimensionAndMetricValueExtractor(retVal));
retVals.put(dimensionValue, arg2Val);
}
}

View File

@ -324,9 +324,9 @@ public class TopNBinaryFnTest
"testdim", "2"
),
ImmutableMap.<String, Object>of(
"rows", 4L,
"index", 5L,
"testdim", "other"
"rows", 0L,
"index", 1L,
"testdim", "3"
)
)
)
@ -336,12 +336,6 @@ public class TopNBinaryFnTest
currTime,
new TopNResultValue(
ImmutableList.<Map<String, Object>>of(
ImmutableMap.<String, Object>of(
"testdim", "other",
"rows", 4L,
"index", 5L,
"addrowsindexconstant", 10.0
),
ImmutableMap.<String, Object>of(
"testdim", "1",
"rows", 3L,
@ -363,7 +357,7 @@ public class TopNBinaryFnTest
QueryGranularity.ALL,
new DefaultDimensionSpec("testdim", null),
new NumericTopNMetricSpec("addrowsindexconstant"),
3,
2,
aggregatorFactories,
postAggregators
).apply(