@@ -332,9 +332,9 @@ fn overwrite_one_item_incremental() {
332
332
Root: Metadata { dimensions: 2, items: RoaringBitmap<[0, 1, 2, 3, 4, 5]>, roots: [0], distance: "euclidean" }
333
333
Tree 0: SplitPlaneNormal(SplitPlaneNormal<euclidean> { left: Item(0), right: Tree(4), normal: [1.0000, 0.0000] })
334
334
Tree 1: Descendants(Descendants { descendants: [1, 5] })
335
- Tree 2: Descendants(Descendants { descendants: [3, 4] })
336
- Tree 3: SplitPlaneNormal(SplitPlaneNormal<euclidean> { left: Tree(2), right: Item(2), normal: [0.0000, 0.0000] })
335
+ Tree 3: SplitPlaneNormal(SplitPlaneNormal<euclidean> { left: Tree(5), right: Item(2), normal: [0.0000, 0.0000] })
337
336
Tree 4: SplitPlaneNormal(SplitPlaneNormal<euclidean> { left: Tree(1), right: Tree(3), normal: [0.0000, 0.0000] })
337
+ Tree 5: Descendants(Descendants { descendants: [3, 4] })
338
338
Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 0.0000] })
339
339
Item 1: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [1.0000, 0.0000] })
340
340
Item 2: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [2.0000, 0.0000] })
@@ -907,7 +907,6 @@ fn delete_extraneous_tree() {
907
907
"### ) ;
908
908
}
909
909
910
- // If we have multiple split node and empty all the branch of the top split node (root node)
911
910
// See https://github.com/meilisearch/arroy/issues/117
912
911
#[ test]
913
912
fn create_root_split_node_with_empty_child ( ) {
@@ -952,16 +951,33 @@ fn create_root_split_node_with_empty_child() {
952
951
==================
953
952
Dumping index 0
954
953
Root: Metadata { dimensions: 2, items: RoaringBitmap<[0, 2, 3, 4]>, roots: [0], distance: "euclidean" }
955
- Tree 0: SplitPlaneNormal(SplitPlaneNormal<euclidean> { left: Item(0), right: Tree(4), normal: [1.0000, 0.0000] })
956
- Tree 1: Descendants(Descendants { descendants: [] })
954
+ Tree 0: SplitPlaneNormal(SplitPlaneNormal<euclidean> { left: Item(0), right: Tree(3), normal: [1.0000, 0.0000] })
957
955
Tree 2: Descendants(Descendants { descendants: [3, 4] })
958
956
Tree 3: SplitPlaneNormal(SplitPlaneNormal<euclidean> { left: Tree(2), right: Item(2), normal: [0.0000, 0.0000] })
959
- Tree 4: SplitPlaneNormal(SplitPlaneNormal<euclidean> { left: Tree(1), right: Tree(3), normal: [0.0000, 0.0000] })
960
957
Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 0.0000] })
961
958
Item 2: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [2.0000, 0.0000] })
962
959
Item 3: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [3.0000, 0.0000] })
963
960
Item 4: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [4.0000, 0.0000] })
964
961
"### ) ;
962
+
963
+ let mut wtxn = handle. env . write_txn ( ) . unwrap ( ) ;
964
+ let writer = Writer :: new ( handle. database , 0 , 2 ) ;
965
+
966
+ // if we remove 0, then the root node must update itself as well
967
+ writer. del_item ( & mut wtxn, 0 ) . unwrap ( ) ;
968
+ writer. builder ( & mut rng) . n_trees ( 1 ) . build ( & mut wtxn) . unwrap ( ) ;
969
+ wtxn. commit ( ) . unwrap ( ) ;
970
+
971
+ insta:: assert_snapshot!( handle, @r###"
972
+ ==================
973
+ Dumping index 0
974
+ Root: Metadata { dimensions: 2, items: RoaringBitmap<[2, 3, 4]>, roots: [3], distance: "euclidean" }
975
+ Tree 2: Descendants(Descendants { descendants: [3, 4] })
976
+ Tree 3: SplitPlaneNormal(SplitPlaneNormal<euclidean> { left: Tree(2), right: Item(2), normal: [0.0000, 0.0000] })
977
+ Item 2: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [2.0000, 0.0000] })
978
+ Item 3: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [3.0000, 0.0000] })
979
+ Item 4: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [4.0000, 0.0000] })
980
+ "### ) ;
965
981
}
966
982
967
983
#[ test]
@@ -1053,20 +1069,19 @@ fn reuse_node_id() {
1053
1069
insta:: assert_snapshot!( handle, @r###"
1054
1070
==================
1055
1071
Dumping index 0
1056
- Root: Metadata { dimensions: 2, items: RoaringBitmap<[0, 1, 2, 3, 4, 5]>, roots: [0, 6 ], distance: "euclidean" }
1072
+ Root: Metadata { dimensions: 2, items: RoaringBitmap<[0, 1, 2, 3, 4, 5]>, roots: [0, 5 ], distance: "euclidean" }
1057
1073
Tree 0: SplitPlaneNormal(SplitPlaneNormal<euclidean> { left: Item(0), right: Tree(4), normal: [1.0000, 0.0000] })
1058
- Tree 1: Descendants(Descendants { descendants: [5 ] })
1059
- Tree 2: SplitPlaneNormal(SplitPlaneNormal<euclidean> { left: Tree(5), right: Item(1), normal: [0.0000, 0.0000 ] })
1060
- Tree 3: SplitPlaneNormal(SplitPlaneNormal<euclidean> { left: Tree(2), right: Item(2), normal: [0.0000, 0.0000 ] })
1074
+ Tree 1: SplitPlaneNormal(SplitPlaneNormal<euclidean> { left: Tree(2), right: Item(1), normal: [0.0000, 0.0000 ] })
1075
+ Tree 2: Descendants(Descendants { descendants: [4, 5 ] })
1076
+ Tree 3: Descendants(Descendants { descendants: [2, 3 ] })
1061
1077
Tree 4: SplitPlaneNormal(SplitPlaneNormal<euclidean> { left: Tree(1), right: Tree(3), normal: [0.0000, 0.0000] })
1062
- Tree 5: Descendants(Descendants { descendants: [3, 4] })
1063
- Tree 6: SplitPlaneNormal(SplitPlaneNormal<euclidean> { left: Tree(12), right: Item(0), normal: [-1.0000, 0.0000] })
1064
- Tree 7: Descendants(Descendants { descendants: [4, 5] })
1065
- Tree 8: SplitPlaneNormal(SplitPlaneNormal<euclidean> { left: Item(2), right: Tree(7), normal: [0.0000, 0.0000] })
1066
- Tree 9: Descendants(Descendants { descendants: [] })
1067
- Tree 10: SplitPlaneNormal(SplitPlaneNormal<euclidean> { left: Tree(8), right: Tree(9), normal: [0.0000, 0.0000] })
1068
- Tree 11: Descendants(Descendants { descendants: [1, 3] })
1069
- Tree 12: SplitPlaneNormal(SplitPlaneNormal<euclidean> { left: Tree(10), right: Tree(11), normal: [0.0000, 0.0000] })
1078
+ Tree 5: SplitPlaneNormal(SplitPlaneNormal<euclidean> { left: Tree(11), right: Item(0), normal: [-1.0000, 0.0000] })
1079
+ Tree 6: Descendants(Descendants { descendants: [4, 5] })
1080
+ Tree 7: SplitPlaneNormal(SplitPlaneNormal<euclidean> { left: Item(2), right: Tree(6), normal: [0.0000, 0.0000] })
1081
+ Tree 8: Descendants(Descendants { descendants: [] })
1082
+ Tree 9: SplitPlaneNormal(SplitPlaneNormal<euclidean> { left: Tree(7), right: Tree(8), normal: [0.0000, 0.0000] })
1083
+ Tree 10: Descendants(Descendants { descendants: [1, 3] })
1084
+ Tree 11: SplitPlaneNormal(SplitPlaneNormal<euclidean> { left: Tree(9), right: Tree(10), normal: [0.0000, 0.0000] })
1070
1085
Item 0: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [0.0000, 0.0000] })
1071
1086
Item 1: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [1.0000, 0.0000] })
1072
1087
Item 2: Leaf(Leaf { header: NodeHeaderEuclidean { bias: 0.0 }, vector: [2.0000, 0.0000] })
0 commit comments