From 9d18f6cd6f238854425a257036e5342096edbc97 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Sat, 11 Nov 2017 11:47:01 +0000 Subject: [PATCH] Extend joinResults to bump counters and add pass-through results Note all the existing addToResults calls are for endpoints where we don't need any counters. --- render/render.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/render/render.go b/render/render.go index 1d7983229..1787d8150 100644 --- a/render/render.go +++ b/render/render.go @@ -159,20 +159,28 @@ func newJoinResults() joinResults { } // Add Node M under id, creating a new result node if not already there -// and updating the mapping from old ID to new ID -// Note we do not update any counters for child topologies here, because addToResults -// is only ever called when m is an endpoint and we never look at endpoint counts -func (ret *joinResults) addToResults(m report.Node, id string, create func(string) report.Node) { +// incrementing a counter if nonblank, and updating the mapping from old ID to new ID +func (ret *joinResults) addToResults(m report.Node, id string, create func(string) report.Node, counters ...string) { result, exists := ret.nodes[id] if !exists { result = create(id) } result.Children = result.Children.Add(m) result.Children = result.Children.Merge(m.Children) + for _, c := range counters { + result.Counters = result.Counters.Add(c, 1) + } ret.nodes[id] = result ret.mapped[m.ID] = id } +// Add a copy of n straight into the results +func (ret *joinResults) passThrough(n report.Node) { + n.Adjacency = nil // fixupAdjacencies assumes all nodes start with blank lists + ret.nodes[n.ID] = n + ret.mapped[n.ID] = n.ID +} + // Rewrite Adjacency for new nodes in ret for original nodes in input func (ret *joinResults) fixupAdjacencies(input Nodes) { for _, n := range input.Nodes {