pub struct MemoryEngine { /* private fields */ }Expand description
内存存储引擎实现
Implementations§
Source§impl MemoryEngine
impl MemoryEngine
pub fn new() -> Self
Sourcepub fn create_composite_index(
&mut self,
table: &str,
columns: &[&str],
) -> DbResult<()>
pub fn create_composite_index( &mut self, table: &str, columns: &[&str], ) -> DbResult<()>
为表列创建复合索引
Sourcepub fn create_unique_index(
&mut self,
table: &str,
columns: &[&str],
) -> DbResult<()>
pub fn create_unique_index( &mut self, table: &str, columns: &[&str], ) -> DbResult<()>
创建唯一复合索引
Sourcepub fn drop_composite_index(
&mut self,
table: &str,
columns: &[&str],
) -> DbResult<bool>
pub fn drop_composite_index( &mut self, table: &str, columns: &[&str], ) -> DbResult<bool>
删除复合索引
Sourcepub fn has_composite_index(&self, table: &str, columns: &[&str]) -> bool
pub fn has_composite_index(&self, table: &str, columns: &[&str]) -> bool
检查复合索引是否存在
Sourcepub fn get_composite_index(
&self,
table: &str,
columns: &[&str],
) -> Option<&BTreeIndex>
pub fn get_composite_index( &self, table: &str, columns: &[&str], ) -> Option<&BTreeIndex>
获取复合索引(不可变引用)
Sourcepub fn get_index_mut(
&mut self,
table: &str,
column: &str,
) -> Option<&mut BTreeIndex>
pub fn get_index_mut( &mut self, table: &str, column: &str, ) -> Option<&mut BTreeIndex>
获取索引(可变引用,单列)
Sourcepub fn get_composite_index_mut(
&mut self,
table: &str,
columns: &[&str],
) -> Option<&mut BTreeIndex>
pub fn get_composite_index_mut( &mut self, table: &str, columns: &[&str], ) -> Option<&mut BTreeIndex>
获取复合索引(可变引用)
Sourcepub fn drop_table_indexes(&mut self, table: &str)
pub fn drop_table_indexes(&mut self, table: &str)
删除表的所有索引
Sourcepub fn get_row_count(&self, table: &str) -> DbResult<usize>
pub fn get_row_count(&self, table: &str) -> DbResult<usize>
获取表的行数
Sourcepub fn remove_from_index(
&mut self,
table: &str,
column: &str,
key: &DbValue,
row_id: RowId,
)
pub fn remove_from_index( &mut self, table: &str, column: &str, key: &DbValue, row_id: RowId, )
从索引中删除键值对(用于 delete 操作,单列)
Sourcepub fn remove_from_composite_index(
&mut self,
table: &str,
columns: &[&str],
key: &[DbValue],
row_id: RowId,
)
pub fn remove_from_composite_index( &mut self, table: &str, columns: &[&str], key: &[DbValue], row_id: RowId, )
从复合索引中删除键值对
Sourcepub fn add_to_index(
&mut self,
table: &str,
column: &str,
key: DbValue,
row_id: RowId,
)
pub fn add_to_index( &mut self, table: &str, column: &str, key: DbValue, row_id: RowId, )
向索引添加键值对(用于 insert 操作,单列)
Sourcepub fn add_to_composite_index(
&mut self,
table: &str,
columns: &[&str],
key: Vec<DbValue>,
row_id: RowId,
)
pub fn add_to_composite_index( &mut self, table: &str, columns: &[&str], key: Vec<DbValue>, row_id: RowId, )
向复合索引添加键值对
Sourcepub fn find_best_index(
&self,
table: &str,
filter_columns: &[&str],
) -> Option<(&IndexMeta, &BTreeIndex)>
pub fn find_best_index( &self, table: &str, filter_columns: &[&str], ) -> Option<(&IndexMeta, &BTreeIndex)>
查找最佳索引
Sourcepub fn serialize(&self) -> Result<SerializableEngineData, String>
pub fn serialize(&self) -> Result<SerializableEngineData, String>
序列化引擎数据(用于快照)
Sourcepub fn deserialize(data: SerializableEngineData) -> Self
pub fn deserialize(data: SerializableEngineData) -> Self
从序列化数据恢复(用于快照加载)
Trait Implementations§
Source§impl Default for MemoryEngine
impl Default for MemoryEngine
Source§impl StorageEngine for MemoryEngine
impl StorageEngine for MemoryEngine
Source§fn create_table(&mut self, schema: TableSchema) -> DbResult<()>
fn create_table(&mut self, schema: TableSchema) -> DbResult<()>
创建表
Source§fn get_schema(&self, name: &str) -> DbResult<TableSchema>
fn get_schema(&self, name: &str) -> DbResult<TableSchema>
获取表 schema(返回克隆,支持锁守卫场景)
Auto Trait Implementations§
impl Freeze for MemoryEngine
impl RefUnwindSafe for MemoryEngine
impl Send for MemoryEngine
impl Sync for MemoryEngine
impl Unpin for MemoryEngine
impl UnsafeUnpin for MemoryEngine
impl UnwindSafe for MemoryEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more