Skip to main content

PersistedEngine

Struct PersistedEngine 

Source
pub struct PersistedEngine { /* private fields */ }
Expand description

持久化存储引擎 包装 MemoryEngine + PersistenceManager,提供 WAL 日志功能

Implementations§

Source§

impl PersistedEngine

Source

pub fn open(path: &Path) -> DbResult<Self>

打开持久化数据库

Source

pub fn create(path: &Path) -> DbResult<Self>

创建新的持久化数据库(如果已存在则覆盖)

Source

pub fn inner_arc(&self) -> Arc<RwLock<MemoryEngine>>

获取内部 MemoryEngine 的 Arc 克隆(用于 QueryBuilder 等)

Source

pub fn checkpoint(&mut self) -> DbResult<()>

手动触发检查点

Source

pub fn force_checkpoint(&mut self) -> DbResult<()>

强制触发检查点(无论 WAL 大小)

Source

pub fn wal_size(&self) -> u64

获取 WAL 文件大小

Source

pub fn create_index(&mut self, table: &str, column: &str) -> DbResult<()>

为表列创建索引(单列)

Source

pub fn create_composite_index( &mut self, table: &str, columns: &[&str], ) -> DbResult<()>

创建复合索引

Source

pub fn create_unique_index( &mut self, table: &str, columns: &[&str], ) -> DbResult<()>

创建唯一复合索引

Source

pub fn drop_index(&mut self, table: &str, column: &str) -> DbResult<bool>

删除索引

Source

pub fn drop_composite_index( &mut self, table: &str, columns: &[&str], ) -> DbResult<bool>

删除复合索引

Source

pub fn has_index(&self, table: &str, column: &str) -> bool

检查列是否有索引

Source

pub fn has_composite_index(&self, table: &str, columns: &[&str]) -> bool

检查复合索引是否存在

Trait Implementations§

Source§

impl StorageEngine for PersistedEngine

Source§

fn create_table(&mut self, schema: TableSchema) -> DbResult<()>

创建表
Source§

fn drop_table(&mut self, name: &str) -> DbResult<()>

删除表
Source§

fn has_table(&self, name: &str) -> bool

检查表是否存在
Source§

fn get_schema(&self, name: &str) -> DbResult<TableSchema>

获取表 schema(返回克隆,支持锁守卫场景)
Source§

fn insert(&mut self, table: &str, row: Row) -> DbResult<RowId>

插入行
Source§

fn get(&self, table: &str, row_id: RowId) -> DbResult<Option<Row>>

获取行(返回克隆,支持锁守卫场景)
Source§

fn update(&mut self, table: &str, row_id: RowId, values: Row) -> DbResult<()>

更新行
Source§

fn delete(&mut self, table: &str, row_id: RowId) -> DbResult<Option<Row>>

删除行
Source§

fn scan(&self, table: &str) -> DbResult<Vec<(RowId, Row)>>

扫描全表(返回克隆,支持锁守卫场景)

Auto Trait Implementations§

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

Source§

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

Source§

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.