pub struct DocumentsBatchBuilder<W> { /* private fields */ }
Expand description
The DocumentsBatchBuilder
provides a way to build a documents batch in the intermediary
format used by milli.
The writer used by the DocumentsBatchBuilder
can be read using a DocumentsBatchReader
to iterate over the documents.
§example:
use serde_json::json;
use milli_core::documents::DocumentsBatchBuilder;
let json = json!({ "id": 1, "name": "foo" });
let mut builder = DocumentsBatchBuilder::new(Vec::new());
builder.append_json_object(json.as_object().unwrap()).unwrap();
let _vector = builder.into_inner().unwrap();
Implementations§
Source§impl<W: Write> DocumentsBatchBuilder<W>
impl<W: Write> DocumentsBatchBuilder<W>
pub fn new(writer: W) -> DocumentsBatchBuilder<W>
Sourcepub fn documents_count(&self) -> u32
pub fn documents_count(&self) -> u32
Returns the number of documents inserted into this builder.
Sourcepub fn append_json_object(&mut self, object: &Object) -> Result<()>
pub fn append_json_object(&mut self, object: &Object) -> Result<()>
Appends a new JSON object into the batch and updates the DocumentsBatchIndex
accordingly.
Sourcepub fn append_json_array<R: Read>(&mut self, reader: R) -> Result<(), Error>
pub fn append_json_array<R: Read>(&mut self, reader: R) -> Result<(), Error>
Appends a new JSON array of objects into the batch and updates the DocumentsBatchIndex
accordingly.
Sourcepub fn into_inner(self) -> Result<W>
pub fn into_inner(self) -> Result<W>
Flushes the content on disk and stores the final version of the DocumentsBatchIndex
.
Auto Trait Implementations§
impl<W> Freeze for DocumentsBatchBuilder<W>where
W: Freeze,
impl<W> RefUnwindSafe for DocumentsBatchBuilder<W>where
W: RefUnwindSafe,
impl<W> Send for DocumentsBatchBuilder<W>where
W: Send,
impl<W> Sync for DocumentsBatchBuilder<W>where
W: Sync,
impl<W> Unpin for DocumentsBatchBuilder<W>where
W: Unpin,
impl<W> UnwindSafe for DocumentsBatchBuilder<W>where
W: UnwindSafe,
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
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