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 Vec (for compatibility)
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_trained_structures<D: Directory>(
&self,
dir: &D,
) -> (FxHashMap<u32, Arc<CoarseCentroids>>, FxHashMap<u32, Arc<PQCodebook>>)
pub async fn load_trained_structures<D: Directory>( &self, dir: &D, ) -> (FxHashMap<u32, Arc<CoarseCentroids>>, FxHashMap<u32, Arc<PQCodebook>>)
Load trained centroids and codebooks from index-level files
Returns (centroids_map, codebooks_map) for fields that are Built
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.