pub struct RelationalStore {
pub tables: RwLock<HashMap<TableName, Vec<VersionedRow>>>,
pub table_meta: RwLock<HashMap<TableName, TableMeta>>,
pub indexes: RwLock<HashMap<(TableName, String), IndexStorage>>,
pub index_write_lock_count: AtomicU64,
/* private fields */
}Fields§
§tables: RwLock<HashMap<TableName, Vec<VersionedRow>>>§table_meta: RwLock<HashMap<TableName, TableMeta>>§indexes: RwLock<HashMap<(TableName, String), IndexStorage>>(table, index_name) → IndexStorage. Lives alongside TableMeta.indexes so readers / writers can look up the physical B-tree without needing a second-level lock per index.
index_write_lock_count: AtomicU64Counts how many times apply_changes-style batch-level index-lock
acquisitions have happened. The per-row commit path does not bump this
counter; only coarse batch holders (apply_changes wrapping N rows) do.
Implementations§
Source§impl RelationalStore
impl RelationalStore
pub fn new() -> Self
pub fn new_row_id(&self) -> RowId
Sourcepub fn apply_inserts(&self, inserts: Vec<(TableName, VersionedRow)>)
pub fn apply_inserts(&self, inserts: Vec<(TableName, VersionedRow)>)
Apply row inserts AND maintain every index (user-declared AND auto) on the affected tables. The index update runs under the same write-lock scope that the relational insert takes (implicitly held by the caller’s commit_mutex).
pub fn apply_deletes(&self, deletes: Vec<(TableName, RowId, TxId)>)
pub fn create_table(&self, name: &str, meta: TableMeta)
pub fn insert_loaded_row(&self, name: &str, row: VersionedRow)
pub fn max_row_id(&self) -> RowId
pub fn set_next_row_id(&self, next_row_id: RowId)
pub fn drop_table(&self, name: &str)
Sourcepub fn create_index_storage(
&self,
table: &str,
name: &str,
columns: Vec<(String, SortDirection)>,
)
pub fn create_index_storage( &self, table: &str, name: &str, columns: Vec<(String, SortDirection)>, )
Register a new index storage for (table, name). The IndexDecl must
already be present in the table’s TableMeta (callers should
register_index_meta before create_index_storage).
Sourcepub fn drop_index_storage(&self, table: &str, name: &str)
pub fn drop_index_storage(&self, table: &str, name: &str)
Remove an index storage. Called from DROP INDEX / CASCADE.
Sourcepub fn rebuild_index(&self, table: &str, name: &str)
pub fn rebuild_index(&self, table: &str, name: &str)
Build (or rebuild) an index storage by scanning the current table rows. Used after Database::open completes rebuilding TableMeta.indexes but before the executor sees queries. Iterates in row_id-ascending order to preserve I18 tie-break stability.
Sourcepub fn introspect_indexes_total_entries(&self) -> u64
pub fn introspect_indexes_total_entries(&self) -> u64
Introspect total postings across all indexes (including tombstones). Tests use this to confirm DROP TABLE releases index storage.
Sourcepub fn bump_index_write_lock_count(&self)
pub fn bump_index_write_lock_count(&self)
Bump the batch-level index-write lock counter. Called once per
apply_changes batch to prove I14.