Pgm

Struct Pgm 

Source
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: usize

Implementations§

Source§

impl<K: Key> Pgm<K>

Source

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

Source

pub fn len(&self) -> usize

Data length 数据长度

Source

pub fn is_empty(&self) -> bool

Source

pub fn segment_count(&self) -> usize

Source

pub fn avg_segment_size(&self) -> f64

Source

pub fn mem_usage(&self) -> usize

Memory usage (excluding data) 内存占用(不含数据)

Source

pub fn predict(&self, key: K) -> usize

Predict position for a key 预测键的位置

Source

pub fn predict_range(&self, key: K) -> (usize, usize)

Predict search range [start, end) for a key 预测键的搜索范围 [start, end)

Trait Implementations§

Source§

impl<K: Clone + Key> Clone for Pgm<K>

Source§

fn clone(&self) -> Pgm<K>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<K: Debug + Key> Debug for Pgm<K>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'__de, K> Decode<'__de> for Pgm<K>
where K: Decode<'__de> + Key, '__de:,

Source§

impl<K> Encode for Pgm<K>
where K: Encode + Key,

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DecodeOwned for T
where T: for<'de> Decode<'de>,