pub struct MaglevHash<N> { /* private fields */ }Expand description
Google Maglev O(1) consistent hashing lookup table with minimal disruption on node changes.
Implementations§
Source§impl<N> MaglevHash<N>
Construction and O(1) lookup operations for MaglevHash.
impl<N> MaglevHash<N>
Construction and O(1) lookup operations for MaglevHash.
Sourcepub fn new(nodes: Vec<(String, N)>) -> Self
pub fn new(nodes: Vec<(String, N)>) -> Self
Builds a Maglev lookup table with DEFAULT_MAGLEV_TABLE_SIZE slots.
§Arguments
Vec<(String, N)>- Named backend nodes(id, value).
§Returns
Self- Populated Maglev consistent hash table.
Sourcepub fn with_table_size(nodes: Vec<(String, N)>, min_table_size: usize) -> Self
pub fn with_table_size(nodes: Vec<(String, N)>, min_table_size: usize) -> Self
Sourcepub fn table_size(&self) -> usize
pub fn table_size(&self) -> usize
Returns the prime lookup table size M.
§Returns
usize- Number of entries in the Maglev lookup table.
Trait Implementations§
Source§impl<N: Clone> Clone for MaglevHash<N>
impl<N: Clone> Clone for MaglevHash<N>
Auto Trait Implementations§
impl<N> Forget for MaglevHash<N>
impl<N> Freeze for MaglevHash<N>where
*const u8 is !null: Freeze,
PhantomData<N>: Freeze,
PhantomData<u8>: Freeze,
PhantomData<u16>: Freeze,
PhantomData<u32>: Freeze,
impl<N> Move for MaglevHash<N>
impl<N> RefUnwindSafe for MaglevHash<N>where
N: RefUnwindSafe,
impl<N> Send for MaglevHash<N>
impl<N> Sync for MaglevHash<N>
impl<N> Unpin for MaglevHash<N>
impl<N> UnsafeUnpin for MaglevHash<N>where
*const u8 is !null: UnsafeUnpin,
PhantomData<N>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<u16>: UnsafeUnpin,
PhantomData<u32>: UnsafeUnpin,
impl<N> UnwindSafe for MaglevHash<N>where
RawVecInner: UnwindSafe,
N: 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