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

Function decode

nodedb-codec/src/fastlanes/mod.rs:71–103  ·  view source on GitHub ↗

Decode FOR + bit-packed bytes back to i64 values.

(data: &[u8])

Source from the content-addressed store, hash-verified

69
70/// Decode FOR + bit-packed bytes back to i64 values.
71pub fn decode(data: &[u8]) -> Result<Vec<i64>, CodecError> {
72 if data.len() < GLOBAL_HEADER_SIZE {
73 return Err(CodecError::Truncated {
74 expected: GLOBAL_HEADER_SIZE,
75 actual: data.len(),
76 });
77 }
78
79 let total_count = u32::from_le_bytes([data[0], data[1], data[2], data[3]]) as usize;
80 let block_count = u16::from_le_bytes([data[4], data[5]]) as usize;
81
82 if total_count == 0 {
83 return Ok(Vec::new());
84 }
85
86 let mut values = Vec::with_capacity(total_count);
87 let mut offset = GLOBAL_HEADER_SIZE;
88
89 for block_idx in 0..block_count {
90 offset = decode_block(data, offset, &mut values, block_idx)?;
91 }
92
93 if values.len() != total_count {
94 return Err(CodecError::Corrupt {
95 detail: format!(
96 "value count mismatch: header says {total_count}, decoded {}",
97 values.len()
98 ),
99 });
100 }
101
102 Ok(values)
103}
104
105/// Compute byte offsets for each block in an encoded stream.
106///

Callers 12

empty_roundtripFunction · 0.70
single_valueFunction · 0.70
small_range_valuesFunction · 0.70
constant_rate_timestampsFunction · 0.70
pre_delta_timestampsFunction · 0.70
negative_valuesFunction · 0.70
boundary_valuesFunction · 0.70
multiple_blocksFunction · 0.70
partial_last_blockFunction · 0.70
large_dataset_roundtripFunction · 0.70

Calls 2

decode_blockFunction · 0.70
lenMethod · 0.45

Tested by 12

empty_roundtripFunction · 0.56
single_valueFunction · 0.56
small_range_valuesFunction · 0.56
constant_rate_timestampsFunction · 0.56
pre_delta_timestampsFunction · 0.56
negative_valuesFunction · 0.56
boundary_valuesFunction · 0.56
multiple_blocksFunction · 0.56
partial_last_blockFunction · 0.56
large_dataset_roundtripFunction · 0.56