pub struct SegmentBuilder { /* private fields */ }Expand description
Segment builder with optimized memory usage
Features:
- Streams documents to disk immediately (no in-memory document storage)
- Uses string interning for terms (reduced allocations)
- Uses hashbrown HashMap (faster than BTreeMap)
Implementations§
Source§impl SegmentBuilder
impl SegmentBuilder
Sourcepub fn new(schema: Arc<Schema>, config: SegmentBuilderConfig) -> Result<Self>
pub fn new(schema: Arc<Schema>, config: SegmentBuilderConfig) -> Result<Self>
Create a new segment builder
pub fn set_tokenizer(&mut self, field: Field, tokenizer: BoxedTokenizer)
pub fn num_docs(&self) -> u32
Sourcepub fn estimated_memory_bytes(&self) -> usize
pub fn estimated_memory_bytes(&self) -> usize
Fast O(1) memory estimate - updated incrementally during indexing
Sourcepub fn sparse_dim_count(&self) -> usize
pub fn sparse_dim_count(&self) -> usize
Count total unique sparse dimensions across all fields
Sourcepub fn stats(&self) -> SegmentBuilderStats
pub fn stats(&self) -> SegmentBuilderStats
Get current statistics for debugging performance (expensive - iterates all data)
Sourcepub fn add_document(&mut self, doc: Document) -> Result<DocId>
pub fn add_document(&mut self, doc: Document) -> Result<DocId>
Add a document - streams to disk immediately
Sourcepub async fn build<D: Directory + DirectoryWriter>(
self,
dir: &D,
segment_id: SegmentId,
trained: Option<&TrainedVectorStructures>,
) -> Result<SegmentMeta>
pub async fn build<D: Directory + DirectoryWriter>( self, dir: &D, segment_id: SegmentId, trained: Option<&TrainedVectorStructures>, ) -> Result<SegmentMeta>
Build the final segment
Streams all data directly to disk via StreamingWriter to avoid buffering entire serialized outputs in memory. Each phase consumes and drops its source data before the next phase begins.
Trait Implementations§
Source§impl Drop for SegmentBuilder
Available on crate feature native only.
impl Drop for SegmentBuilder
Available on crate feature
native only.Auto Trait Implementations§
impl !RefUnwindSafe for SegmentBuilder
impl !UnwindSafe for SegmentBuilder
impl Freeze for SegmentBuilder
impl Send for SegmentBuilder
impl Sync for SegmentBuilder
impl Unpin for SegmentBuilder
impl UnsafeUnpin for SegmentBuilder
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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>
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 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>
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