pub struct Table {
pub file: Rc<SortedFile>,
pub info: Rc<ColInfo>,
pub ixlist: RefCell<IxList>,
pub id: i64,
pub id_gen: Cell<Option<i64>>,
pub id_gen_dirty: Cell<bool>,
}
Expand description
Database base table. Underlying file, type information about the columns and id allocation.
Fields§
§file: Rc<SortedFile>
Underlying SortedFile.
info: Rc<ColInfo>
Type information about the columns.
ixlist: RefCell<IxList>
List of indexes. ( Maybe could eliminate the RefCell )
id: i64
Table id in sys.Table.
id_gen: Cell<Option<i64>>
Row id allocator.
id_gen_dirty: Cell<bool>
Row id allocator has changed.
Implementations§
source§impl Table
impl Table
sourcepub fn new(id: i64, root_page: u64, id_gen: i64, info: Rc<ColInfo>) -> Rc<Table>
pub fn new(id: i64, root_page: u64, id_gen: i64, info: Rc<ColInfo>) -> Rc<Table>
Construct a table with specified info.
sourcepub fn free_pages(&self, db: &DB)
pub fn free_pages(&self, db: &DB)
Drop the underlying file storage ( the table is not useable after this ).
sourcepub fn index_from(
self: &Rc<Table>,
b: &Block<'_>,
we: &mut Expr
) -> (Option<CExpPtr<bool>>, Option<CTableExpression>)
pub fn index_from( self: &Rc<Table>, b: &Block<'_>, we: &mut Expr ) -> (Option<CExpPtr<bool>>, Option<CTableExpression>)
Look for indexed table expression based on supplied WHERE expression (we).
sourcepub fn id_get(&self, db: &DB, id: u64) -> Option<(PagePtr, usize)>
pub fn id_get(&self, db: &DB, id: u64) -> Option<(PagePtr, usize)>
Get record with specified id.
sourcepub fn ix_get(
&self,
db: &DB,
key: Vec<Value>,
index: usize
) -> Option<(PagePtr, usize)>
pub fn ix_get( &self, db: &DB, key: Vec<Value>, index: usize ) -> Option<(PagePtr, usize)>
Get record with matching key, using specified index.
sourcepub fn scan_id(self: &Rc<Table>, db: &DB, id: i64) -> IdScan ⓘ
pub fn scan_id(self: &Rc<Table>, db: &DB, id: i64) -> IdScan ⓘ
Get a single record with specified id.
sourcepub fn scan_key(
self: &Rc<Table>,
db: &DB,
key: Value,
index: usize
) -> IndexScan ⓘ
pub fn scan_key( self: &Rc<Table>, db: &DB, key: Value, index: usize ) -> IndexScan ⓘ
Get records with matching key.
sourcepub fn scan_keys(
self: &Rc<Table>,
db: &DB,
keys: Vec<Value>,
index: usize
) -> IndexScan ⓘ
pub fn scan_keys( self: &Rc<Table>, db: &DB, keys: Vec<Value>, index: usize ) -> IndexScan ⓘ
Get records with matching keys.
sourcepub fn add_index(&self, root: u64, cols: Vec<usize>, id: i64)
pub fn add_index(&self, root: u64, cols: Vec<usize>, id: i64)
Add the specified index to the table.
sourcepub fn delete_index(&self, db: &DB, ix: usize)
pub fn delete_index(&self, db: &DB, ix: usize)
Delete the specified index.
sourcepub fn init_index(&self, db: &DB)
pub fn init_index(&self, db: &DB)
Initialises last index ( called just after add_index ).
sourcepub fn access<'d, 't>(&'t self, p: &'d Page, off: usize) -> Access<'d, 't>
pub fn access<'d, 't>(&'t self, p: &'d Page, off: usize) -> Access<'d, 't>
Utility for accessing fields by number.
sourcepub fn write_access<'d, 't>(
&'t self,
p: &'d mut Page,
off: usize
) -> WriteAccess<'d, 't>
pub fn write_access<'d, 't>( &'t self, p: &'d mut Page, off: usize ) -> WriteAccess<'d, 't>
Utility for updating fields by number.
sourcepub fn get_id_gen(&self, db: &DB) -> i64
pub fn get_id_gen(&self, db: &DB) -> i64
Get id generator.
sourcepub fn id_allocated(&self, db: &DB, id: i64)
pub fn id_allocated(&self, db: &DB, id: i64)
Update id allocator if supplied row id exceeds current value.