Skip to main content

HotIndex

Struct HotIndex 

Source
pub struct HotIndex { /* private fields */ }
Expand description

分片热层索引 —— 将ID哈希路由到对应分片,减少全局锁竞争

Implementations§

Source§

impl HotIndex

Source

pub fn new(cfg: &HotConfig) -> Result<Self>

Source

pub fn add_sync(&self, id: String, vec: Vec<f32>) -> Result<()>

Source

pub async fn write_batch( &self, items: Vec<(String, Vec<f32>)>, trace_id: String, ) -> Result<()>

异步批量写入(经由背景协程,避免阻塞调用方)

Source

pub fn remove(&self, id: &str) -> Option<Vec<f32>>

Source

pub fn get(&self, id: &str) -> Option<Vec<f32>>

Source

pub fn touch(&self, id: &str)

Source

pub fn contains(&self, id: &str) -> bool

Source

pub fn len(&self) -> usize

Source

pub fn search(&self, query: &[f32], k: usize) -> Result<Vec<(String, f32)>>

跨分片搜索,合并后取top-k

Source

pub fn collect_evictions(&self) -> Vec<String>

返回所有超出容量被驱逐的ID(由波动引擎处理后续迁移)

Auto Trait Implementations§

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> 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, 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.