pub struct Pgm<K: Key> {
pub epsilon: usize,
pub segments: Vec<Segment<K>>,
pub lut: Vec<u32>,
pub scale: f64,
pub min_key: f64,
pub len: usize,
}Expand description
Pgm-Index core structure (no data ownership, serializable) Pgm 索引核心结构(不持有数据,可序列化)
Fields§
§epsilon: usize§segments: Vec<Segment<K>>§lut: Vec<u32>§scale: f64§min_key: f64§len: usizeImplementations§
Source§impl<K: Key> Pgm<K>
impl<K: Key> Pgm<K>
Sourcepub fn new(data: &[K], epsilon: usize, check_sorted: bool) -> Result<Self>
pub fn new(data: &[K], epsilon: usize, check_sorted: bool) -> Result<Self>
Build Pgm from sorted data slice (O(N) build time) 从已排序数据切片构建 Pgm
§Errors
Returns PgmError::InvalidEpsilon if epsilon < MIN_EPSILON
Returns PgmError::EmptyData if data is empty
Returns PgmError::NotSorted if check_sorted is true and data is not sorted
pub fn is_empty(&self) -> bool
pub fn segment_count(&self) -> usize
pub fn avg_segment_size(&self) -> f64
Sourcepub fn predict_range(&self, key: K) -> (usize, usize)
pub fn predict_range(&self, key: K) -> (usize, usize)
Predict search range [start, end) for a key 预测键的搜索范围 [start, end)
Trait Implementations§
impl<'__de, K> Decode<'__de> for Pgm<K>
impl<K> Encode for Pgm<K>
Auto Trait Implementations§
impl<K> Freeze for Pgm<K>
impl<K> RefUnwindSafe for Pgm<K>where
K: RefUnwindSafe,
impl<K> Send for Pgm<K>
impl<K> Sync for Pgm<K>
impl<K> Unpin for Pgm<K>where
K: Unpin,
impl<K> UnwindSafe for Pgm<K>where
K: UnwindSafe,
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