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

Function large_doc_uses_hashmap

nodedb-query/src/msgpack_scan/index.rs:171–185  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

169
170 #[test]
171 fn large_doc_uses_hashmap() {
172 let mut map = serde_json::Map::new();
173 for i in 0..20 {
174 map.insert(format!("field_{i}"), json!(i));
175 }
176 let buf = encode(&serde_json::Value::Object(map));
177 let idx = FieldIndex::build(&buf, 0).unwrap();
178 assert_eq!(idx.len(), 20);
179 assert!(matches!(idx.inner, IndexInner::Map(_)));
180
181 for i in 0..20 {
182 let (s, _) = idx.get(&format!("field_{i}")).unwrap();
183 assert_eq!(read_i64(&buf, s), Some(i));
184 }
185 }
186
187 #[test]
188 fn not_a_map() {

Callers

nothing calls this directly

Calls 3

encodeFunction · 0.70
insertMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected