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: StringIndex name (the FT.CREATE first argument).
schema: VectorSchemaCompiled schema.
engine: EngineStorage + index engine.
Implementations§
Source§impl VectorTable
impl VectorTable
Sourcepub fn record_indexed_key(&self, key: Vec<u8>)
pub fn record_indexed_key(&self, key: Vec<u8>)
Record key as having been indexed. Idempotent.
Sourcepub fn indexed_keys(&self) -> Vec<Vec<u8>>
pub fn indexed_keys(&self) -> Vec<Vec<u8>>
Snapshot the set of indexed keys.
Sourcepub fn has_text_field(&self, field: &str) -> bool
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.
Sourcepub fn add_text_field(&self, field: &str) -> bool
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).
Sourcepub fn text_field_names(&self) -> Vec<String>
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.
Sourcepub fn has_text_index(&self, field: &str) -> bool
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.
Sourcepub fn text_index_doc_count(&self, field: &str) -> Option<usize>
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.
Sourcepub fn upsert_text_field(&self, field: &str, key: &[u8], text: &[u8])
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.
Sourcepub fn search_text_substring(
&self,
field: &str,
query: &[u8],
) -> Option<Vec<TextHit>>
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.
Sourcepub fn search_text_regex(&self, field: &str, pattern: &str) -> TextRegexResult
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.
Sourcepub fn search_text_regex_approx(
&self,
field: &str,
pattern: &str,
max_errors: u16,
) -> TextRegexApproxResult
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§
Auto Trait Implementations§
impl !Freeze for VectorTable
impl !RefUnwindSafe for VectorTable
impl Send for VectorTable
impl Sync for VectorTable
impl Unpin for VectorTable
impl UnsafeUnpin for VectorTable
impl !UnwindSafe for VectorTable
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.