pub struct IndexMetadata {
pub version: u32,
pub schema: Schema,
pub segment_metas: HashMap<String, SegmentMetaInfo>,
pub vector_fields: HashMap<u32, FieldVectorMeta>,
pub total_vectors: usize,
}Expand description
Unified index metadata - single source of truth for index state
Fields§
§version: u32Version for compatibility
schema: SchemaIndex schema
segment_metas: HashMap<String, SegmentMetaInfo>Segment metadata: segment_id -> info (doc count, etc.) Using HashMap allows O(1) lookup and stores doc counts for merge decisions
vector_fields: HashMap<u32, FieldVectorMeta>Per-field vector index metadata
total_vectors: usizeTotal vectors across all segments (updated on commit)
Implementations§
Source§impl IndexMetadata
impl IndexMetadata
Sourcepub fn segment_ids(&self) -> Vec<String>
pub fn segment_ids(&self) -> Vec<String>
Get segment IDs as a sorted Vec (deterministic ordering for doc_id_offset assignment)
Sourcepub fn add_segment(&mut self, segment_id: String, num_docs: u32)
pub fn add_segment(&mut self, segment_id: String, num_docs: u32)
Add or update a segment with its doc count
Sourcepub fn remove_segment(&mut self, segment_id: &str)
pub fn remove_segment(&mut self, segment_id: &str)
Remove a segment
Sourcepub fn has_segment(&self, segment_id: &str) -> bool
pub fn has_segment(&self, segment_id: &str) -> bool
Check if segment exists
Sourcepub fn segment_doc_count(&self, segment_id: &str) -> Option<u32>
pub fn segment_doc_count(&self, segment_id: &str) -> Option<u32>
Get segment doc count
Sourcepub fn is_field_built(&self, field_id: u32) -> bool
pub fn is_field_built(&self, field_id: u32) -> bool
Check if a field has been built
Sourcepub fn get_field_meta(&self, field_id: u32) -> Option<&FieldVectorMeta>
pub fn get_field_meta(&self, field_id: u32) -> Option<&FieldVectorMeta>
Get field metadata
Sourcepub fn init_field(&mut self, field_id: u32, index_type: VectorIndexType)
pub fn init_field(&mut self, field_id: u32, index_type: VectorIndexType)
Initialize field metadata (called when field is first seen)
Sourcepub fn mark_field_built(
&mut self,
field_id: u32,
vector_count: usize,
num_clusters: usize,
centroids_file: String,
codebook_file: Option<String>,
)
pub fn mark_field_built( &mut self, field_id: u32, vector_count: usize, num_clusters: usize, centroids_file: String, codebook_file: Option<String>, )
Mark field as built with trained structures
Sourcepub fn should_build_field(&self, field_id: u32, threshold: usize) -> bool
pub fn should_build_field(&self, field_id: u32, threshold: usize) -> bool
Check if field should be built based on threshold
Sourcepub async fn load<D: Directory>(dir: &D) -> Result<Self>
pub async fn load<D: Directory>(dir: &D) -> Result<Self>
Load from directory
If metadata.json is missing but metadata.json.tmp exists (crash
between write and rename), recovers from the temp file.
Sourcepub async fn save<D: DirectoryWriter>(&self, dir: &D) -> Result<()>
pub async fn save<D: DirectoryWriter>(&self, dir: &D) -> Result<()>
Save to directory (atomic: write temp file, then rename)
Uses write-then-rename so a crash mid-write won’t corrupt the existing metadata file. On POSIX, rename is atomic.
Sourcepub async fn load_trained_structures<D: Directory>(
&self,
dir: &D,
) -> Option<TrainedVectorStructures>
pub async fn load_trained_structures<D: Directory>( &self, dir: &D, ) -> Option<TrainedVectorStructures>
Load trained structures from index-level files for fields in Built state.
Returns Some(TrainedVectorStructures) if at least one field has trained
centroids, None otherwise.
Trait Implementations§
Source§impl Clone for IndexMetadata
impl Clone for IndexMetadata
Source§fn clone(&self) -> IndexMetadata
fn clone(&self) -> IndexMetadata
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for IndexMetadata
impl Debug for IndexMetadata
Source§impl<'de> Deserialize<'de> for IndexMetadata
impl<'de> Deserialize<'de> for IndexMetadata
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for IndexMetadata
impl RefUnwindSafe for IndexMetadata
impl Send for IndexMetadata
impl Sync for IndexMetadata
impl Unpin for IndexMetadata
impl UnwindSafe for IndexMetadata
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 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.