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

Function index_maintained_on_put

nodedb/src/engine/kv/engine.rs:564–595  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

562
563 #[test]
564 fn index_maintained_on_put() {
565 let mut e = make_engine();
566 let n = now();
567
568 // Create index first (no backfill needed — empty collection).
569 e.register_index(1, "c", "status", 0, false, n);
570
571 // Insert.
572 e.put(
573 1,
574 "c",
575 b"k1",
576 &mp_obj(&[("status", "active")]),
577 0,
578 n,
579 Surrogate::ZERO,
580 );
581 assert_eq!(e.index_lookup_eq(1, "c", "status", b"active").len(), 1);
582
583 // Update: status changes.
584 e.put(
585 1,
586 "c",
587 b"k1",
588 &mp_obj(&[("status", "inactive")]),
589 0,
590 n,
591 Surrogate::ZERO,
592 );
593 assert!(e.index_lookup_eq(1, "c", "status", b"active").is_empty());
594 assert_eq!(e.index_lookup_eq(1, "c", "status", b"inactive").len(), 1);
595 }
596
597 #[test]
598 fn index_cleaned_on_delete() {

Callers

nothing calls this directly

Calls 5

nowFunction · 0.85
mp_objFunction · 0.85
register_indexMethod · 0.80
make_engineFunction · 0.70
putMethod · 0.45

Tested by

no test coverage detected