MCPcopy Create free account
hub / github.com/KentBeck/BPlusTree3 / test_leaf_caching_optimization_proof

Function test_leaf_caching_optimization_proof

rust/src/lib.rs:184–213  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

182
183 #[test]
184 fn test_leaf_caching_optimization_proof() {
185 let mut tree = BPlusTreeMap::new(4).unwrap(); // Small capacity to force multiple leaves
186
187 for i in 0..20 {
188 tree.insert(i, i * 100);
189 }
190
191 let mut iter = tree.items();
192 let first_item = iter.next();
193 assert_eq!(first_item, Some((&0, &0)));
194 assert!(
195 iter.current_leaf_ref.is_some(),
196 "Leaf reference should be cached after first next() call"
197 );
198
199 let second_item = iter.next();
200 assert_eq!(second_item, Some((&1, &100)));
201 assert!(
202 iter.current_leaf_ref.is_some(),
203 "Leaf reference should remain cached within same leaf"
204 );
205
206 let mut count = 2; // Already consumed 2 items
207 for (k, v) in iter {
208 assert_eq!(*k, count);
209 assert_eq!(*v, count * 100);
210 count += 1;
211 }
212 assert_eq!(count, 20);
213 }
214
215 #[test]
216 fn test_fast_iterator_also_uses_leaf_caching() {

Callers

nothing calls this directly

Calls 3

nextMethod · 0.80
insertMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected