feat: manual compact api (#1912)

* merge develop

* chore: merge develop

* fix: some cr commentx

* fix: cr comments
This commit is contained in:
Lei, HUANG
2023-07-11 12:00:39 +08:00
committed by GitHub
parent fc850c9988
commit a7ea3bbc16
22 changed files with 327 additions and 85 deletions

View File

@@ -37,7 +37,9 @@ pub use self::engine::{
TwcsOptions,
};
pub use self::metadata::RegionMeta;
pub use self::region::{CloseContext, FlushContext, FlushReason, Region, RegionStat, WriteContext};
pub use self::region::{
CloseContext, CompactContext, FlushContext, FlushReason, Region, RegionStat, WriteContext,
};
pub use self::requests::{
AddColumn, AlterOperation, AlterRequest, GetRequest, ScanRequest, WriteRequest,
};

View File

@@ -86,6 +86,8 @@ pub trait Region: Send + Sync + Clone + std::fmt::Debug + 'static {
/// Flush memtable of the region to disk.
async fn flush(&self, ctx: &FlushContext) -> Result<(), Self::Error>;
async fn compact(&self, ctx: &CompactContext) -> Result<(), Self::Error>;
}
#[derive(Default, Debug)]
@@ -132,6 +134,18 @@ impl Default for FlushContext {
}
}
#[derive(Debug, Copy, Clone)]
pub struct CompactContext {
/// Whether to wait the compaction result.
pub wait: bool,
}
impl Default for CompactContext {
fn default() -> CompactContext {
CompactContext { wait: true }
}
}
/// Reason of flush operation.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum FlushReason {