|
@ -119,12 +119,6 @@ func TestAddHasCountFindIterateRemove(t *testing.T) { |
|
|
if has := bpt.Has(randstr(10)); has { |
|
|
if has := bpt.Has(randstr(10)); has { |
|
|
t.Error("Table has extra key") |
|
|
t.Error("Table has extra key") |
|
|
} |
|
|
} |
|
|
if count := bpt.Count(r.key); count != 1 { |
|
|
|
|
|
t.Error(bpt, "Missing key") |
|
|
|
|
|
} |
|
|
|
|
|
if count := bpt.Count(randstr(10)); count != 0 { |
|
|
|
|
|
t.Error("Table has extra key") |
|
|
|
|
|
} |
|
|
|
|
|
for k, v, next := bpt.Find(r.key)(); next != nil; k, v, next = next() { |
|
|
for k, v, next := bpt.Find(r.key)(); next != nil; k, v, next = next() { |
|
|
if !k.Equals(r.key) { |
|
|
if !k.Equals(r.key) { |
|
|
t.Error(bpt, "Find Failed Key Error") |
|
|
t.Error(bpt, "Find Failed Key Error") |
|
@ -190,9 +184,6 @@ func TestAddHasCountFindIterateRemove(t *testing.T) { |
|
|
if has := bpt.Has(r.key); !has { |
|
|
if has := bpt.Has(r.key); !has { |
|
|
t.Error(bpt, "Missing key") |
|
|
t.Error(bpt, "Missing key") |
|
|
} |
|
|
} |
|
|
if count := bpt.Count(r.key); count != 1 { |
|
|
|
|
|
t.Error(bpt, "Missing key") |
|
|
|
|
|
} |
|
|
|
|
|
if err := bpt.RemoveWhere(r.key, func(value interface{}) bool { return true }); err != nil { |
|
|
if err := bpt.RemoveWhere(r.key, func(value interface{}) bool { return true }); err != nil { |
|
|
t.Fatal(bpt, err) |
|
|
t.Fatal(bpt, err) |
|
|
} |
|
|
} |
|
@ -275,7 +266,7 @@ func TestBpMap(t *testing.T) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func Test_get_start(t *testing.T) { |
|
|
func Test_get_start(t *testing.T) { |
|
|
root := NewLeaf(2, false) |
|
|
|
|
|
|
|
|
root := NewLeaf(2) |
|
|
root, err := root.put(Int(1), 1) |
|
|
root, err := root.put(Int(1), 1) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
t.Error(err) |
|
|
t.Error(err) |
|
@ -344,7 +335,7 @@ func Test_get_start(t *testing.T) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func Test_get_end(t *testing.T) { |
|
|
func Test_get_end(t *testing.T) { |
|
|
root := NewLeaf(3, false) |
|
|
|
|
|
|
|
|
root := NewLeaf(3) |
|
|
root, err := root.put(Int(1), -1) |
|
|
root, err := root.put(Int(1), -1) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
t.Fatal(err) |
|
|
t.Fatal(err) |
|
@ -436,7 +427,7 @@ func Test_get_end(t *testing.T) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func Test_put_no_root_split(t *testing.T) { |
|
|
func Test_put_no_root_split(t *testing.T) { |
|
|
a := NewLeaf(2, false) |
|
|
|
|
|
|
|
|
a := NewLeaf(2) |
|
|
if err := a.put_kv(Int(1), 1); err != nil { |
|
|
if err := a.put_kv(Int(1), 1); err != nil { |
|
|
t.Error(err) |
|
|
t.Error(err) |
|
|
} |
|
|
} |
|
@ -470,7 +461,7 @@ func Test_put_no_root_split(t *testing.T) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func Test_put_root_split(t *testing.T) { |
|
|
func Test_put_root_split(t *testing.T) { |
|
|
a := NewLeaf(2, false) |
|
|
|
|
|
|
|
|
a := NewLeaf(2) |
|
|
p, err := a.put(Int(1), 1) |
|
|
p, err := a.put(Int(1), 1) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
t.Error(err) |
|
|
t.Error(err) |
|
@ -520,7 +511,7 @@ func Test_put_root_split(t *testing.T) { |
|
|
|
|
|
|
|
|
func Test_internal_insert_no_split(t *testing.T) { |
|
|
func Test_internal_insert_no_split(t *testing.T) { |
|
|
a := NewInternal(3) |
|
|
a := NewInternal(3) |
|
|
leaf := NewLeaf(1, false) |
|
|
|
|
|
|
|
|
leaf := NewLeaf(1) |
|
|
if err := leaf.put_kv(Int(1), 1); err != nil { |
|
|
if err := leaf.put_kv(Int(1), 1); err != nil { |
|
|
t.Error(err) |
|
|
t.Error(err) |
|
|
} |
|
|
} |
|
@ -548,7 +539,7 @@ func Test_internal_insert_no_split(t *testing.T) { |
|
|
|
|
|
|
|
|
func Test_internal_insert_split_less(t *testing.T) { |
|
|
func Test_internal_insert_split_less(t *testing.T) { |
|
|
a := NewInternal(3) |
|
|
a := NewInternal(3) |
|
|
leaf := NewLeaf(1, false) |
|
|
|
|
|
|
|
|
leaf := NewLeaf(1) |
|
|
if err := leaf.put_kv(Int(1), 1); err != nil { |
|
|
if err := leaf.put_kv(Int(1), 1); err != nil { |
|
|
t.Error(err) |
|
|
t.Error(err) |
|
|
} |
|
|
} |
|
@ -658,7 +649,7 @@ func Test_internal_split_greater(t *testing.T) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func Test_leaf_insert_no_split(t *testing.T) { |
|
|
func Test_leaf_insert_no_split(t *testing.T) { |
|
|
a := NewLeaf(3, false) |
|
|
|
|
|
|
|
|
a := NewLeaf(3) |
|
|
insert_linked_list_node(a, nil, nil) |
|
|
insert_linked_list_node(a, nil, nil) |
|
|
if err := a.put_kv(Int(1), 1); err != nil { |
|
|
if err := a.put_kv(Int(1), 1); err != nil { |
|
|
t.Error(err) |
|
|
t.Error(err) |
|
@ -684,7 +675,7 @@ func Test_leaf_insert_no_split(t *testing.T) { |
|
|
|
|
|
|
|
|
// tests the defer to split logic
|
|
|
// tests the defer to split logic
|
|
|
func Test_leaf_insert_split_less(t *testing.T) { |
|
|
func Test_leaf_insert_split_less(t *testing.T) { |
|
|
a := NewLeaf(3, false) |
|
|
|
|
|
|
|
|
a := NewLeaf(3) |
|
|
insert_linked_list_node(a, nil, nil) |
|
|
insert_linked_list_node(a, nil, nil) |
|
|
if err := a.put_kv(Int(1), 1); err != nil { |
|
|
if err := a.put_kv(Int(1), 1); err != nil { |
|
|
t.Error(err) |
|
|
t.Error(err) |
|
@ -715,7 +706,7 @@ func Test_leaf_insert_split_less(t *testing.T) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func Test_leaf_split_less(t *testing.T) { |
|
|
func Test_leaf_split_less(t *testing.T) { |
|
|
a := NewLeaf(3, false) |
|
|
|
|
|
|
|
|
a := NewLeaf(3) |
|
|
insert_linked_list_node(a, nil, nil) |
|
|
insert_linked_list_node(a, nil, nil) |
|
|
if err := a.put_kv(Int(1), 1); err != nil { |
|
|
if err := a.put_kv(Int(1), 1); err != nil { |
|
|
t.Error(err) |
|
|
t.Error(err) |
|
@ -746,7 +737,7 @@ func Test_leaf_split_less(t *testing.T) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func Test_leaf_split_equal(t *testing.T) { |
|
|
func Test_leaf_split_equal(t *testing.T) { |
|
|
a := NewLeaf(3, false) |
|
|
|
|
|
|
|
|
a := NewLeaf(3) |
|
|
insert_linked_list_node(a, nil, nil) |
|
|
insert_linked_list_node(a, nil, nil) |
|
|
if err := a.put_kv(Int(1), 1); err != nil { |
|
|
if err := a.put_kv(Int(1), 1); err != nil { |
|
|
t.Error(err) |
|
|
t.Error(err) |
|
@ -777,7 +768,7 @@ func Test_leaf_split_equal(t *testing.T) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func Test_leaf_split_greater(t *testing.T) { |
|
|
func Test_leaf_split_greater(t *testing.T) { |
|
|
a := NewLeaf(3, false) |
|
|
|
|
|
|
|
|
a := NewLeaf(3) |
|
|
insert_linked_list_node(a, nil, nil) |
|
|
insert_linked_list_node(a, nil, nil) |
|
|
if err := a.put_kv(Int(1), 1); err != nil { |
|
|
if err := a.put_kv(Int(1), 1); err != nil { |
|
|
t.Error(err) |
|
|
t.Error(err) |
|
@ -809,13 +800,13 @@ func Test_leaf_split_greater(t *testing.T) { |
|
|
|
|
|
|
|
|
// tests the defer logic
|
|
|
// tests the defer logic
|
|
|
func Test_pure_leaf_insert_split_less(t *testing.T) { |
|
|
func Test_pure_leaf_insert_split_less(t *testing.T) { |
|
|
a := NewLeaf(2, false) |
|
|
|
|
|
|
|
|
a := NewLeaf(2) |
|
|
insert_linked_list_node(a, nil, nil) |
|
|
insert_linked_list_node(a, nil, nil) |
|
|
b := NewLeaf(2, false) |
|
|
|
|
|
|
|
|
b := NewLeaf(2) |
|
|
insert_linked_list_node(b, a, nil) |
|
|
insert_linked_list_node(b, a, nil) |
|
|
c := NewLeaf(2, false) |
|
|
|
|
|
|
|
|
c := NewLeaf(2) |
|
|
insert_linked_list_node(c, b, nil) |
|
|
insert_linked_list_node(c, b, nil) |
|
|
d := NewLeaf(2, false) |
|
|
|
|
|
|
|
|
d := NewLeaf(2) |
|
|
insert_linked_list_node(d, c, nil) |
|
|
insert_linked_list_node(d, c, nil) |
|
|
if err := a.put_kv(Int(3), 1); err != nil { |
|
|
if err := a.put_kv(Int(3), 1); err != nil { |
|
|
t.Error(err) |
|
|
t.Error(err) |
|
@ -882,13 +873,13 @@ func Test_pure_leaf_insert_split_less(t *testing.T) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func Test_pure_leaf_split_less(t *testing.T) { |
|
|
func Test_pure_leaf_split_less(t *testing.T) { |
|
|
a := NewLeaf(2, false) |
|
|
|
|
|
|
|
|
a := NewLeaf(2) |
|
|
insert_linked_list_node(a, nil, nil) |
|
|
insert_linked_list_node(a, nil, nil) |
|
|
b := NewLeaf(2, false) |
|
|
|
|
|
|
|
|
b := NewLeaf(2) |
|
|
insert_linked_list_node(b, a, nil) |
|
|
insert_linked_list_node(b, a, nil) |
|
|
c := NewLeaf(2, false) |
|
|
|
|
|
|
|
|
c := NewLeaf(2) |
|
|
insert_linked_list_node(c, b, nil) |
|
|
insert_linked_list_node(c, b, nil) |
|
|
d := NewLeaf(2, false) |
|
|
|
|
|
|
|
|
d := NewLeaf(2) |
|
|
insert_linked_list_node(d, c, nil) |
|
|
insert_linked_list_node(d, c, nil) |
|
|
if err := a.put_kv(Int(3), 1); err != nil { |
|
|
if err := a.put_kv(Int(3), 1); err != nil { |
|
|
t.Error(err) |
|
|
t.Error(err) |
|
@ -955,13 +946,13 @@ func Test_pure_leaf_split_less(t *testing.T) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func Test_pure_leaf_split_equal(t *testing.T) { |
|
|
func Test_pure_leaf_split_equal(t *testing.T) { |
|
|
a := NewLeaf(2, false) |
|
|
|
|
|
|
|
|
a := NewLeaf(2) |
|
|
insert_linked_list_node(a, nil, nil) |
|
|
insert_linked_list_node(a, nil, nil) |
|
|
b := NewLeaf(2, false) |
|
|
|
|
|
|
|
|
b := NewLeaf(2) |
|
|
insert_linked_list_node(b, a, nil) |
|
|
insert_linked_list_node(b, a, nil) |
|
|
c := NewLeaf(2, false) |
|
|
|
|
|
|
|
|
c := NewLeaf(2) |
|
|
insert_linked_list_node(c, b, nil) |
|
|
insert_linked_list_node(c, b, nil) |
|
|
d := NewLeaf(2, false) |
|
|
|
|
|
|
|
|
d := NewLeaf(2) |
|
|
insert_linked_list_node(d, c, nil) |
|
|
insert_linked_list_node(d, c, nil) |
|
|
if err := a.put_kv(Int(3), 1); err != nil { |
|
|
if err := a.put_kv(Int(3), 1); err != nil { |
|
|
t.Error(err) |
|
|
t.Error(err) |
|
@ -1019,13 +1010,13 @@ func Test_pure_leaf_split_equal(t *testing.T) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func Test_pure_leaf_split_greater(t *testing.T) { |
|
|
func Test_pure_leaf_split_greater(t *testing.T) { |
|
|
a := NewLeaf(2, false) |
|
|
|
|
|
|
|
|
a := NewLeaf(2) |
|
|
insert_linked_list_node(a, nil, nil) |
|
|
insert_linked_list_node(a, nil, nil) |
|
|
b := NewLeaf(2, false) |
|
|
|
|
|
|
|
|
b := NewLeaf(2) |
|
|
insert_linked_list_node(b, a, nil) |
|
|
insert_linked_list_node(b, a, nil) |
|
|
c := NewLeaf(2, false) |
|
|
|
|
|
|
|
|
c := NewLeaf(2) |
|
|
insert_linked_list_node(c, b, nil) |
|
|
insert_linked_list_node(c, b, nil) |
|
|
d := NewLeaf(2, false) |
|
|
|
|
|
|
|
|
d := NewLeaf(2) |
|
|
insert_linked_list_node(d, c, nil) |
|
|
insert_linked_list_node(d, c, nil) |
|
|
if err := a.put_kv(Int(3), 1); err != nil { |
|
|
if err := a.put_kv(Int(3), 1); err != nil { |
|
|
t.Error(err) |
|
|
t.Error(err) |
|
@ -1089,13 +1080,13 @@ func Test_pure_leaf_split_greater(t *testing.T) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func Test_find_end_of_pure_run(t *testing.T) { |
|
|
func Test_find_end_of_pure_run(t *testing.T) { |
|
|
a := NewLeaf(2, false) |
|
|
|
|
|
|
|
|
a := NewLeaf(2) |
|
|
insert_linked_list_node(a, nil, nil) |
|
|
insert_linked_list_node(a, nil, nil) |
|
|
b := NewLeaf(2, false) |
|
|
|
|
|
|
|
|
b := NewLeaf(2) |
|
|
insert_linked_list_node(b, a, nil) |
|
|
insert_linked_list_node(b, a, nil) |
|
|
c := NewLeaf(2, false) |
|
|
|
|
|
|
|
|
c := NewLeaf(2) |
|
|
insert_linked_list_node(c, b, nil) |
|
|
insert_linked_list_node(c, b, nil) |
|
|
d := NewLeaf(2, false) |
|
|
|
|
|
|
|
|
d := NewLeaf(2) |
|
|
insert_linked_list_node(d, c, nil) |
|
|
insert_linked_list_node(d, c, nil) |
|
|
if err := a.put_kv(Int(3), 1); err != nil { |
|
|
if err := a.put_kv(Int(3), 1); err != nil { |
|
|
t.Error(err) |
|
|
t.Error(err) |
|
@ -1125,13 +1116,13 @@ func Test_find_end_of_pure_run(t *testing.T) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func Test_insert_linked_list_node(t *testing.T) { |
|
|
func Test_insert_linked_list_node(t *testing.T) { |
|
|
a := NewLeaf(1, false) |
|
|
|
|
|
|
|
|
a := NewLeaf(1) |
|
|
insert_linked_list_node(a, nil, nil) |
|
|
insert_linked_list_node(a, nil, nil) |
|
|
b := NewLeaf(2, false) |
|
|
|
|
|
|
|
|
b := NewLeaf(2) |
|
|
insert_linked_list_node(b, a, nil) |
|
|
insert_linked_list_node(b, a, nil) |
|
|
c := NewLeaf(3, false) |
|
|
|
|
|
|
|
|
c := NewLeaf(3) |
|
|
insert_linked_list_node(c, b, nil) |
|
|
insert_linked_list_node(c, b, nil) |
|
|
d := NewLeaf(4, false) |
|
|
|
|
|
|
|
|
d := NewLeaf(4) |
|
|
insert_linked_list_node(d, a, b) |
|
|
insert_linked_list_node(d, a, b) |
|
|
if a.prev != nil { |
|
|
if a.prev != nil { |
|
|
t.Errorf("expected a.prev == nil") |
|
|
t.Errorf("expected a.prev == nil") |
|
@ -1160,13 +1151,13 @@ func Test_insert_linked_list_node(t *testing.T) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func Test_remove_linked_list_node(t *testing.T) { |
|
|
func Test_remove_linked_list_node(t *testing.T) { |
|
|
a := NewLeaf(1, false) |
|
|
|
|
|
|
|
|
a := NewLeaf(1) |
|
|
insert_linked_list_node(a, nil, nil) |
|
|
insert_linked_list_node(a, nil, nil) |
|
|
b := NewLeaf(2, false) |
|
|
|
|
|
|
|
|
b := NewLeaf(2) |
|
|
insert_linked_list_node(b, a, nil) |
|
|
insert_linked_list_node(b, a, nil) |
|
|
c := NewLeaf(3, false) |
|
|
|
|
|
|
|
|
c := NewLeaf(3) |
|
|
insert_linked_list_node(c, b, nil) |
|
|
insert_linked_list_node(c, b, nil) |
|
|
d := NewLeaf(4, false) |
|
|
|
|
|
|
|
|
d := NewLeaf(4) |
|
|
insert_linked_list_node(d, a, b) |
|
|
insert_linked_list_node(d, a, b) |
|
|
if a.prev != nil { |
|
|
if a.prev != nil { |
|
|
t.Errorf("expected a.prev == nil") |
|
|
t.Errorf("expected a.prev == nil") |
|
@ -1235,8 +1226,8 @@ func Test_remove_linked_list_node(t *testing.T) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func Test_balance_leaf_nodes_with_dup(t *testing.T) { |
|
|
func Test_balance_leaf_nodes_with_dup(t *testing.T) { |
|
|
a := NewLeaf(3, false) |
|
|
|
|
|
b := NewLeaf(3, false) |
|
|
|
|
|
|
|
|
a := NewLeaf(3) |
|
|
|
|
|
b := NewLeaf(3) |
|
|
if err := a.put_kv(Int(1), 1); err != nil { |
|
|
if err := a.put_kv(Int(1), 1); err != nil { |
|
|
t.Error(err) |
|
|
t.Error(err) |
|
|
} |
|
|
} |
|
@ -1256,8 +1247,8 @@ func Test_balance_leaf_nodes_with_dup(t *testing.T) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func Test_balance_leaf_nodes(t *testing.T) { |
|
|
func Test_balance_leaf_nodes(t *testing.T) { |
|
|
a := NewLeaf(7, false) |
|
|
|
|
|
b := NewLeaf(7, false) |
|
|
|
|
|
|
|
|
a := NewLeaf(7) |
|
|
|
|
|
b := NewLeaf(7) |
|
|
if err := a.put_kv(Int(1), 1); err != nil { |
|
|
if err := a.put_kv(Int(1), 1); err != nil { |
|
|
t.Error(err) |
|
|
t.Error(err) |
|
|
} |
|
|
} |
|
|