Skip to main content

CacheCodecImpl

Trait CacheCodecImpl 

Source
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§

Source

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).

Source

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§

Source

fn serialize(&self, writer: &mut CacheEntryWriter<'_>) -> Result<(), Error>

Write the body: a header, then sections in a fixed order.

Source

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

Source§

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.

Source§

const TYPE_ID: &'static str = "lance.scalar.BitmapIndexState"

Source§

const CURRENT_VERSION: u32 = 1

Source§

fn deserialize(r: &mut CacheEntryReader<'_>) -> Result<BitmapIndexState, Error>

Source§

impl CacheCodecImpl for LabelListIndexState

Source§

fn serialize(&self, w: &mut CacheEntryWriter<'_>) -> Result<(), Error>

Wire format:

RAW_BLOB : list_nulls (roaring tree map, portable encoding)
<nested BitmapIndexState body (self-delimiting)>
Source§

const TYPE_ID: &'static str = "lance.scalar.LabelListIndexState"

Source§

const CURRENT_VERSION: u32 = 1

Source§

fn deserialize( r: &mut CacheEntryReader<'_>, ) -> Result<LabelListIndexState, Error>

Source§

impl CacheCodecImpl for Positions

Source§

const TYPE_ID: &'static str = "lance.fts.Positions"

Source§

const CURRENT_VERSION: u32 = 1

Source§

fn serialize(&self, w: &mut CacheEntryWriter<'_>) -> Result<(), Error>

Source§

fn deserialize(r: &mut CacheEntryReader<'_>) -> Result<Positions, Error>

Source§

impl CacheCodecImpl for PostingList

Source§

const TYPE_ID: &'static str = "lance.fts.PostingList"

Source§

const CURRENT_VERSION: u32 = 3

Source§

fn serialize(&self, w: &mut CacheEntryWriter<'_>) -> Result<(), Error>

Source§

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.

Source§

const TYPE_ID: &'static str = "lance.fts.PostingListGroup"

Source§

const CURRENT_VERSION: u32 = 4

Source§

fn serialize(&self, w: &mut CacheEntryWriter<'_>) -> Result<(), Error>

Source§

fn deserialize(r: &mut CacheEntryReader<'_>) -> Result<PostingListGroup, Error>

Source§

impl CacheCodecImpl for RowAddrTreeMap

Source§

const TYPE_ID: &'static str = "lance.RowAddrTreeMap"

Source§

const CURRENT_VERSION: u32 = 1

Source§

fn serialize(&self, w: &mut CacheEntryWriter<'_>) -> Result<(), Error>

Source§

fn deserialize(r: &mut CacheEntryReader<'_>) -> Result<RowAddrTreeMap, Error>

Implementors§

Source§

impl<S: IvfSubIndex> CacheCodecImpl for PartitionEntry<S, FlatBinQuantizer>

Source§

const TYPE_ID: &'static str = "lance.vector.ivf.PartitionEntry.FlatBin"

Source§

const CURRENT_VERSION: u32 = 1

Source§

impl<S: IvfSubIndex> CacheCodecImpl for PartitionEntry<S, FlatQuantizer>

Source§

const TYPE_ID: &'static str = "lance.vector.ivf.PartitionEntry.Flat"

Source§

const CURRENT_VERSION: u32 = 1

Source§

impl<S: IvfSubIndex> CacheCodecImpl for PartitionEntry<S, ProductQuantizer>

Source§

const TYPE_ID: &'static str = "lance.vector.ivf.PartitionEntry.PQ"

Source§

const CURRENT_VERSION: u32 = 1

Source§

impl<S: IvfSubIndex> CacheCodecImpl for PartitionEntry<S, RabitQuantizer>

Source§

const TYPE_ID: &'static str = "lance.vector.ivf.PartitionEntry.Rabit"

Source§

const CURRENT_VERSION: u32 = 1

Source§

impl<S: IvfSubIndex> CacheCodecImpl for PartitionEntry<S, ScalarQuantizer>

Source§

const TYPE_ID: &'static str = "lance.vector.ivf.PartitionEntry.SQ"

Source§

const CURRENT_VERSION: u32 = 1