Struct paradedb_tantivy::schema::Term
source · pub struct Term<B = Vec<u8>>(/* private fields */)
where
B: AsRef<[u8]>;
Expand description
Term represents the value that the token can take. It’s a serialized representation over different types.
It actually wraps a Vec<u8>
. The first 5 bytes are metadata.
4 bytes are the field id, and the last byte is the type.
The serialized value ValueBytes
is considered everything after the 4 first bytes (term id).
Implementations§
source§impl Term
impl Term
sourcepub fn with_capacity(capacity: usize) -> Term
pub fn with_capacity(capacity: usize) -> Term
Create a new Term with a buffer with a given capacity.
sourcepub fn from_field_ip_addr(field: Field, ip_addr: Ipv6Addr) -> Term
pub fn from_field_ip_addr(field: Field, ip_addr: Ipv6Addr) -> Term
Builds a term given a field, and a Ipv6Addr
-value
sourcepub fn from_field_u64(field: Field, val: u64) -> Term
pub fn from_field_u64(field: Field, val: u64) -> Term
Builds a term given a field, and a u64
-value
sourcepub fn from_field_i64(field: Field, val: i64) -> Term
pub fn from_field_i64(field: Field, val: i64) -> Term
Builds a term given a field, and a i64
-value
sourcepub fn from_field_f64(field: Field, val: f64) -> Term
pub fn from_field_f64(field: Field, val: f64) -> Term
Builds a term given a field, and a f64
-value
sourcepub fn from_field_bool(field: Field, val: bool) -> Term
pub fn from_field_bool(field: Field, val: bool) -> Term
Builds a term given a field, and a bool
-value
sourcepub fn from_field_date(field: Field, val: DateTime) -> Term
pub fn from_field_date(field: Field, val: DateTime) -> Term
Builds a term given a field, and a DateTime
value
sourcepub fn from_facet(field: Field, facet: &Facet) -> Term
pub fn from_facet(field: Field, facet: &Facet) -> Term
Creates a Term
given a facet.
sourcepub fn from_field_text(field: Field, text: &str) -> Term
pub fn from_field_text(field: Field, text: &str) -> Term
Builds a term given a field, and a string value
sourcepub fn from_field_bytes(field: Field, bytes: &[u8]) -> Term
pub fn from_field_bytes(field: Field, bytes: &[u8]) -> Term
Builds a term bytes.
sourcepub fn clear_with_type(&mut self, typ: Type)
pub fn clear_with_type(&mut self, typ: Type)
Removes the value_bytes and set the type code.
sourcepub fn set_u64(&mut self, val: u64)
pub fn set_u64(&mut self, val: u64)
Sets a u64 value in the term.
U64 are serialized using (8-byte) BigEndian representation. The use of BigEndian has the benefit of preserving the natural order of the values.
sourcepub fn set_ip_addr(&mut self, val: Ipv6Addr)
pub fn set_ip_addr(&mut self, val: Ipv6Addr)
Sets a Ipv6Addr
value in the term.
sourcepub fn truncate_value_bytes(&mut self, len: usize)
pub fn truncate_value_bytes(&mut self, len: usize)
Truncates the value bytes of the term. Value and field type stays the same.
sourcepub fn append_bytes(&mut self, bytes: &[u8]) -> &mut [u8] ⓘ
pub fn append_bytes(&mut self, bytes: &[u8]) -> &mut [u8] ⓘ
Appends value bytes to the Term.
This function returns the segment that has just been added.
sourcepub fn add_json_path_separator(&mut self)
pub fn add_json_path_separator(&mut self)
Appends a JSON_PATH_SEGMENT_SEP to the term. Only used for JSON type.
sourcepub fn set_json_path_end(&mut self)
pub fn set_json_path_end(&mut self)
Sets the current end to JSON_END_OF_PATH. Only used for JSON type.
sourcepub fn set_json_path_separator(&mut self)
pub fn set_json_path_separator(&mut self)
Sets the current end to JSON_PATH_SEGMENT_SEP. Only used for JSON type.
source§impl<B> Term<B>where
B: AsRef<[u8]>,
impl<B> Term<B>where B: AsRef<[u8]>,
sourcepub fn serialized_value_bytes(&self) -> &[u8] ⓘ
pub fn serialized_value_bytes(&self) -> &[u8] ⓘ
Returns the serialized representation of the value. (this does neither include the field id nor the value type.)
If the term is a string, its value is utf-8 encoded.
If the term is a u64, its value is encoded according
to byteorder::BigEndian
.
sourcepub fn value(&self) -> ValueBytes<&[u8]>
pub fn value(&self) -> ValueBytes<&[u8]>
Returns the value of the term. address or JSON path + value. (this does not include the field.)
sourcepub fn serialized_term(&self) -> &[u8] ⓘ
pub fn serialized_term(&self) -> &[u8] ⓘ
Returns the serialized representation of Term. This includes field_id, value type and value.
Do NOT rely on this byte representation in the index. This value is likely to change in the future.
Trait Implementations§
source§impl<B> Ord for Term<B>where
B: AsRef<[u8]>,
impl<B> Ord for Term<B>where B: AsRef<[u8]>,
source§impl<B> PartialEq<Term<B>> for Term<B>where
B: AsRef<[u8]>,
impl<B> PartialEq<Term<B>> for Term<B>where B: AsRef<[u8]>,
source§impl<B> PartialOrd<Term<B>> for Term<B>where
B: AsRef<[u8]>,
impl<B> PartialOrd<Term<B>> for Term<B>where B: AsRef<[u8]>,
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl<B> Eq for Term<B>where B: AsRef<[u8]>,
Auto Trait Implementations§
impl<B> RefUnwindSafe for Term<B>where B: RefUnwindSafe,
impl<B> Send for Term<B>where B: Send,
impl<B> Sync for Term<B>where B: Sync,
impl<B> Unpin for Term<B>where B: Unpin,
impl<B> UnwindSafe for Term<B>where B: 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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
source§fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
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, Global>) -> Rc<dyn Any, Global>
fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
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.