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

Function encode_f64

nodedb-codec/src/gorilla.rs:316–322  ·  view source on GitHub ↗

Encode a slice of f64 values using Gorilla XOR compression. Uses synthetic sequential timestamps (0, 1, 2, ...) so the timestamp channel compresses to near-zero overhead.

(values: &[f64])

Source from the content-addressed store, hash-verified

314/// Uses synthetic sequential timestamps (0, 1, 2, ...) so the timestamp
315/// channel compresses to near-zero overhead.
316pub fn encode_f64(values: &[f64]) -> Vec<u8> {
317 let mut enc = GorillaEncoder::new();
318 for (i, &v) in values.iter().enumerate() {
319 enc.encode(i as i64, v);
320 }
321 enc.finish()
322}
323
324/// Decode Gorilla-compressed f64 values (encoded with `encode_f64`).
325pub fn decode_f64(data: &[u8]) -> Result<Vec<f64>, CodecError> {

Callers 1

f64_batch_roundtripFunction · 0.70

Calls 3

iterMethod · 0.45
encodeMethod · 0.45
finishMethod · 0.45

Tested by 1

f64_batch_roundtripFunction · 0.56