You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@htrace.apache.org by cm...@apache.org on 2015/02/26 22:24:15 UTC

incubator-htrace git commit: HTRACE-117. graph.go: sort children array to get deterministic output (cmccabe)

Repository: incubator-htrace
Updated Branches:
  refs/heads/master 0fd383546 -> e77266210


HTRACE-117. graph.go: sort children array to get deterministic output (cmccabe)


Project: http://git-wip-us.apache.org/repos/asf/incubator-htrace/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-htrace/commit/e7726621
Tree: http://git-wip-us.apache.org/repos/asf/incubator-htrace/tree/e7726621
Diff: http://git-wip-us.apache.org/repos/asf/incubator-htrace/diff/e7726621

Branch: refs/heads/master
Commit: e772662101f5b94bbbb11aa560cc1e1bdce17866
Parents: 0fd3835
Author: Colin P. Mccabe <cm...@apache.org>
Authored: Wed Feb 25 17:41:46 2015 -0800
Committer: Colin P. Mccabe <cm...@apache.org>
Committed: Thu Feb 26 13:24:09 2015 -0800

----------------------------------------------------------------------
 htrace-core/src/go/src/org/apache/htrace/htrace/graph.go      | 5 +++--
 htrace-core/src/go/src/org/apache/htrace/htrace/graph_test.go | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/e7726621/htrace-core/src/go/src/org/apache/htrace/htrace/graph.go
----------------------------------------------------------------------
diff --git a/htrace-core/src/go/src/org/apache/htrace/htrace/graph.go b/htrace-core/src/go/src/org/apache/htrace/htrace/graph.go
index fd55592..36951de 100644
--- a/htrace-core/src/go/src/org/apache/htrace/htrace/graph.go
+++ b/htrace-core/src/go/src/org/apache/htrace/htrace/graph.go
@@ -71,7 +71,7 @@ func spansToDot(spans common.SpanSlice, writer io.Writer) error {
 			idMap[span.Id] = span
 		}
 	}
-	childMap := make(map[common.SpanId][]*common.Span)
+	childMap := make(map[common.SpanId]common.SpanSlice)
 	for i := range spans {
 		child := spans[i]
 		for j := range child.Parents {
@@ -82,7 +82,7 @@ func spansToDot(spans common.SpanSlice, writer io.Writer) error {
 			} else {
 				children := childMap[parent.Id]
 				if children == nil {
-					children = make([]*common.Span, 0)
+					children = make(common.SpanSlice, 0)
 				}
 				children = append(children, child)
 				childMap[parent.Id] = children
@@ -99,6 +99,7 @@ func spansToDot(spans common.SpanSlice, writer io.Writer) error {
 	// Write out the edges between nodes... the parent/children relationships
 	for i := range spans {
 		children := childMap[spans[i].Id]
+		sort.Sort(children)
 		if children != nil {
 			for c := range children {
 				w.Printf(fmt.Sprintf(`  "%s" -> "%s";`+"\n",

http://git-wip-us.apache.org/repos/asf/incubator-htrace/blob/e7726621/htrace-core/src/go/src/org/apache/htrace/htrace/graph_test.go
----------------------------------------------------------------------
diff --git a/htrace-core/src/go/src/org/apache/htrace/htrace/graph_test.go b/htrace-core/src/go/src/org/apache/htrace/htrace/graph_test.go
index 6cf0c3a..3003b3f 100644
--- a/htrace-core/src/go/src/org/apache/htrace/htrace/graph_test.go
+++ b/htrace-core/src/go/src/org/apache/htrace/htrace/graph_test.go
@@ -71,9 +71,9 @@ func TestSpansToDot(t *testing.T) {
 		t.Fatalf("spansToDot failed: error %s\n", err.Error())
 	}
 	EXPECTED_STR := `digraph spans {
-  "e2c7273efb280a8c" [label="ClientNamenodeProtocol#getBlockLocations"];
   "6af3cc058e5d829d" [label="newDFSInputStream"];
   "75d16cc5b2c07d8a" [label="getBlockLocations"];
+  "e2c7273efb280a8c" [label="ClientNamenodeProtocol#getBlockLocations"];
   "6af3cc058e5d829d" -> "75d16cc5b2c07d8a";
   "75d16cc5b2c07d8a" -> "e2c7273efb280a8c";
 }`