#[non_exhaustive]pub struct DocColumns { /* private fields */ }Expand description
A batch of upserts as columns. Build it with DocColumns::new, then
with_attr and with_sparse;
the constructors are the only way in, so every batch is well formed.
Every row has every attribute column: a column cannot leave a field out
of one row, only make it null there (valid false). A batch with no
attribute columns writes no attributes at all, as a document with
attrs: None does.
Implementations§
Source§impl DocColumns
impl DocColumns
Sourcepub fn new(
ids: Vec<u8>,
id_offsets: Vec<u32>,
vectors: Vec<f32>,
dim: usize,
) -> Result<Self>
pub fn new( ids: Vec<u8>, id_offsets: Vec<u32>, vectors: Vec<f32>, dim: usize, ) -> Result<Self>
A batch of id_offsets.len() - 1 rows with no attributes and no
sparse vectors: row i’s id is ids[id_offsets[i]..id_offsets[i + 1]]
and its vector vectors[i * dim..(i + 1) * dim].
§Errors
ItzmaError::InvalidColumns if the offsets do not start at 0, go
down or do not end at ids.len(), an id is not UTF-8 on its own, or
vectors is not rows * dim long.
Sourcepub fn with_attr(
self,
name: impl Into<String>,
column: AttrColumn,
) -> Result<Self>
pub fn with_attr( self, name: impl Into<String>, column: AttrColumn, ) -> Result<Self>
Add an attribute column named name.
§Errors
ItzmaError::InvalidColumns if the name is empty or already used,
or the column does not have one entry a row (see AttrColumn), or
its offsets or text are malformed.
Sourcepub fn with_sparse(self, sparse: SparseColumn) -> Result<Self>
pub fn with_sparse(self, sparse: SparseColumn) -> Result<Self>
Sourcepub fn validate(&self, schema: &Schema) -> Result<()>
pub fn validate(&self, schema: &Schema) -> Result<()>
Check the batch against a namespace’s schema, without writing: the
checks Namespace::upsert runs on each
document, run column by column. An input with one defect gets exactly
the error upsert gives for the same documents; with several, the
first one reported can differ, since every id is checked before any
vector, every vector before any sparse vector, and so on.
§Errors
ItzmaError::EmptyBatchfor a batch of no rows.ItzmaError::InvalidIdfor an empty id or one longer thanMAX_ID_BYTES.ItzmaError::DimensionMismatchandItzmaError::InvalidVectorfor vectors, asSchema::validatedecides, and for sparse vectors.ItzmaError::UnknownAttr,ItzmaError::AttrTypeMismatchandItzmaError::InvalidAttrsfor attributes. A free-form namespace checks only that every number is finite, since JSON has no NaN.
Trait Implementations§
Source§impl Clone for DocColumns
impl Clone for DocColumns
Source§impl Debug for DocColumns
impl Debug for DocColumns
Source§impl PartialEq for DocColumns
impl PartialEq for DocColumns
impl StructuralPartialEq for DocColumns
Auto Trait Implementations§
impl Forget for DocColumns
impl Freeze for DocColumnswhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<u32>: Freeze,
PhantomData<f32>: Freeze,
PhantomData<(String, AttrColumn)>: Freeze,
PhantomData<bool>: Freeze,
impl Move for DocColumns
impl RefUnwindSafe for DocColumns
impl Send for DocColumnswhere
RawVecInner: Send,
impl Sync for DocColumnswhere
RawVecInner: Sync,
impl Unpin for DocColumns
impl UnsafeUnpin for DocColumnswhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<u32>: UnsafeUnpin,
PhantomData<f32>: UnsafeUnpin,
PhantomData<(String, AttrColumn)>: UnsafeUnpin,
PhantomData<bool>: UnsafeUnpin,
impl UnwindSafe for DocColumnswhere
RawVecInner: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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