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

Method build_key

nodedb/src/engine/kv/index.rs:158–167  ·  view source on GitHub ↗

Build a composite key from individual field values. Values are concatenated with `\0` separator. This preserves lexicographic ordering for prefix scans on leading fields. Limitation:** field values must not contain null bytes (`\0`), as they are used as separators. This holds for typical KV keys (strings, UUIDs, integers encoded as big-endian bytes).

(values: &[&[u8]])

Source from the content-addressed store, hash-verified

156 /// are used as separators. This holds for typical KV keys (strings, UUIDs,
157 /// integers encoded as big-endian bytes).
158 fn build_key(values: &[&[u8]]) -> Vec<u8> {
159 let mut key = Vec::new();
160 for (i, v) in values.iter().enumerate() {
161 if i > 0 {
162 key.push(0); // Null separator.
163 }
164 key.extend_from_slice(v);
165 }
166 key
167 }
168
169 /// Insert a composite entry.
170 pub fn insert(&mut self, field_values: &[&[u8]], primary_key: Vec<u8>) {

Callers

nothing calls this directly

Calls 2

iterMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected