pub struct Store { /* private fields */ }Expand description
Store is similar to VBuckMap, but allows records of any length.
insert, get, remove and iter give access to keyed records.
Small keyed records ( < 255 bytes ) are fast to store and access, large records are slower.
For example iterating over 64K small records could take 1 milli-sec, but 90 milli-sec for large records.
Insert performance is improved if key length is known and small ( VKey::len ).
Keyed records are mutable in the sense that they can be removed then re-inserted with the same key.
store, fetch and delete give access to data where the key is an u64 id chosen by the Store.
This can be used to reduce the size of a keyed record by storing large parts separately.
Implementations§
Source§impl Store
impl Store
Sourcepub fn insert<K: VKey>(&mut self, key: &K, user_data: &[u8], ps: &mut PageSet)
pub fn insert<K: VKey>(&mut self, key: &K, user_data: &[u8], ps: &mut PageSet)
Insert user_data, must not be a duplicate key ( but this is not checked ).
Sourcepub fn get<K: VKey>(&mut self, key: &K, ps: &mut PageSet) -> Option<SData>
pub fn get<K: VKey>(&mut self, key: &K, ps: &mut PageSet) -> Option<SData>
Get data for specified key, returns SData, or None if key not found.
Sourcepub fn iter<'a>(&'a self, ps: &mut PageSet) -> StoreIter<'a>
pub fn iter<'a>(&'a self, ps: &mut PageSet) -> StoreIter<'a>
Get iterator that returns all records (rows).
Sourcepub fn store(&mut self, user_data: &[u8], ps: &mut PageSet) -> u64
pub fn store(&mut self, user_data: &[u8], ps: &mut PageSet) -> u64
Store arbitrary size data, returns id. Use fetch to get it back.
Sourcepub fn fetch(&self, id: u64, len: usize, ps: &mut PageSet) -> LVec<u8>
pub fn fetch(&self, id: u64, len: usize, ps: &mut PageSet) -> LVec<u8>
Fetch stored data, len must not exceed len of stored user_data.
Sourcepub fn delete(&mut self, id: u64, len: usize, ps: &mut PageSet)
pub fn delete(&mut self, id: u64, len: usize, ps: &mut PageSet)
Delete stored data, len must be equal to original len of stored user_data.
Sourcepub fn delete_all(&mut self, ps: &mut PageSet)
pub fn delete_all(&mut self, ps: &mut PageSet)
Delete everything, Store is no longer usable.