use tempest_core::utils::{ByteSize, HexU64};
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout, LittleEndian, U32, U64};
use crate::sst::bloom::BloomFilterFooter;
pub(crate) const SST_MAGICNUM: &[u8; 8] = b"TMPS_SST";
mod block;
mod bloom;
mod index;
pub mod error;
pub(crate) mod get;
pub(crate) mod iterator;
pub(crate) mod load;
pub(crate) mod write;
pub use error::*;
pub(crate) use get::*;
pub(crate) use iterator::*;
pub(crate) use load::*;
pub(crate) use write::*;
#[cfg(test)]
mod tests;
#[derive(derive_more::Debug, IntoBytes, FromBytes, KnownLayout, Immutable)]
#[repr(C)]
pub(crate) struct SstFooter {
#[debug(ignore)]
pub(crate) magic: [u8; 8],
#[debug("{:?}", HexU64(bloom_offset.get()))]
pub(crate) bloom_offset: U64<LittleEndian>,
#[debug("{:?}", ByteSize(bloom_size.get() as u64))]
pub(crate) bloom_size: U32<LittleEndian>,
pub(crate) bloom_footer: BloomFilterFooter,
#[debug("{:?}", HexU64(index_offset.get()))]
pub(crate) index_offset: U64<LittleEndian>,
#[debug("{:?}", ByteSize(index_size.get() as u64))]
pub(crate) index_size: U32<LittleEndian>,
}
impl SstFooter {
pub(crate) fn new(
bloom_offset: u64,
bloom_size: u32,
bloom_footer: BloomFilterFooter,
index_offset: u64,
index_size: u32,
) -> Self {
Self {
magic: *SST_MAGICNUM,
bloom_offset: bloom_offset.into(),
bloom_size: bloom_size.into(),
bloom_footer,
index_offset: index_offset.into(),
index_size: index_size.into(),
}
}
}