Skip to main content

KeyBuilder

Struct KeyBuilder 

Source
pub struct KeyBuilder { /* private fields */ }
Expand description

Streams typed logical fields into a canonical cache key.

Integer methods use little-endian fixed-width encoding. Variable-width strings and bytes are type-tagged and length-prefixed. There is deliberately no usize method because cache identities must not depend on target width.

§Examples

use lance_core::cache::{CacheKeySchema, CacheNamespace, KeyBuilder};

let namespace = CacheNamespace::root().child("dataset");
let mut builder = KeyBuilder::new(
    namespace,
    "example.Page",
    CacheKeySchema::new("example.page-key", 1),
);
builder.write_u32(7);
builder.write_str("values");
let key = builder.finish();
assert_eq!(key.as_bytes().len(), 16);

Implementations§

Source§

impl KeyBuilder

Source

pub fn new( namespace: CacheNamespace, stable_type_id: &'static str, schema: CacheKeySchema, ) -> Self

Start a key in a namespace with a stable value type and key schema.

Source

pub fn write_u8(&mut self, value: u8)

Append a tagged, fixed-width u8.

Source

pub fn write_u16(&mut self, value: u16)

Append a tagged, little-endian u16.

Source

pub fn write_u32(&mut self, value: u32)

Append a tagged, little-endian u32.

Source

pub fn write_u64(&mut self, value: u64)

Append a tagged, little-endian u64.

Source

pub fn write_i32(&mut self, value: i32)

Append a tagged, little-endian i32.

Source

pub fn write_i64(&mut self, value: i64)

Append a tagged, little-endian i64.

Source

pub fn write_bool(&mut self, value: bool)

Append a tagged boolean.

Source

pub fn write_str(&mut self, value: &str)

Append a tagged, length-prefixed UTF-8 string.

Source

pub fn write_bytes(&mut self, value: &[u8])

Append tagged, length-prefixed bytes.

Source

pub fn write_fixed_bytes<const N: usize>(&mut self, value: &[u8; N])

Append a tagged fixed-size byte array, including its length.

Source

pub fn write_none(&mut self)

Append the canonical marker for an absent optional value.

Source

pub fn write_some(&mut self)

Append the canonical marker for a present optional value.

Source

pub fn write_variant(&mut self, variant: u32)

Append a tagged enum variant ordinal.

Source

pub fn write_sequence_len(&mut self, len: u64)

Append the length of a following sequence.

Source

pub fn finish(self) -> InternalCacheKey

Finalize and return the canonical 128-bit key.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more