Skip to content

Commit

Permalink
calculate postAggs while pulling from cache
Browse files Browse the repository at this point in the history
  • Loading branch information
nishantmonu51 committed Apr 22, 2014
1 parent 7bafb71 commit 3fb4225
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ public CacheStrategy<Result<TopNResultValue>, Object, TopNQuery> getCacheStrateg
return new CacheStrategy<Result<TopNResultValue>, Object, TopNQuery>()
{
private final List<AggregatorFactory> aggs = query.getAggregatorSpecs();
private final List<PostAggregator> postAggs = AggregatorUtil.pruneDependentPostAgg(
query.getPostAggregatorSpecs(),
query.getTopNMetricSpec()
.getMetricName(query.getDimensionSpec())
);

@Override
public byte[] computeCacheKey(TopNQuery query)
Expand Down Expand Up @@ -338,6 +343,10 @@ public Result<TopNResultValue> apply(Object input)
vals.put(factory.getName(), factory.deserialize(resultIter.next()));
}

for (PostAggregator postAgg : postAggs) {
vals.put(postAgg.getName(), postAgg.compute(vals));
}

retVal.add(vals);
}

Expand Down

0 comments on commit 3fb4225

Please sign in to comment.