RemDb

Struct RemDb 

Source
pub struct RemDb {
    pub config: &'static DbConfig,
    pub snapshot_version: u32,
    pub metrics: DbMetrics,
    /* private fields */
}
Expand description

数据库实例

Fields§

§config: &'static DbConfig

数据库配置

§snapshot_version: u32

全局快照版本号

§metrics: DbMetrics

数据库监控指标

Implementations§

Source§

impl RemDb

Source

pub fn new(config: &'static DbConfig) -> Self

创建新的数据库实例

Source

pub fn get_table(&self, table_id: usize) -> Result<&MemoryTable>

获取表

Source

pub fn get_table_mut(&mut self, table_id: usize) -> Result<&mut MemoryTable>

获取表(可变)

Source

pub fn get_primary_index(&self, table_id: usize) -> Result<&PrimaryIndex>

获取主键索引

Source

pub fn get_primary_index_mut( &mut self, table_id: usize, ) -> Result<&mut PrimaryIndex>

获取主键索引(可变)

Source

pub fn get_secondary_index(&self, table_id: usize) -> Result<&AnySecondaryIndex>

获取辅助索引

Source

pub fn get_secondary_index_mut( &mut self, table_id: usize, ) -> Result<&mut AnySecondaryIndex>

获取辅助索引(可变)

Source

pub fn is_low_power_mode(&self) -> bool

检查是否处于低功耗模式

Source

pub fn enter_low_power_mode(&mut self) -> Result<()>

进入低功耗模式

Source

pub fn exit_low_power_mode(&mut self) -> Result<()>

退出低功耗模式

Source

pub unsafe fn begin_transaction( &mut self, tx_type: TransactionType, isolation_level: IsolationLevel, tx_buffer: *mut Transaction, log_buffer: *mut LogItem, max_log_items: usize, ) -> Result<NonNull<Transaction>>

开始事务

Source

pub unsafe fn commit_transaction(&mut self) -> Result<()>

提交事务

Source

pub unsafe fn rollback_transaction(&mut self) -> Result<()>

回滚事务

Source

pub fn init(&mut self) -> Result<()>

初始化数据库

Source

pub fn save_snapshot(&mut self, path: &str) -> Result<()>

保存快照到文件

Source

pub fn restore_snapshot(&mut self, path: &str) -> Result<()>

从文件恢复快照

Source

pub fn get_metrics(&self) -> &DbMetrics

获取当前监控指标

Source

pub fn metrics_snapshot(&self) -> DbMetricsSnapshot

创建指标快照

Source

pub fn reset_metrics(&self)

重置所有监控指标

Source

pub fn health_check(&self) -> HealthCheckResult

执行健康检查

Source§

impl RemDb

Source

pub fn dump_metrics(&self) -> String

将指标输出为文本格式

Source

pub fn sql_query(&mut self, sql: &str) -> Result<ResultSet>

执行SQL查询

Source

pub fn export_ddl(&self, path: &str) -> Result<()>

导出完整的DDL文件

Source

pub fn export_data(&self, path: &str) -> Result<()>

导出数据到文件

Source

pub fn save_incremental_snapshot(&mut self, path: &str) -> Result<()>

保存增量快照到文件

Trait Implementations§

Source§

impl DdlExecutor for RemDb

为RemDb实现DdlExecutor trait

Source§

fn create_table( &mut self, name: &str, fields: &[(&str, DataType)], primary_key: Option<usize>, ) -> Result<()>

创建表
Source§

fn create_index( &mut self, table_name: &str, field_name: &str, index_type: IndexType, ) -> Result<()>

创建索引
Source§

impl Send for RemDb

Source§

impl Sync for RemDb

Auto Trait Implementations§

§

impl !Freeze for RemDb

§

impl !RefUnwindSafe for RemDb

§

impl Unpin for RemDb

§

impl !UnwindSafe for RemDb

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.