pub struct SlotDB<T>{ /* private fields */ }
Expand description
A Skip List
like structure,
designed to support fast paged queries and indexes
Implementations§
source§impl<T> SlotDB<T>
impl<T> SlotDB<T>
sourcepub fn new(multiple_step: u64, swap_order: bool) -> Self
pub fn new(multiple_step: u64, swap_order: bool) -> Self
@param: swap_order
:
Switch the inner logic of the slot direction:
- positive => reverse
- reverse => positive
Positive query usually get better performance, swap order if most cases run in the reverse mode
pub fn insert(&mut self, slot: u64, t: T) -> Result<()>
pub fn remove(&mut self, slot: u64, t: &T)
pub fn clear(&mut self)
sourcepub fn get_entries_by_page(
&self,
page_size: u16,
page_index: u32,
reverse_order: bool,
) -> Vec<T>
pub fn get_entries_by_page( &self, page_size: u16, page_index: u32, reverse_order: bool, ) -> Vec<T>
Common usages in web services
sourcepub fn get_entries_by_page_slot(
&self,
slot_left_bound: Option<u64>,
slot_right_bound: Option<u64>,
page_size: u16,
page_index: u32,
reverse_order: bool,
) -> Vec<T>
pub fn get_entries_by_page_slot( &self, slot_left_bound: Option<u64>, slot_right_bound: Option<u64>, page_size: u16, page_index: u32, reverse_order: bool, ) -> Vec<T>
Common usages in web services
sourcepub fn entry_cnt_within_two_slots(&self, slot_start: u64, slot_end: u64) -> u64
pub fn entry_cnt_within_two_slots(&self, slot_start: u64, slot_end: u64) -> u64
Can also be used to do some data statistics
pub fn total_by_slot( &self, slot_start: Option<u64>, slot_end: Option<u64>, ) -> u64
pub fn total(&self) -> u64
Trait Implementations§
source§impl<'de, T> Deserialize<'de> for SlotDB<T>
impl<'de, T> Deserialize<'de> for SlotDB<T>
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<T> !Freeze for SlotDB<T>
impl<T> RefUnwindSafe for SlotDB<T>where
T: RefUnwindSafe,
impl<T> Send for SlotDB<T>where
T: Send,
impl<T> Sync for SlotDB<T>where
T: Sync,
impl<T> Unpin for SlotDB<T>where
T: Unpin,
impl<T> UnwindSafe for SlotDB<T>where
T: RefUnwindSafe + 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