pub struct CatalogEntry<'a> {
pub model: u8,
pub value_type: u8,
pub band: u8,
pub p_exp: u8,
pub shape_tag: [u8; 16],
pub root_addr: u64,
pub element_count: u64,
pub bytes: u64,
pub db: u16,
pub next: u64,
pub name: &'a [u8],
pub schema: &'a [u8],
}Expand description
One catalogue entry, decoded, borrowing its name and schema from the file.
Fields§
§model: u8Raw model byte. Ask CatalogEntry::model what it means.
value_type: u8Raw value type byte, zero unless the model is kv.
band: u8Raw band byte.
p_exp: u8Partition count as a base two exponent. Never 1: a two way split buys nothing and costs an indirection, so the ladder goes one, four, sixteen.
shape_tag: [u8; 16]The 128 bit shape hash, or all zeroes for a collection that RESP created and that therefore has no declared shape.
root_addr: u64Where the collection’s root lives.
element_count: u64Elements, for SCARD and friends without walking anything.
bytes: u64Bytes the collection occupies.
db: u16Which logical database.
next: u64The next entry in the chain, or 0.
name: &'a [u8]The collection’s name.
schema: &'a [u8]The canonical shape description the shape_tag hashes, or empty.
Implementations§
Source§impl<'a> CatalogEntry<'a>
impl<'a> CatalogEntry<'a>
Sourcepub const fn new(model: Model, name: &'a [u8]) -> CatalogEntry<'a>
pub const fn new(model: Model, name: &'a [u8]) -> CatalogEntry<'a>
An entry for a named collection with no declared shape.
Sourcepub fn encode(&self, buf: &mut [u8]) -> Result<usize>
pub fn encode(&self, buf: &mut [u8]) -> Result<usize>
Writes the entry and its checksum, returning the length written.
Unlike a log record this one writes its len up front, because a
catalogue entry is not appended to a log that a reader is scanning. It
is written to a free segment and then reached by a pointer that is
published in the next superblock flip, so the entry is either reachable
and whole or not reachable at all.
§Errors
Code::Invalid for an oversized name or an illegal p_exp,
Code::Full if buf is too small.
Sourcepub fn decode(bytes: &'a [u8]) -> Result<CatalogEntry<'a>>
pub fn decode(bytes: &'a [u8]) -> Result<CatalogEntry<'a>>
Reads the entry at the front of bytes.
§Errors
Code::Corrupt if the length is impossible, if the entry runs past
the end of bytes, if the name and schema do not fit inside it, or if
the checksum fails.
Sourcepub fn value_type(&self) -> Option<ValueType>
pub fn value_type(&self) -> Option<ValueType>
The value type, if the model is kv and this version knows the byte.
Sourcepub const fn partitions(&self) -> u32
pub const fn partitions(&self) -> u32
How many partitions the collection is split into.
Sourcepub fn is_shape_tagged(&self) -> bool
pub fn is_shape_tagged(&self) -> bool
Whether the collection was declared with a shape.
An all zero tag means it was not, which is the case for anything a RESP client created. Shape checking has nothing to check against there and says so rather than inventing a shape.
Trait Implementations§
Source§impl<'a> Clone for CatalogEntry<'a>
impl<'a> Clone for CatalogEntry<'a>
Source§fn clone(&self) -> CatalogEntry<'a>
fn clone(&self) -> CatalogEntry<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more