MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / incremental_rehash

Function incremental_rehash

nodedb/src/engine/kv/hash_table/api.rs:368–397  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

366
367 #[test]
368 fn incremental_rehash() {
369 let mut t = KvHashTable::new(16, 0.5, 2, 64);
370
371 // Fill to trigger rehash (>50% of 16 = >8 entries).
372 for i in 0..10 {
373 let key = format!("key{i:03}");
374 let val = format!("val{i:03}");
375 t.put(key.as_bytes(), val.as_bytes(), NO_EXPIRY, Surrogate::ZERO);
376 }
377
378 // Rehash should have been triggered.
379 // Continue inserting to drive incremental migration.
380 for i in 10..20 {
381 let key = format!("key{i:03}");
382 let val = format!("val{i:03}");
383 t.put(key.as_bytes(), val.as_bytes(), NO_EXPIRY, Surrogate::ZERO);
384 }
385
386 // All entries should be findable.
387 for i in 0..20 {
388 let key = format!("key{i:03}");
389 let val = format!("val{i:03}");
390 assert_eq!(
391 t.get(key.as_bytes(), 0),
392 Some(val.as_bytes()),
393 "missing key{i:03}"
394 );
395 }
396 assert_eq!(t.len(), 20);
397 }
398
399 #[test]
400 fn overflow_values() {

Callers

nothing calls this directly

Calls 2

putMethod · 0.45
as_bytesMethod · 0.45

Tested by

no test coverage detected