Struct rustdb::table::Table

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

source

pub fn new(id: i64, root_page: u64, id_gen: i64, info: Rc<ColInfo>) -> Rc<Table>

Construct a table with specified info.

source

pub fn save(&self, db: &DB, op: SaveOp)

Save or Rollback underlying files.

source

pub fn free_pages(&self, db: &DB)

Drop the underlying file storage ( the table is not useable after this ).

source

pub fn insert(&self, db: &DB, row: &mut Row)

Insert specified row into the table.

source

pub fn remove(&self, db: &DB, row: &Row)

Remove specified loaded row from the table.

source

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).

source

pub fn id_get(&self, db: &DB, id: u64) -> Option<(PagePtr, usize)>

Get record with specified id.

source

pub fn ix_get( &self, db: &DB, key: Vec<Value>, index: usize ) -> Option<(PagePtr, usize)>

Get record with matching key, using specified index.

source

pub fn scan(&self, db: &DB) -> Asc

Scan all the records in the table.

source

pub fn scan_id(self: &Rc<Table>, db: &DB, id: i64) -> IdScan

Get a single record with specified id.

source

pub fn scan_key( self: &Rc<Table>, db: &DB, key: Value, index: usize ) -> IndexScan

Get records with matching key.

source

pub fn scan_keys( self: &Rc<Table>, db: &DB, keys: Vec<Value>, index: usize ) -> IndexScan

Get records with matching keys.

source

pub fn add_index(&self, root: u64, cols: Vec<usize>, id: i64)

Add the specified index to the table.

source

pub fn delete_index(&self, db: &DB, ix: usize)

Delete the specified index.

source

pub fn init_index(&self, db: &DB)

Initialises last index ( called just after add_index ).

source

pub fn access<'d, 't>(&'t self, p: &'d Page, off: usize) -> Access<'d, 't>

Utility for accessing fields by number.

source

pub fn write_access<'d, 't>( &'t self, p: &'d mut Page, off: usize ) -> WriteAccess<'d, 't>

Utility for updating fields by number.

source

pub fn row(&self) -> Row

Construct a row for the table.

source

pub fn get_id_gen(&self, db: &DB) -> i64

Get id generator.

source

pub fn alloc_id(&self, db: &DB) -> i64

Allocate row id.

source

pub fn id_allocated(&self, db: &DB, id: i64)

Update id allocator if supplied row id exceeds current value.

source

pub fn repack(&self, db: &DB, k: usize) -> i64

Repack the file pages.

source

pub fn get_used(&self, db: &DB, to: &mut HashSet<u64>)

Add the all the pages used by the table to the specified set.

Auto Trait Implementations§

§

impl !Freeze for Table

§

impl !RefUnwindSafe for Table

§

impl !Send for Table

§

impl !Sync for Table

§

impl Unpin for Table

§

impl !UnwindSafe for Table

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, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.