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

Function encode_f64

nodedb-codec/src/pcodec.rs:33–45  ·  view source on GitHub ↗

Compress f64 values using Pcodec.

(values: &[f64])

Source from the content-addressed store, hash-verified

31
32/// Compress f64 values using Pcodec.
33pub fn encode_f64(values: &[f64]) -> Result<Vec<u8>, CodecError> {
34 let count = values.len() as u32;
35 let compressed = pco::standalone::simple_compress(values, &pco::ChunkConfig::default())
36 .map_err(|e| CodecError::CompressFailed {
37 detail: format!("pcodec f64: {e}"),
38 })?;
39
40 let mut out = Vec::with_capacity(5 + compressed.len());
41 out.push(TAG_F64);
42 out.extend_from_slice(&count.to_le_bytes());
43 out.extend_from_slice(&compressed);
44 Ok(out)
45}
46
47/// Decompress Pcodec f64 data.
48pub fn decode_f64(data: &[u8]) -> Result<Vec<f64>, CodecError> {

Callers 10

encode_f64_pipelineFunction · 0.70
f64_emptyFunction · 0.70
f64_roundtripFunction · 0.70
f64_compression_ratioFunction · 0.70
f64_special_valuesFunction · 0.70
f64_roundtripFunction · 0.50
f64_orderingFunction · 0.50
encode_attr_colFunction · 0.50

Calls 2

lenMethod · 0.45
pushMethod · 0.45

Tested by 7

f64_emptyFunction · 0.56
f64_roundtripFunction · 0.56
f64_compression_ratioFunction · 0.56
f64_special_valuesFunction · 0.56
f64_roundtripFunction · 0.40
f64_orderingFunction · 0.40