Skip to content

Latest commit

 

History

History
69 lines (54 loc) · 1.09 KB

File metadata and controls

69 lines (54 loc) · 1.09 KB

Table - 表格管理

src/table/

模組結構

檔案 說明
mod.rs 模組入口
table.rs 表格操作
row.rs 列資料結構
schema.rs 表格結構定義
serialize.rs 序列化/反序列化

TableHandle

pub struct TableHandle {
    pub name: String,
    pub page_id: PageId,
}

主要方法

impl Table {
    pub fn open(name: &str, catalog: &Catalog) -> Result<Option<Self>>;
    pub fn insert(&mut self, row: Row) -> Result<()>;
    pub fn update(&mut self, row: Row) -> Result<()>;
    pub fn delete(&mut self, rowid: i64) -> Result<()>;
    pub fn scan(&self) -> Result<TableScan>;
}

TableScan

pub struct TableScan {
    table: TableHandle,
    cursor: BTreeCursor,
}

Row 列結構

pub struct Row {
    pub rowid: i64,
    pub values: Vec<Value>,
}

Schema 表格結構

pub struct TableSchema {
    pub name: String,
    pub columns: Vec<ColumnDef>,
    pub indices: Vec<IndexDef>,
    pub rowid_col: Option<String>,
}

測試

cargo test table