Skip to content

Commit

Permalink
add scan to WalManager.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rachelint committed Oct 10, 2022
1 parent f40d064 commit fc61f9c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
13 changes: 12 additions & 1 deletion wal/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ impl ReadBoundary {

#[derive(Debug, Clone)]
pub struct ReadRequest {
/// Region id of the wal to read
/// WalLocation of the wal to read
pub location: WalLocation,
// TODO(yingwen): Or just rename to ReadBound?
/// Start bound
Expand All @@ -232,6 +232,14 @@ pub struct ReadRequest {
pub end: ReadBoundary,
}

#[derive(Debug, Clone)]
pub struct ScanRequest {
/// WalLocation of the wal to read
pub location: WalLocation,
}

pub type ScanContext = ReadContext;

/// Blocking Iterator abstraction for log entry.
pub trait BlockingLogIterator: Send + fmt::Debug {
/// Fetch next log entry from the iterator.
Expand Down Expand Up @@ -291,6 +299,9 @@ pub trait WalManager: Send + Sync + fmt::Debug + 'static {
///
/// Returns the max sequence number for the batch of log entries.
async fn write(&self, ctx: &WriteContext, batch: &LogWriteBatch) -> Result<SequenceNumber>;

/// Scan all logs from a `Region`.
async fn scan(&self, ctx: &ScanContext, req: &ScanRequest) -> Result<BatchLogIteratorAdapter>;
}

/// Adapter to convert a blocking interator to a batch async iterator.
Expand Down
10 changes: 9 additions & 1 deletion wal/src/rocks_impl/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::{
log_batch::{LogEntry, LogWriteBatch},
manager::{
error::*, BatchLogIteratorAdapter, BlockingLogIterator, ReadContext, ReadRequest, RegionId,
WalLocation, WalManager, WriteContext, MAX_REGION_ID,
ScanContext, ScanRequest, WalLocation, WalManager, WriteContext, MAX_REGION_ID,
},
};

Expand Down Expand Up @@ -649,6 +649,14 @@ impl WalManager for RocksImpl {
let region = self.get_or_create_region(batch.location.table_id);
region.write(ctx, batch).await
}

async fn scan(
&self,
_ctx: &ScanContext,
_req: &ScanRequest,
) -> Result<BatchLogIteratorAdapter> {
todo!()
}
}

impl fmt::Debug for RocksImpl {
Expand Down
11 changes: 10 additions & 1 deletion wal/src/table_kv_impl/wal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ use table_kv::TableKv;
use crate::{
log_batch::LogWriteBatch,
manager::{
self, error::*, BatchLogIteratorAdapter, ReadContext, ReadRequest, WalLocation, WalManager,
self, error::*, BatchLogIteratorAdapter, ReadContext, ReadRequest, ScanContext,
ScanRequest, WalLocation, WalManager,
},
table_kv_impl::{
model::NamespaceConfig,
Expand Down Expand Up @@ -158,4 +159,12 @@ impl<T: TableKv> WalManager for WalNamespaceImpl<T> {
.map_err(|e| Box::new(e) as _)
.context(Write)
}

async fn scan(
&self,
_ctx: &ScanContext,
_req: &ScanRequest,
) -> Result<BatchLogIteratorAdapter> {
todo!()
}
}

0 comments on commit fc61f9c

Please sign in to comment.