aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--weed/util/bounded_tree/bounded_tree.go6
-rw-r--r--weed/util/bounded_tree/bounded_tree_test.go9
2 files changed, 11 insertions, 4 deletions
diff --git a/weed/util/bounded_tree/bounded_tree.go b/weed/util/bounded_tree/bounded_tree.go
index efe2ff93a..8c99ad83d 100644
--- a/weed/util/bounded_tree/bounded_tree.go
+++ b/weed/util/bounded_tree/bounded_tree.go
@@ -1,8 +1,6 @@
package bounded_tree
import (
- "fmt"
-
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/util"
)
@@ -135,7 +133,7 @@ func (t *BoundedTree) HasVisited(p util.FullPath) bool {
}
components := p.Split()
- fmt.Printf("components %v %d\n", components, len(components))
+ // fmt.Printf("components %v %d\n", components, len(components))
return t.hasVisited(t.root, util.FullPath("/"), components, 0)
}
@@ -149,7 +147,7 @@ func (t *BoundedTree) hasVisited(n *Node, currentPath util.FullPath, components
return false
}
- fmt.Printf(" hasVisited child %v %+v %d\n", currentPath, components, i)
+ // fmt.Printf(" hasVisited child %v %+v %d\n", currentPath, components, i)
if i >= len(components) {
return true
diff --git a/weed/util/bounded_tree/bounded_tree_test.go b/weed/util/bounded_tree/bounded_tree_test.go
index 331cc46c0..2328f0497 100644
--- a/weed/util/bounded_tree/bounded_tree_test.go
+++ b/weed/util/bounded_tree/bounded_tree_test.go
@@ -62,6 +62,15 @@ func TestBoundedTree(t *testing.T) {
tree.EnsureVisited(util.FullPath("/a/b/c"), visitFn)
assert.Equal(t, true, tree.HasVisited(util.FullPath("/a/b")))
+ assert.Equal(t, true, tree.HasVisited(util.FullPath("/a/b/c")))
+ assert.Equal(t, false, tree.HasVisited(util.FullPath("/a/b/c/d")))
+ assert.Equal(t, false, tree.HasVisited(util.FullPath("/a/b/e")))
+ assert.Equal(t, false, tree.HasVisited(util.FullPath("/a/f")))
+ assert.Equal(t, false, tree.HasVisited(util.FullPath("/g")))
+ assert.Equal(t, false, tree.HasVisited(util.FullPath("/h")))
+ assert.Equal(t, true, tree.HasVisited(util.FullPath("/")))
+ assert.Equal(t, true, tree.HasVisited(util.FullPath("/x")))
+ assert.Equal(t, false, tree.HasVisited(util.FullPath("/a/b/e/x")))
printMap(tree.root.Children)