MCPcopy Create free account
hub / github.com/cosdata/cosdata / hash_float_vec

Function hash_float_vec

src/models/common.rs:359–371  ·  view source on GitHub ↗
(vec: Vec<f32>)

Source from the content-addressed store, hash-verified

357
358#[allow(dead_code)]
359pub fn hash_float_vec(vec: Vec<f32>) -> Vec<u8> {
360 // Create a new hasher instance
361 let mut hasher = Sha256::new();
362
363 // Convert the Vec<f32> to a byte representation
364 for &num in &vec {
365 // Convert each f32 to its byte representation and update the hasher
366 hasher.update(num.to_le_bytes());
367 }
368
369 // Finalize the hash and return the result as a Vec<u8>
370 hasher.finalize().to_vec()
371}
372
373pub fn get_max_insert_level(x: f64, levels: &[(f64, u8)]) -> u8 {
374 let lst = levels.iter();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected