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

Function store_value_in

nodedb/src/engine/kv/hash_helpers.rs:89–100  ·  view source on GitHub ↗

Store a value, choosing inline or overflow based on the threshold.

(
    overflow: &mut SlabAllocator,
    value: &[u8],
    inline_threshold: usize,
)

Source from the content-addressed store, hash-verified

87
88/// Store a value, choosing inline or overflow based on the threshold.
89pub(super) fn store_value_in(
90 overflow: &mut SlabAllocator,
91 value: &[u8],
92 inline_threshold: usize,
93) -> KvValue {
94 if value.len() <= inline_threshold {
95 KvValue::Inline(value.to_vec())
96 } else {
97 let (index, len) = overflow.alloc(value);
98 KvValue::Overflow { index, len }
99 }
100}
101
102/// Free overflow storage if the value is an overflow entry.
103pub(super) fn free_value_from(value: &KvValue, overflow: &mut SlabAllocator) {

Callers 1

putMethod · 0.85

Calls 3

lenMethod · 0.45
to_vecMethod · 0.45
allocMethod · 0.45

Tested by

no test coverage detected