Files
tuliprox/backend/src/utils/binary_utils.rs
T
euzuandGitHub 13f71ed988 B+ tree now supports a multi-block layout to handle records that exce… (#553)
B+ tree now supports a multi-block layout to handle records that exceed a single block.
Additionally, a larger safety factor was added to the overhead calculation to reduce the risk of data overflow.
Added in-place update for values if they fit in the block without rewriting the whole tree structure.
Implemented an LRU Block Cache (Node Cache) for the query engine.
Implemented zero copy key lookup
Added --dbv for printing id_mapping.db files
Increased initial load time with mmap
2026-01-30 19:29:04 +01:00

32 lines
682 B
Rust

use std::io;
use log::error;
use shared::error::to_io_error;
#[inline]
pub fn binary_serialize<T>(value: &T) -> io::Result<Vec<u8>>
where
T: ?Sized + serde::Serialize,
{
rmp_serde::to_vec(value).map_err(to_io_error)
}
#[inline]
pub fn binary_deserialize<T>(value: &[u8]) -> io::Result<T>
where
T: for<'a> serde::Deserialize<'a>,
{
rmp_serde::from_slice(value).map_err(|e| {
error!("Failed to decode {e}");
to_io_error(e)
})
}
#[inline]
pub fn binary_serialize_into<W, T>(writer: &mut W, value: &T) -> io::Result<()>
where
W: io::Write,
T: ?Sized + serde::Serialize,
{
rmp_serde::encode::write(writer, value).map_err(to_io_error)
}