pub struct SegmentMetadata {
pub id: SegmentId,
pub namespace: NamespaceId,
pub state: SegmentState,
pub live_count: usize,
pub deleted_count: usize,
pub size_bytes: usize,
pub created_at: u64,
pub updated_at: u64,
pub min_id: Option<VectorId>,
pub max_id: Option<VectorId>,
pub level: u32,
}Expand description
Metadata for a segment
Fields§
§id: SegmentIdSegment ID
namespace: NamespaceIdNamespace this segment belongs to
state: SegmentStateCurrent state
live_count: usizeNumber of live vectors
deleted_count: usizeNumber of deleted vectors (garbage)
size_bytes: usizeTotal size in bytes (estimated)
created_at: u64Creation timestamp
updated_at: u64Last modified timestamp
min_id: Option<VectorId>Minimum vector ID in segment (for range queries)
max_id: Option<VectorId>Maximum vector ID in segment (for range queries)
level: u32Level in LSM-like hierarchy (0 = most recent)
Implementations§
Source§impl SegmentMetadata
impl SegmentMetadata
Sourcepub fn new(id: SegmentId, namespace: NamespaceId) -> Self
pub fn new(id: SegmentId, namespace: NamespaceId) -> Self
Create new segment metadata
Sourcepub fn garbage_ratio(&self) -> f32
pub fn garbage_ratio(&self) -> f32
Calculate garbage ratio
Sourcepub fn total_count(&self) -> usize
pub fn total_count(&self) -> usize
Total vector count (live + deleted)
Sourcepub fn needs_compaction(&self, threshold: f32) -> bool
pub fn needs_compaction(&self, threshold: f32) -> bool
Check if segment should be compacted based on garbage ratio
Sourcepub fn update_id_range(&mut self, id: &VectorId)
pub fn update_id_range(&mut self, id: &VectorId)
Update the ID range
Trait Implementations§
Source§impl Clone for SegmentMetadata
impl Clone for SegmentMetadata
Source§fn clone(&self) -> SegmentMetadata
fn clone(&self) -> SegmentMetadata
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SegmentMetadata
impl Debug for SegmentMetadata
Source§impl<'de> Deserialize<'de> for SegmentMetadata
impl<'de> Deserialize<'de> for SegmentMetadata
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for SegmentMetadata
impl RefUnwindSafe for SegmentMetadata
impl Send for SegmentMetadata
impl Sync for SegmentMetadata
impl Unpin for SegmentMetadata
impl UnsafeUnpin for SegmentMetadata
impl UnwindSafe for SegmentMetadata
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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