Skip to main content

Doc

Struct Doc 

Source
pub struct Doc { /* private fields */ }
Expand description

Owning document.

Implementations§

Source§

impl Doc

Source

pub fn new() -> Result<Self>

Source

pub fn borrow(&self) -> DocRef<'_>

Borrow this document non-mutably, e.g. to read fields.

Source

pub fn clear(&mut self)

Source

pub fn set_pk(&mut self, pk: &str) -> Result<()>

Source

pub fn set_doc_id(&mut self, id: u64)

Source

pub fn set_score(&mut self, score: f32)

Source

pub fn set_operator(&mut self, op: DocOperator)

Source

pub fn set_field_null(&mut self, field_name: &str) -> Result<()>

Source

pub fn add_field_raw( &mut self, field_name: &str, data_type: DataType, value: &[u8], ) -> Result<()>

Raw field setter — value is the wire layout expected by zvec for data_type. See Self::add_string, Self::add_vector_fp32 etc. for typed wrappers.

Source

pub fn add_string(&mut self, field_name: &str, value: &str) -> Result<()>

Source

pub fn add_bool(&mut self, field_name: &str, value: bool) -> Result<()>

Source

pub fn add_int32(&mut self, field_name: &str, value: i32) -> Result<()>

Source

pub fn add_int64(&mut self, field_name: &str, value: i64) -> Result<()>

Source

pub fn add_uint32(&mut self, field_name: &str, value: u32) -> Result<()>

Source

pub fn add_uint64(&mut self, field_name: &str, value: u64) -> Result<()>

Source

pub fn add_float(&mut self, field_name: &str, value: f32) -> Result<()>

Source

pub fn add_double(&mut self, field_name: &str, value: f64) -> Result<()>

Source

pub fn add_binary(&mut self, field_name: &str, value: &[u8]) -> Result<()>

Source

pub fn add_vector_fp32( &mut self, field_name: &str, vector: &[f32], ) -> Result<()>

Source

pub fn add_vector_fp64( &mut self, field_name: &str, vector: &[f64], ) -> Result<()>

Source

pub fn add_vector_int8(&mut self, field_name: &str, vector: &[i8]) -> Result<()>

Source

pub fn add_vector_int16( &mut self, field_name: &str, vector: &[i16], ) -> Result<()>

Add an INT16 vector field. Values are stored as-is in native byte order.

Source

pub fn add_vector_fp16_bits( &mut self, field_name: &str, vector: &[u16], ) -> Result<()>

Add an FP16 vector field. Each u16 is the raw bit pattern of an IEEE-754 half-precision float, as zvec’s C API accepts them; pair with a crate like half to produce them from f32.

Source

pub fn add_vector_fp16( &mut self, field_name: &str, vector: &[f16], ) -> Result<()>

Available on crate feature half only.

Add an FP16 vector field directly from a slice of half::f16.

Available with the half cargo feature.

Source

pub fn add_vector_int4_packed( &mut self, field_name: &str, packed: &[u8], ) -> Result<()>

Add an INT4 vector field. INT4 is nibble-packed — two values per byte — and zvec expects the caller to hand it pre-packed bytes.

Source

pub fn add_vector_binary32( &mut self, field_name: &str, words: &[u32], ) -> Result<()>

Add a binary32 vector field (bit-packed, 32 bits per word).

Source

pub fn add_vector_binary64( &mut self, field_name: &str, words: &[u64], ) -> Result<()>

Add a binary64 vector field (bit-packed, 64 bits per word).

Source

pub fn add_array_int32( &mut self, field_name: &str, values: &[i32], ) -> Result<()>

Add an array<int32> field.

Source

pub fn add_array_int64( &mut self, field_name: &str, values: &[i64], ) -> Result<()>

Add an array<int64> field.

Source

pub fn add_array_uint32( &mut self, field_name: &str, values: &[u32], ) -> Result<()>

Add an array<uint32> field.

Source

pub fn add_array_uint64( &mut self, field_name: &str, values: &[u64], ) -> Result<()>

Add an array<uint64> field.

Source

pub fn add_array_float( &mut self, field_name: &str, values: &[f32], ) -> Result<()>

Add an array<float> field.

Source

pub fn add_array_double( &mut self, field_name: &str, values: &[f64], ) -> Result<()>

Add an array<double> field.

Source

pub fn remove_field(&mut self, field_name: &str) -> Result<()>

Source

pub fn merge(&mut self, other: &Doc)

Source

pub fn validate(&self, schema: &CollectionSchema, is_update: bool) -> Result<()>

Source

pub fn serialize(&self) -> Result<Vec<u8>>

Source

pub fn deserialize(data: &[u8]) -> Result<Self>

Source

pub fn to_detail_string(&self) -> Result<String>

Source

pub fn pk(&self) -> Option<String>

Source

pub fn doc_id(&self) -> u64

Source

pub fn score(&self) -> f32

Source

pub fn operator(&self) -> DocOperator

Source

pub fn field_count(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn has_field(&self, name: &str) -> bool

Source

pub fn has_field_value(&self, name: &str) -> bool

Source

pub fn is_field_null(&self, name: &str) -> bool

Source

pub fn memory_usage(&self) -> usize

Source

pub fn field_names(&self) -> Result<Vec<String>>

Source

pub fn get_vector_fp32(&self, field_name: &str) -> Result<Vec<f32>>

Source

pub fn get_string(&self, field_name: &str) -> Result<Option<String>>

Source

pub fn get_int64(&self, field_name: &str) -> Result<i64>

Source

pub fn get_float(&self, field_name: &str) -> Result<f32>

Source§

impl Doc

Source

pub fn from_json(value: &Value, schema: &CollectionSchema) -> Result<Self>

Available on crate feature serde-json only.

Build a Doc from a JSON object, resolving field types through schema. The special key "_pk" is recognised as the document’s primary key when it’s a string.

Available with the serde-json cargo feature.

Trait Implementations§

Source§

impl Drop for Doc

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Doc

Auto Trait Implementations§

§

impl Freeze for Doc

§

impl RefUnwindSafe for Doc

§

impl !Sync for Doc

§

impl Unpin for Doc

§

impl UnsafeUnpin for Doc

§

impl UnwindSafe for Doc

Blanket Implementations§

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.