calculate postAggs while pulling from cache

This commit is contained in:
nishantmonu51 2014-04-22 11:25:21 +05:30
parent 7bafb71841
commit 3fb42251d9
1 changed files with 9 additions and 0 deletions

View File

@ -249,6 +249,11 @@ public class TopNQueryQueryToolChest extends QueryToolChest<Result<TopNResultVal
return new CacheStrategy<Result<TopNResultValue>, Object, TopNQuery>() return new CacheStrategy<Result<TopNResultValue>, Object, TopNQuery>()
{ {
private final List<AggregatorFactory> aggs = query.getAggregatorSpecs(); private final List<AggregatorFactory> aggs = query.getAggregatorSpecs();
private final List<PostAggregator> postAggs = AggregatorUtil.pruneDependentPostAgg(
query.getPostAggregatorSpecs(),
query.getTopNMetricSpec()
.getMetricName(query.getDimensionSpec())
);
@Override @Override
public byte[] computeCacheKey(TopNQuery query) public byte[] computeCacheKey(TopNQuery query)
@ -338,6 +343,10 @@ public class TopNQueryQueryToolChest extends QueryToolChest<Result<TopNResultVal
vals.put(factory.getName(), factory.deserialize(resultIter.next())); vals.put(factory.getName(), factory.deserialize(resultIter.next()));
} }
for (PostAggregator postAgg : postAggs) {
vals.put(postAgg.getName(), postAgg.compute(vals));
}
retVal.add(vals); retVal.add(vals);
} }