mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-24 08:50:40 +00:00
feat: add fmt::Debug for RegionImpl
This commit is contained in:
@@ -21,6 +21,7 @@ use crate::fs::AppendResponseImpl;
|
||||
|
||||
type FileMap = BTreeMap<u64, LogFileRef>;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct LocalFileLogStore {
|
||||
files: RwLock<FileMap>,
|
||||
active: ArcSwap<LogFile>,
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::sync::Arc;
|
||||
|
||||
use store_api::logstore::namespace::Namespace;
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct LocalNamespace {
|
||||
inner: Arc<LocalNamespaceInner>,
|
||||
}
|
||||
@@ -13,6 +13,7 @@ impl Default for LocalNamespace {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct LocalNamespaceInner {
|
||||
name: String,
|
||||
id: u64,
|
||||
|
||||
@@ -5,8 +5,8 @@ use crate::fs::{entry::EntryImpl, namespace::LocalNamespace, AppendResponseImpl}
|
||||
|
||||
/// A noop log store which only for test
|
||||
// TODO: Add a test feature
|
||||
#[derive(Default)]
|
||||
pub struct NoopLogStore {}
|
||||
#[derive(Debug, Default)]
|
||||
pub struct NoopLogStore;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl LogStore for NoopLogStore {
|
||||
|
||||
@@ -10,7 +10,7 @@ use snafu::ResultExt;
|
||||
use crate::error::{self, Result};
|
||||
|
||||
/// Background job context.
|
||||
#[derive(Clone, Default)]
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct Context {
|
||||
inner: Arc<ContextInner>,
|
||||
}
|
||||
@@ -34,12 +34,13 @@ impl Context {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
#[derive(Debug, Default)]
|
||||
struct ContextInner {
|
||||
cancelled: AtomicBool,
|
||||
}
|
||||
|
||||
/// Handle to the background job.
|
||||
#[derive(Debug)]
|
||||
pub struct JobHandle {
|
||||
ctx: Context,
|
||||
handle: JoinHandle<Result<()>>,
|
||||
@@ -71,7 +72,7 @@ type BoxedJob = Box<dyn Job>;
|
||||
|
||||
/// Thread pool that runs all background jobs.
|
||||
#[async_trait]
|
||||
pub trait JobPool: Send + Sync {
|
||||
pub trait JobPool: Send + Sync + std::fmt::Debug {
|
||||
/// Submit a job to run in background.
|
||||
///
|
||||
/// Returns the [JobHandle] to the job.
|
||||
@@ -83,6 +84,7 @@ pub trait JobPool: Send + Sync {
|
||||
|
||||
pub type JobPoolRef = Arc<dyn JobPool>;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct JobPoolImpl {}
|
||||
|
||||
#[async_trait]
|
||||
|
||||
@@ -199,8 +199,7 @@ impl<S: LogStore> EngineInner<S> {
|
||||
regions.insert(region_name.clone(), region.clone());
|
||||
}
|
||||
|
||||
// TODO(yingwen): Impl Debug format for region and print region info briefly in log.
|
||||
info!("Storage engine create region {}", region_name);
|
||||
info!("Storage engine create region {:?}", ®ion);
|
||||
|
||||
Ok(region)
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ use crate::wal::Wal;
|
||||
/// Default write buffer size (32M).
|
||||
const DEFAULT_WRITE_BUFFER_SIZE: usize = 32 * 1024 * 1024;
|
||||
|
||||
pub trait FlushStrategy: Send + Sync {
|
||||
pub trait FlushStrategy: Send + Sync + std::fmt::Debug {
|
||||
fn should_flush(
|
||||
&self,
|
||||
shared: &SharedDataRef,
|
||||
@@ -113,10 +113,11 @@ pub struct MemtableWithMeta {
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait FlushScheduler: Send + Sync {
|
||||
pub trait FlushScheduler: Send + Sync + std::fmt::Debug {
|
||||
async fn schedule_flush(&self, flush_job: Box<dyn Job>) -> Result<JobHandle>;
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct FlushSchedulerImpl {
|
||||
job_pool: JobPoolRef,
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ use crate::manifest::action::*;
|
||||
use crate::manifest::storage::ManifestObjectStore;
|
||||
use crate::manifest::storage::ObjectStoreLogIterator;
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct RegionManifest {
|
||||
inner: Arc<RegionManifestInner>,
|
||||
}
|
||||
@@ -74,6 +74,7 @@ impl Manifest for RegionManifest {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct RegionManifestInner {
|
||||
region_id: RegionId,
|
||||
store: Arc<ManifestObjectStore>,
|
||||
|
||||
@@ -95,7 +95,7 @@ pub trait BatchIterator: Iterator<Item = Result<Batch>> + Send + Sync {
|
||||
|
||||
pub type BatchIteratorPtr = Box<dyn BatchIterator>;
|
||||
|
||||
pub trait MemtableBuilder: Send + Sync {
|
||||
pub trait MemtableBuilder: Send + Sync + std::fmt::Debug {
|
||||
fn build(&self, id: MemtableId, schema: MemtableSchema) -> MemtableRef;
|
||||
}
|
||||
|
||||
@@ -136,7 +136,8 @@ impl KeyValues {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct DefaultMemtableBuilder {}
|
||||
#[derive(Debug)]
|
||||
pub struct DefaultMemtableBuilder;
|
||||
|
||||
impl MemtableBuilder for DefaultMemtableBuilder {
|
||||
fn build(&self, id: MemtableId, schema: MemtableSchema) -> MemtableRef {
|
||||
|
||||
@@ -22,6 +22,7 @@ use crate::wal::Wal;
|
||||
use crate::write_batch::WriteBatch;
|
||||
|
||||
/// [Region] implementation.
|
||||
#[derive(Debug)]
|
||||
pub struct RegionImpl<S: LogStore> {
|
||||
inner: Arc<RegionInner<S>>,
|
||||
}
|
||||
@@ -110,6 +111,7 @@ impl<S: LogStore> RegionImpl<S> {
|
||||
}
|
||||
|
||||
/// Shared data of region.
|
||||
#[derive(Debug)]
|
||||
pub struct SharedData {
|
||||
pub id: RegionId,
|
||||
pub name: String,
|
||||
@@ -119,6 +121,7 @@ pub struct SharedData {
|
||||
|
||||
pub type SharedDataRef = Arc<SharedData>;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct RegionInner<S: LogStore> {
|
||||
shared: SharedDataRef,
|
||||
writer: RegionWriterRef,
|
||||
|
||||
@@ -47,7 +47,7 @@ impl FlushTester {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
#[derive(Debug, Default)]
|
||||
struct FlushSwitch {
|
||||
should_flush: AtomicBool,
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ pub type RegionWriterRef = Arc<RegionWriter>;
|
||||
// TODO(yingwen): Add benches for write and support group commit to improve write throughput.
|
||||
|
||||
/// Region writer manages all write operations to the region.
|
||||
#[derive(Debug)]
|
||||
pub struct RegionWriter {
|
||||
/// Inner writer guarded by write lock, the write lock is used to ensure
|
||||
/// all write operations are serialized.
|
||||
@@ -112,6 +113,7 @@ impl<'a, S: LogStore> WriterContext<'a, S> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct WriterInner {
|
||||
memtable_builder: MemtableBuilderRef,
|
||||
last_memtable_id: MemtableId,
|
||||
|
||||
@@ -121,7 +121,7 @@ pub struct WriteOptions {
|
||||
|
||||
/// Sst access layer.
|
||||
#[async_trait]
|
||||
pub trait AccessLayer: Send + Sync {
|
||||
pub trait AccessLayer: Send + Sync + std::fmt::Debug {
|
||||
// Writes SST file with given name and returns the full path.
|
||||
async fn write_sst(
|
||||
&self,
|
||||
@@ -134,6 +134,7 @@ pub trait AccessLayer: Send + Sync {
|
||||
pub type AccessLayerRef = Arc<dyn AccessLayer>;
|
||||
|
||||
/// Sst access layer based on local file system.
|
||||
#[derive(Debug)]
|
||||
pub struct FsAccessLayer {
|
||||
sst_dir: String,
|
||||
object_store: ObjectStore,
|
||||
|
||||
@@ -24,6 +24,7 @@ use crate::sync::CowCell;
|
||||
const DEFAULT_BUCKET_DURATION: Duration = Duration::from_secs(3600 * 2);
|
||||
|
||||
/// Controls version of in memory state for a region.
|
||||
#[derive(Debug)]
|
||||
pub struct VersionControl {
|
||||
// TODO(yingwen): If all modification to version must acquire the region writer lock first,
|
||||
// then we may just use ArcSwap to hold version. But some operations may only require the
|
||||
@@ -116,7 +117,7 @@ type MemtableVersionRef = Arc<MemtableVersion>;
|
||||
type LevelMetasRef = Arc<LevelMetas>;
|
||||
|
||||
/// Version contains metadata and state of region.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Version {
|
||||
/// Metadata of the region.
|
||||
///
|
||||
|
||||
@@ -15,6 +15,7 @@ use crate::{
|
||||
write_batch::{codec::WriteBatchArrowEncoder, WriteBatch},
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Wal<S: LogStore> {
|
||||
region_id: u32,
|
||||
namespace: S::Namespace,
|
||||
|
||||
@@ -12,7 +12,7 @@ pub mod namespace;
|
||||
|
||||
/// `LogStore` serves as a Write-Ahead-Log for storage engine.
|
||||
#[async_trait::async_trait]
|
||||
pub trait LogStore: Send + Sync + 'static {
|
||||
pub trait LogStore: Send + Sync + 'static + std::fmt::Debug {
|
||||
type Error: ErrorExt + Send + Sync + 'static;
|
||||
type Namespace: Namespace;
|
||||
type Entry: Entry;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
pub trait Namespace: Send + Sync + Clone {
|
||||
pub trait Namespace: Send + Sync + Clone + std::fmt::Debug {
|
||||
fn new(name: &str, id: u64) -> Self;
|
||||
|
||||
fn name(&self) -> &str;
|
||||
|
||||
Reference in New Issue
Block a user