pub struct AilakeFileWriter { /* private fields */ }Implementations§
Source§impl AilakeFileWriter
impl AilakeFileWriter
pub fn new(policy: VectorStoragePolicy) -> Self
Sourcepub fn with_fts(self, config: FtsConfig) -> Self
pub fn with_fts(self, config: FtsConfig) -> Self
Attach a Tantivy FTS config. An AILK_FTS section will be built and embedded.
Sourcepub fn with_prebuilt_fts_blob(self, blob: Vec<u8>) -> Self
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.
Use a pre-trained IVF-PQ codebook instead of running k-means. Shards built from the same codebook produce comparable ADC distances.
pub fn with_hnsw_config(self, config: HnswConfig) -> Self
pub fn with_ivf_pq(self, config: IvfPqConfig) -> Self
pub fn with_index_type(self, index_type: IndexType) -> Self
Sourcepub fn with_auto_index(self) -> Self
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).
Sourcepub fn write_with_prebuilt_hnsw(
&self,
batch: &RecordBatch,
embeddings: &[Vec<f32>],
hnsw: &HnswIndex,
) -> AilakeResult<Bytes>
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.
Sourcepub fn write_parquet_only(
&self,
batch: &RecordBatch,
embeddings: &[Vec<f32>],
) -> AilakeResult<Bytes>
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.
Sourcepub fn write(
&self,
batch: &RecordBatch,
embeddings: &[Vec<f32>],
) -> AilakeResult<Bytes>
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.
Sourcepub fn write_single_pass(
&self,
batch: &RecordBatch,
embeddings: &[Vec<f32>],
) -> AilakeResult<Bytes>
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.
Sourcepub fn write_multi_single_pass(
&self,
batch: &RecordBatch,
columns: &[VectorColumnBatch<'_>],
) -> AilakeResult<Bytes>
pub fn write_multi_single_pass( &self, batch: &RecordBatch, columns: &[VectorColumnBatch<'_>], ) -> AilakeResult<Bytes>
Multi-column variant of write_single_pass.
Sourcepub fn write_multi(
&self,
batch: &RecordBatch,
columns: &[VectorColumnBatch<'_>],
) -> AilakeResult<Bytes>
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§
impl Freeze for AilakeFileWriter
impl RefUnwindSafe for AilakeFileWriter
impl Send for AilakeFileWriter
impl Sync for AilakeFileWriter
impl Unpin for AilakeFileWriter
impl UnsafeUnpin for AilakeFileWriter
impl UnwindSafe for AilakeFileWriter
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSync for T
impl<T> Fruit for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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