pub trait CacheCodecImpl: Send + Sync {
const TYPE_ID: &'static str;
const CURRENT_VERSION: u32;
// Required methods
fn serialize(&self, writer: &mut CacheEntryWriter<'_>) -> Result<(), Error>;
fn deserialize(reader: &mut CacheEntryReader<'_>) -> Result<Self, Error>
where Self: Sized;
}Expand description
Serialization trait for cache entries.
Experimental: the serialized format is not yet covered by a stability
guarantee and may change between releases. When it does stabilize, the
rules are: TYPE_ID, protobuf field numbers, and enum values are
append-only forever; format changes that protobuf cannot express
transparently bump CURRENT_VERSION.
Implement this on concrete types that need to survive serialization through
a persistent cache backend, then wire it into a
CacheKey via CacheCodec::from_impl.
The envelope (magic/version/type_id/type_version) is written and validated
by the CacheCodec wrapper. serialize writes only
the body — a header followed by sections in a fixed, version-keyed order —
and deserialize reads them back in that same order.
The read sequence mirroring the write sequence for each type_version is
the invariant the implementor owns.
Required Associated Constants§
Sourceconst TYPE_ID: &'static str
const TYPE_ID: &'static str
Stable identity for this entry type. Must not change once shipped.
This is a deliberate author-assigned string, not std::any::type_name
(which is not stable across compiler versions).
Sourceconst CURRENT_VERSION: u32
const CURRENT_VERSION: u32
Body schema version this build writes. Bump when the body layout changes in a way protobuf field additions cannot express transparently (adding/removing/reordering sections, a raw-blob encoding change, etc.).
Required Methods§
Sourcefn serialize(&self, writer: &mut CacheEntryWriter<'_>) -> Result<(), Error>
fn serialize(&self, writer: &mut CacheEntryWriter<'_>) -> Result<(), Error>
Write the body: a header, then sections in a fixed order.
Sourcefn deserialize(reader: &mut CacheEntryReader<'_>) -> Result<Self, Error>where
Self: Sized,
fn deserialize(reader: &mut CacheEntryReader<'_>) -> Result<Self, Error>where
Self: Sized,
Reconstruct from the body. Branch on
reader.version() for backward compat;
sections are read in write order.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl CacheCodecImpl for BitmapIndexState
impl CacheCodecImpl for BitmapIndexState
Source§fn serialize(&self, w: &mut CacheEntryWriter<'_>) -> Result<(), Error>
fn serialize(&self, w: &mut CacheEntryWriter<'_>) -> Result<(), Error>
Wire format:
RAW_BLOB : null_map (roaring tree map, portable encoding)
ARROW_IPC : (keys: <value_type>, offsets: UInt64)The value type is recovered from the IPC section schema.
const TYPE_ID: &'static str = "lance.scalar.BitmapIndexState"
const CURRENT_VERSION: u32 = 1
fn deserialize(r: &mut CacheEntryReader<'_>) -> Result<BitmapIndexState, Error>
Source§impl CacheCodecImpl for LabelListIndexState
impl CacheCodecImpl for LabelListIndexState
Source§fn serialize(&self, w: &mut CacheEntryWriter<'_>) -> Result<(), Error>
fn serialize(&self, w: &mut CacheEntryWriter<'_>) -> Result<(), Error>
Wire format:
RAW_BLOB : list_nulls (roaring tree map, portable encoding)
<nested BitmapIndexState body (self-delimiting)>const TYPE_ID: &'static str = "lance.scalar.LabelListIndexState"
const CURRENT_VERSION: u32 = 1
fn deserialize( r: &mut CacheEntryReader<'_>, ) -> Result<LabelListIndexState, Error>
Source§impl CacheCodecImpl for Positions
impl CacheCodecImpl for Positions
Source§impl CacheCodecImpl for PostingList
impl CacheCodecImpl for PostingList
const TYPE_ID: &'static str = "lance.fts.PostingList"
const CURRENT_VERSION: u32 = 3
fn serialize(&self, w: &mut CacheEntryWriter<'_>) -> Result<(), Error>
fn deserialize(r: &mut CacheEntryReader<'_>) -> Result<PostingList, Error>
Source§impl CacheCodecImpl for PostingListGroup
Version 2 distinguishes packed groups from the materialized fallback. A
packed group writes one IPC batch; materialized groups retain the v1 inline
member framing used by legacy and position-bearing prewarm paths. Version 3
marks packed groups whose IPC schema can carry configurable posting block
sizes while retaining the version-2 body framing. Version 4 adds optional
impact data, either as an inline section for materialized members or as a
column in the packed IPC batch.
impl CacheCodecImpl for PostingListGroup
Version 2 distinguishes packed groups from the materialized fallback. A packed group writes one IPC batch; materialized groups retain the v1 inline member framing used by legacy and position-bearing prewarm paths. Version 3 marks packed groups whose IPC schema can carry configurable posting block sizes while retaining the version-2 body framing. Version 4 adds optional impact data, either as an inline section for materialized members or as a column in the packed IPC batch.