Skip to main content

AilakeFileWriter

Struct AilakeFileWriter 

Source
pub struct AilakeFileWriter { /* private fields */ }

Implementations§

Source§

impl AilakeFileWriter

Source

pub fn new(policy: VectorStoragePolicy) -> Self

Source

pub fn with_fts(self, config: FtsConfig) -> Self

Attach a Tantivy FTS config. An AILK_FTS section will be built and embedded.

Source

pub fn with_prebuilt_fts_blob(self, blob: Vec<u8>) -> Self

Supply a pre-built FTS blob (e.g., from compaction). Takes priority over with_fts.

Source

pub fn with_shared_ivf_codebook(self, codebook: Arc<IvfPqCodebook>) -> Self

Use a pre-trained IVF-PQ codebook instead of running k-means. Shards built from the same codebook produce comparable ADC distances.

Source

pub fn with_hnsw_config(self, config: HnswConfig) -> Self

Source

pub fn with_ivf_pq(self, config: IvfPqConfig) -> Self

Source

pub fn with_index_type(self, index_type: IndexType) -> Self

Source

pub fn with_auto_index(self) -> Self

Use IndexType::Auto: detect GPU / CPU cores at write time and pick the best index. Equivalent to .with_index_type(IndexType::Auto).

Source

pub fn write_with_prebuilt_hnsw( &self, batch: &RecordBatch, embeddings: &[Vec<f32>], hnsw: &HnswIndex, ) -> AilakeResult<Bytes>

Write batch + embeddings using a pre-built HnswIndex.

Skips the O(N log N) HNSW construction — the caller is responsible for building and populating the index. The index must contain exactly embeddings.len() nodes with RowIds 0..N matching embeddings[0..N] in order.

Used by incremental compaction to reuse the dominant file’s existing index and only insert vectors from smaller files.

Source

pub fn write_parquet_only( &self, batch: &RecordBatch, embeddings: &[Vec<f32>], ) -> AilakeResult<Bytes>

Write RecordBatch + embeddings as plain Parquet, with no AILK section.

Used by TableWriter::write_batch_deferred() to persist data immediately while the HNSW index is built asynchronously in the background. The resulting file is a valid Parquet readable by any standard reader, but AilakeFileReader::is_ailake_file() returns false until the HNSW section is appended by the background indexing task.

Source

pub fn write( &self, batch: &RecordBatch, embeddings: &[Vec<f32>], ) -> AilakeResult<Bytes>

Write RecordBatch + embeddings into a single AI-Lake file.

Layout: [PAR1][row groups][AILK header+centroid+HNSW+trailer][Parquet footer][footer_len][PAR1]

Standard Parquet readers find PAR1 at the end, read the footer, skip directly to row group offsets. The AILK section sits between row groups and footer and is never touched. AI-Lake readers find the AILK section via ailake.footer_offset in the Parquet footer KV.

Source

pub fn write_single_pass( &self, batch: &RecordBatch, embeddings: &[Vec<f32>], ) -> AilakeResult<Bytes>

Single-pass streaming write — no ailake.footer_offset KV injection.

Produces a valid AI-Lake file in a single Parquet write pass without any seek or footer rewrite. Safe for append-only destinations (HDFS strict mode, piped stdout, write-once distributed filesystems).

Readers bootstrap the AILK section from the AilakeTrailer (the 24 bytes immediately preceding the Parquet footer) instead of from the Parquet KV metadata. Both bootstrap paths are supported by AilakeFileReader.

Trade-off vs write():

  • One Parquet write instead of two — saves CPU + memory for large batches.
  • On S3, the AILK offset is derived from bytes already fetched in the footer range-GET (trailer is the 24 bytes before the footer). No extra GET.
Source

pub fn write_multi_single_pass( &self, batch: &RecordBatch, columns: &[VectorColumnBatch<'_>], ) -> AilakeResult<Bytes>

Multi-column variant of write_single_pass.

Source

pub fn write_multi( &self, batch: &RecordBatch, columns: &[VectorColumnBatch<'_>], ) -> AilakeResult<Bytes>

Write RecordBatch + multiple vector columns into a single AI-Lake file.

Each column gets its own AILK section appended sequentially before the Parquet footer. Offsets are recorded in Parquet KV metadata:

  • Primary (first) column: ailake.footer_offset
  • Additional columns: ailake.{column_name}.footer_offset

Readers use the column-specific KV key to locate the right AILK section.

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Fruit for T
where T: Send + Downcast,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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