Skip to content

Commit

Permalink
Revert "fix npe in topNBinaryFn with post aggs"
Browse files Browse the repository at this point in the history
This reverts commit bbedde3.
  • Loading branch information
nishantmonu51 committed Apr 22, 2014
1 parent 357cd66 commit 7bafb71
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 35 deletions.
27 changes: 2 additions & 25 deletions processing/src/main/java/io/druid/query/topn/TopNBinaryFn.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,7 @@ public Result<TopNResultValue> apply(Result<TopNResultValue> arg1, Result<TopNRe
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);
Expand All @@ -124,18 +112,7 @@ public Result<TopNResultValue> apply(Result<TopNResultValue> arg1, Result<TopNRe

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);
}
}

Expand Down
14 changes: 4 additions & 10 deletions processing/src/test/java/io/druid/query/topn/TopNBinaryFnTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,9 @@ public void testMergeByPostAgg()
"testdim", "2"
),
ImmutableMap.<String, Object>of(
"rows", 4L,
"index", 5L,
"testdim", "other"
"rows", 0L,
"index", 1L,
"testdim", "3"
)
)
)
Expand All @@ -336,12 +336,6 @@ public void testMergeByPostAgg()
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,
Expand All @@ -363,7 +357,7 @@ public void testMergeByPostAgg()
QueryGranularity.ALL,
new DefaultDimensionSpec("testdim", null),
new NumericTopNMetricSpec("addrowsindexconstant"),
3,
2,
aggregatorFactories,
postAggregators
).apply(
Expand Down

0 comments on commit 7bafb71

Please sign in to comment.