public void accumulate(TaggedLogAPIEntity entity) throws Exception{ List<Double> preAggregatedValues = createPreAggregatedValues(entity); // aggregate to root first addDatapoint(root, preAggregatedValues); // go through hierarchical tree HierarchicalAggregateEntity current = root; int i = 0; for(String groupbyField : groupbyFields){ // determine groupbyFieldValue from tag or fields String groupbyFieldValue = determineGroupbyFieldValue(entity, groupbyField, i); SortedMap<String, HierarchicalAggregateEntity> children = current.getChildren(); if(children.get(groupbyFieldValue) == null){ HierarchicalAggregateEntity tmp = new HierarchicalAggregateEntity(); children.put(groupbyFieldValue, tmp); } children.get(groupbyFieldValue).setKey(groupbyFieldValue); addDatapoint(children.get(groupbyFieldValue), preAggregatedValues); current = children.get(groupbyFieldValue); } }
public HierarchicalAggregateEntity result(){ finalizeHierarchicalAggregateEntity(root); return this.root; } }
HierarchicalAggregator agg = new HierarchicalAggregator(groupbyFields, comp.aggregateFunctionTypes(), comp.aggregateFields()); reader.register(agg); reader.readAsStream(); if(comp.sortOptions() == null){ result.setObj(agg.result()); }else{ // has sort options result.setObj(PostHierarchicalAggregateSort.sort(agg.result(), comp.sortOptions()));
HierarchicalAggregator agg = new HierarchicalAggregator(groupbyFields, comp.aggregateFunctionTypes(), comp.aggregateFields()); reader.register(agg); reader.readAsStream(); if(comp.sortOptions() == null){ result.setObj(agg.result()); }else{ // has sort options result.setObj(PostHierarchicalAggregateSort.sort(agg.result(), comp.sortOptions()));
private void finalizeHierarchicalAggregateEntity(HierarchicalAggregateEntity entity){ for(GroupbyBucket.Function f : entity.getTmpValues()){ entity.getValues().add(f.result()); } for(HierarchicalAggregateEntity child : entity.getChildren().values()){ finalizeHierarchicalAggregateEntity(child); } entity.setTmpValues(null); }