@@ -129,12 +129,12 @@ func addAndRemoveKeys(t *testing.T, keys []string, extraKeys []string, options .
129
129
}
130
130
}
131
131
132
- fmt .Println ("start flush" )
133
- bef := time .Now ()
132
+ // fmt.Println("start flush")
133
+ // bef := time.Now()
134
134
if err := begn .Flush (ctx ); err != nil {
135
135
t .Fatal (err )
136
136
}
137
- fmt .Println ("flush took: " , time .Since (bef ))
137
+ // fmt.Println("flush took: ", time.Since(bef))
138
138
c , err := cs .Put (ctx , begn )
139
139
if err != nil {
140
140
t .Fatal (err )
@@ -158,6 +158,8 @@ func addAndRemoveKeys(t *testing.T, keys []string, extraKeys []string, options .
158
158
}
159
159
}
160
160
161
+ printHamt (begn )
162
+
161
163
// create second hamt by adding and deleting the extra keys
162
164
for i := 0 ; i < len (extraKeys ); i ++ {
163
165
begn .Set (ctx , extraKeys [i ], randValue ())
@@ -188,6 +190,37 @@ func addAndRemoveKeys(t *testing.T, keys []string, extraKeys []string, options .
188
190
}
189
191
}
190
192
193
+ func printHamt (hamt * Node ) {
194
+ ctx := context .Background ()
195
+
196
+ var printNode func (n * Node , depth int )
197
+
198
+ printNode = func (n * Node , depth int ) {
199
+ c , err := n .store .Put (ctx , n )
200
+ if err != nil {
201
+ panic (err )
202
+ }
203
+ fmt .Printf ("%s‣ %v:\n " , strings .Repeat (" " , depth ), c )
204
+ for _ , p := range n .Pointers {
205
+ if p .isShard () {
206
+ child , err := p .loadChild (ctx , n .store , n .bitWidth , n .hash )
207
+ if err != nil {
208
+ panic (err )
209
+ }
210
+ printNode (child , depth + 1 )
211
+ } else {
212
+ var keys []string
213
+ for _ , pt := range p .KVs {
214
+ keys = append (keys , string (pt .Key ))
215
+ }
216
+ fmt .Printf ("%s⇶ [ %s ]\n " , strings .Repeat (" " , depth + 1 ), strings .Join (keys , ", " ))
217
+ }
218
+ }
219
+ }
220
+
221
+ printNode (hamt , 0 )
222
+ }
223
+
191
224
func dotGraphRec (n * Node , name * int ) {
192
225
cur := * name
193
226
for _ , p := range n .Pointers {
0 commit comments