diff --git a/grovedb/src/element/insert.rs b/grovedb/src/element/insert.rs index 030d1510..ae231766 100644 --- a/grovedb/src/element/insert.rs +++ b/grovedb/src/element/insert.rs @@ -279,7 +279,7 @@ impl Element { let changed = previous_element .as_ref() .map(|p| !p.eq_no_backreferences(&to_insert)) - .unwrap_or_default(); + .unwrap_or(true); if changed { let has_references = to_insert.has_backward_references(); @@ -673,12 +673,11 @@ mod tests { let batch = StorageBatch::new(); let mut merk = empty_path_merk(&*storage, &batch, &tx, grove_version); - let (inserted, previous) = Element::new_item(b"value2".to_vec()) + let (_, previous) = Element::new_item(b"value2".to_vec()) .insert_if_changed_value(&mut merk, b"another-key", None, grove_version) .unwrap() .expect("expected successful insertion 2"); - assert!(inserted); assert_eq!(previous, Some(Element::new_item(b"value".to_vec())),); storage @@ -703,12 +702,11 @@ mod tests { .insert(&mut merk, b"mykey", None, grove_version) .unwrap() .expect("expected successful insertion"); - let (inserted, previous) = Element::new_item(b"value2".to_vec()) + let (_, previous) = Element::new_item(b"value2".to_vec()) .insert_if_changed_value(&mut merk, b"another-key", None, grove_version) .unwrap() .expect("expected successful insertion 2"); - assert!(inserted); assert_eq!(previous, None); assert_eq!( diff --git a/grovedb/src/operations/insert/mod.rs b/grovedb/src/operations/insert/mod.rs index 14bc1a34..6a07b41b 100644 --- a/grovedb/src/operations/insert/mod.rs +++ b/grovedb/src/operations/insert/mod.rs @@ -850,7 +850,8 @@ mod tests { assert_eq!( cost, OperationCost { - seek_count: 3, // 1 to get tree, 1 to insert, 1 to insert into root tree + seek_count: 4, /* 1 to get tree, 1 to check prev value for ref propagation, 1 to + * insert, 1 to insert into root tree */ storage_cost: StorageCost { added_bytes: 149, replaced_bytes: 0, @@ -917,7 +918,7 @@ mod tests { assert_eq!( cost, OperationCost { - seek_count: 5, + seek_count: 6, storage_cost: StorageCost { added_bytes: 170, replaced_bytes: 84, // todo: verify @@ -1000,7 +1001,7 @@ mod tests { assert_eq!( cost, OperationCost { - seek_count: 7, + seek_count: 8, storage_cost: StorageCost { added_bytes: 170, replaced_bytes: 217, @@ -1079,7 +1080,7 @@ mod tests { assert_eq!( cost, OperationCost { - seek_count: 7, + seek_count: 8, storage_cost: StorageCost { added_bytes: 170, replaced_bytes: 217, // todo: verify @@ -1140,7 +1141,7 @@ mod tests { assert_eq!( cost, OperationCost { - seek_count: 3, // 1 to get tree, 1 to insert, 1 to insert into root tree + seek_count: 4, // 1 to get tree, 1 to insert, 1 to insert into root tree storage_cost: StorageCost { added_bytes: 153, replaced_bytes: 0, @@ -1405,7 +1406,7 @@ mod tests { assert_eq!( cost, OperationCost { - seek_count: 5, // todo: verify this + seek_count: 6, // todo: verify this storage_cost: StorageCost { added_bytes: 150, replaced_bytes: 78, @@ -1470,7 +1471,7 @@ mod tests { assert_eq!( cost, OperationCost { - seek_count: 3, // todo: verify this + seek_count: 4, // todo: verify this storage_cost: StorageCost { added_bytes: 156, replaced_bytes: 0, @@ -1564,7 +1565,7 @@ mod tests { assert_eq!( cost, OperationCost { - seek_count: 5, // todo: verify this + seek_count: 6, // todo: verify this storage_cost: StorageCost { added_bytes: 156, replaced_bytes: 78, @@ -1660,7 +1661,7 @@ mod tests { assert_eq!( cost, OperationCost { - seek_count: 5, // todo: verify this + seek_count: 6, // todo: verify this storage_cost: StorageCost { added_bytes: 156, replaced_bytes: 82, @@ -1729,13 +1730,13 @@ mod tests { assert_eq!( cost, OperationCost { - seek_count: 3, // todo: verify this + seek_count: 4, // todo: verify this storage_cost: StorageCost { added_bytes: 0, replaced_bytes: 112, removed_bytes: NoStorageRemoval }, - storage_loaded_bytes: 77, + storage_loaded_bytes: 124, hash_node_calls: 2, } ); @@ -1783,13 +1784,13 @@ mod tests { assert_eq!( cost, OperationCost { - seek_count: 6, // todo: verify this + seek_count: 7, // todo: verify this storage_cost: StorageCost { added_bytes: 0, replaced_bytes: 190, removed_bytes: NoStorageRemoval }, - storage_loaded_bytes: 230, // todo verify this + storage_loaded_bytes: 277, // todo verify this hash_node_calls: 8, } ); @@ -1837,13 +1838,13 @@ mod tests { assert_eq!( cost, OperationCost { - seek_count: 6, // todo: verify this + seek_count: 7, // todo: verify this storage_cost: StorageCost { added_bytes: 0, replaced_bytes: 248, removed_bytes: NoStorageRemoval }, - storage_loaded_bytes: 266, // todo verify this + storage_loaded_bytes: 411, // todo verify this hash_node_calls: 9, } ); @@ -1903,13 +1904,13 @@ mod tests { assert_eq!( cost, OperationCost { - seek_count: 9, // todo: verify this + seek_count: 10, // todo: verify this storage_cost: StorageCost { added_bytes: 0, replaced_bytes: 409, // todo: verify this removed_bytes: NoStorageRemoval }, - storage_loaded_bytes: 487, // todo verify this + storage_loaded_bytes: 632, // todo verify this hash_node_calls: 11, } ); @@ -1957,13 +1958,13 @@ mod tests { assert_eq!( cost, OperationCost { - seek_count: 6, // todo: verify this + seek_count: 7, // todo: verify this storage_cost: StorageCost { added_bytes: 0, replaced_bytes: 248, removed_bytes: NoStorageRemoval }, - storage_loaded_bytes: 276, // todo verify this + storage_loaded_bytes: 421, // todo verify this hash_node_calls: 9, } ); @@ -2011,13 +2012,13 @@ mod tests { assert_eq!( cost, OperationCost { - seek_count: 6, // todo: verify this + seek_count: 7, // todo: verify this storage_cost: StorageCost { added_bytes: 1, replaced_bytes: 191, // todo: verify this removed_bytes: NoStorageRemoval }, - storage_loaded_bytes: 231, + storage_loaded_bytes: 279, hash_node_calls: 8, } );