vsdb_slot_db

Struct SlotDB

source
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>

source

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

source

pub fn insert(&mut self, slot: u64, t: T) -> Result<()>

source

pub fn remove(&mut self, slot: u64, t: &T)

source

pub fn clear(&mut self)

source

pub fn get_entries_by_page( &self, page_size: u16, page_index: u32, reverse_order: bool, ) -> Vec<T>

Common usages in web services

source

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

source

pub fn entry_cnt_within_two_slots(&self, slot_start: u64, slot_end: u64) -> u64

Can also be used to do some data statistics

source

pub fn total_by_slot( &self, slot_start: Option<u64>, slot_end: Option<u64>, ) -> u64

source

pub fn total(&self) -> u64

Trait Implementations§

source§

impl<T> Debug for SlotDB<T>

source§

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

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

impl<T> Default for SlotDB<T>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de, T> Deserialize<'de> for SlotDB<T>

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<T> Serialize for SlotDB<T>

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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>

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> KeyDe for T

source§

fn decode_key(bytes: &[u8]) -> Result<T, Box<dyn RucError>>

Decode from bytes to the original key type.
source§

impl<T> KeyEn for T
where T: Serialize,

source§

fn try_encode_key(&self) -> Result<Vec<u8>, Box<dyn RucError>>

Encode original key type to bytes.
source§

fn encode_key(&self) -> Vec<u8>

source§

impl<T> KeyEnDe for T
where T: KeyEn + KeyDe,

source§

fn try_encode(&self) -> Result<Vec<u8>, Box<dyn RucError>>

Encode original key type to bytes.
source§

fn encode(&self) -> Vec<u8>

source§

fn decode(bytes: &[u8]) -> Result<T, Box<dyn RucError>>

Decode from bytes to the original key type.
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> ValueDe for T

source§

fn decode_value(bytes: &[u8]) -> Result<T, Box<dyn RucError>>

Decode from bytes to the original key type.
source§

impl<T> ValueEn for T
where T: Serialize,

source§

fn try_encode_value(&self) -> Result<Vec<u8>, Box<dyn RucError>>

Encode original key type to bytes.
source§

fn encode_value(&self) -> Vec<u8>

source§

impl<T> ValueEnDe for T
where T: ValueEn + ValueDe,

source§

fn try_encode(&self) -> Result<Vec<u8>, Box<dyn RucError>>

Encode original key type to bytes.
source§

fn encode(&self) -> Vec<u8>

source§

fn decode(bytes: &[u8]) -> Result<T, Box<dyn RucError>>

Decode from bytes to the original key type.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,