Struct rustdb::sortedfile::SortedFile
source · [−]pub struct SortedFile {
pub pages: RefCell<HashMap<u64, PagePtr>>,
pub dirty_pages: RefCell<Vec<PagePtr>>,
pub rec_size: usize,
pub key_size: usize,
pub root_page: u64,
/* private fields */
}
Expand description
Sorted Record storage.
SortedFile is a tree of pages.
Each page is either a parent page with links to child pages, or a leaf page.
Fields
pages: RefCell<HashMap<u64, PagePtr>>
Cached pages.
dirty_pages: RefCell<Vec<PagePtr>>
List of pages that have changed.
rec_size: usize
Size of a record.
key_size: usize
Size of a key.
root_page: u64
The root page.
Implementations
sourceimpl SortedFile
impl SortedFile
sourcepub fn new(rec_size: usize, key_size: usize, root_page: u64) -> Self
pub fn new(rec_size: usize, key_size: usize, root_page: u64) -> Self
Create File with specified record size, key size, root page.
sourcepub fn free_pages(&self, db: &DB, r: &dyn Record)
pub fn free_pages(&self, db: &DB, r: &dyn Record)
Free the underlying storage. File is not useable after this.
sourcepub fn insert(&self, db: &DB, r: &dyn Record)
pub fn insert(&self, db: &DB, r: &dyn Record)
Insert a Record. If the key is a duplicate, the record is not saved.
sourcepub fn get(&self, db: &DB, r: &dyn Record) -> Option<(PagePtr, usize)>
pub fn get(&self, db: &DB, r: &dyn Record) -> Option<(PagePtr, usize)>
Locate a record with matching key. Result is PagePtr and offset of data.
sourcepub fn asc(self: &Rc<Self>, db: &DB, start: Box<dyn Record>) -> AscⓘNotable traits for Ascimpl Iterator for Asc type Item = (PagePtr, usize);
pub fn asc(self: &Rc<Self>, db: &DB, start: Box<dyn Record>) -> AscⓘNotable traits for Ascimpl Iterator for Asc type Item = (PagePtr, usize);
For iteration in ascending order from start.
sourcepub fn dsc(self: &Rc<Self>, db: &DB, start: Box<dyn Record>) -> DscⓘNotable traits for Dscimpl Iterator for Dsc type Item = (PagePtr, usize);
pub fn dsc(self: &Rc<Self>, db: &DB, start: Box<dyn Record>) -> DscⓘNotable traits for Dscimpl Iterator for Dsc type Item = (PagePtr, usize);
For iteration in descending order from start.
Auto Trait Implementations
impl !RefUnwindSafe for SortedFile
impl !Send for SortedFile
impl !Sync for SortedFile
impl Unpin for SortedFile
impl !UnwindSafe for SortedFile
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more