Skip to main content

VectorTable

Struct VectorTable 

Source
pub struct VectorTable {
    pub name: String,
    pub schema: VectorSchema,
    pub engine: Engine,
    /* private fields */
}
Expand description

One registered vector index.

A VectorTable couples the protocol-level VectorSchema (what the client asked for) with the storage-level Engine (what is actually persisted). The pair is immutable for the lifetime of the index; rebuilding a schema means dropping and recreating the table.

Alongside the schema and engine, the table tracks the set of document keys that the FT.* surface has indexed via HSET interception. The set is used by VectorRegistry::drop_with_dd to enumerate the underlying hash documents that should also be removed.

Fields§

§name: String

Index name (the FT.CREATE first argument).

§schema: VectorSchema

Compiled schema.

§engine: Engine

Storage + index engine.

Implementations§

Source§

impl VectorTable

Source

pub fn record_indexed_key(&self, key: Vec<u8>)

Record key as having been indexed. Idempotent.

Source

pub fn indexed_keys(&self) -> Vec<Vec<u8>>

Snapshot the set of indexed keys.

Source

pub fn has_text_field(&self, field: &str) -> bool

True when the schema declares a TEXT field named field. The check is case-sensitive (the FT.CREATE parser preserves the field name verbatim). After an FT.ALTER ADD <field> TEXT the schema vector remains frozen (it lives on an immutable Arc<VectorTable>), so this method also consults the runtime TextFieldIndex map: a field that the registry has provisioned a trigram index for is treated as a TEXT field for the lifetime of the table.

Source

pub fn add_text_field(&self, field: &str) -> bool

Provision a runtime TextFieldIndex for field.

Used by FT.ALTER ADD <field> TEXT to extend an already-registered table with a new text-indexed field. Idempotent: a second call for the same field is a no-op and returns false.

Returns true when a new index slot was provisioned, false when the field was already known (either as part of the original schema or because a prior FT.ALTER provisioned it).

Source

pub fn text_field_names(&self) -> Vec<String>

Snapshot the set of TEXT fields known to this table: the original SCHEMA declarations plus anything provisioned later through Self::add_text_field. Names are returned in lexicographic order.

Source

pub fn has_text_index(&self, field: &str) -> bool

True when the registry has provisioned a TextIndex for field. The check returns true exactly when Self::has_text_field returns true; exposed separately so wire-level tests can assert that the FT.CREATE path actually populated the registry rather than just recorded the schema.

Source

pub fn text_index_doc_count(&self, field: &str) -> Option<usize>

Number of documents currently indexed under field. Returns None when no TEXT field by that name is declared in the schema.

Source

pub fn upsert_text_field(&self, field: &str, key: &[u8], text: &[u8])

Insert text into the TextIndex for field, associating it with the user-visible key. If the same key had a prior entry under this field it is removed first so the postings index never accumulates stale doc ids.

No-op when the schema has no TEXT field by that name; callers can therefore call this for every HSET field/value pair without prior schema lookup.

Source

pub fn search_text_substring( &self, field: &str, query: &[u8], ) -> Option<Vec<TextHit>>

Run an exact-substring lookup against the TextIndex registered under field. Returns the user-visible keys whose stored text contains query as a contiguous byte substring, paired with the original text bytes.

Returns None when no TEXT field by that name is declared in the schema. Callers translate that into a -ERR reply.

Source

pub fn search_text_regex(&self, field: &str, pattern: &str) -> TextRegexResult

Run an exact-regex lookup against the TextIndex registered under field. Returns the user-visible keys whose stored text matches pattern, paired with the original text bytes.

Returns None when no TEXT field by that name is declared in the schema, or Some(Err(...)) when the pattern fails to compile.

Source

pub fn search_text_regex_approx( &self, field: &str, pattern: &str, max_errors: u16, ) -> TextRegexApproxResult

Run an approximate-regex lookup against the TextIndex registered under field with up to max_errors edit operations. Returns the user-visible keys whose stored text approximately matches pattern, paired with the original text bytes.

Returns None when no TEXT field by that name is declared in the schema, or Some(Err(...)) when the pattern fails to compile through the TRE engine.

Trait Implementations§

Source§

impl Debug for VectorTable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,