Skip to content

Commit

Permalink
Fix Tree Aggregation regression
Browse files Browse the repository at this point in the history
Recursion added descendants to an intermediate construct.
  • Loading branch information
PhRX committed Feb 6, 2017
1 parent 9a2a592 commit 951e05c
Showing 1 changed file with 7 additions and 5 deletions.
Expand Up @@ -83,23 +83,25 @@ public void add(String key, LeanNode node)
super.add(node); super.add(node);
} }


public void addChild(Node child) public Node addChild(Node child)
{ {
children.compute(child.getKey(), (k, v) -> v == null ? child : v.combine(child)); return children.compute(child.getKey(), (k, v) -> v == null ? child : v.combine(child));
} }


public void addChild(LeanNode child, CombinedGrouping grouping, boolean recurse) public void addChild(LeanNode child, CombinedGrouping grouping, boolean recurse)
{ {
// Construct intermediate Node
Node childNode = new Node(getAggregation()); Node childNode = new Node(getAggregation());
childNode.add(child); childNode.add(child);
childNode.setKey(grouping.apply(getAggregation().getSource(), child)); childNode.setKey(grouping.apply(getAggregation().getSource(), child));


addChild(childNode); // Aggregate it into existing children
Node newChild = addChild(childNode);


if (recurse) if (recurse)
{ {
child.getChildren().forEach( child.getChildren()
grandChild -> childNode.addChild(grandChild, grouping, recurse)); .forEach(grandChild -> newChild.addChild(grandChild, grouping, true));
} }
} }


Expand Down

0 comments on commit 951e05c

Please sign in to comment.