Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/storage/src/memtable/btree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use std::cmp::Ordering;
use std::collections::{btree_map, BTreeMap};
use std::fmt;
use std::ops::Bound;
use std::sync::atomic::{AtomicUsize, Ordering as AtomicOrdering};
use std::sync::{Arc, RwLock};
Expand All @@ -37,7 +38,6 @@ type RwLockMap = RwLock<BTreeMap<InnerKey, RowValue>>;
/// A simple memtable implementation based on std's [`BTreeMap`].
///
/// Mainly for test purpose, don't use in production.
#[derive(Debug)]
pub struct BTreeMemtable {
id: MemtableId,
schema: RegionSchemaRef,
Expand All @@ -56,6 +56,20 @@ impl BTreeMemtable {
}
}

impl fmt::Debug for BTreeMemtable {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let len = self.map.read().unwrap().len();

f.debug_struct("BTreeMemtable")
.field("id", &self.id)
// Only show StoreSchema
.field("schema", &self.schema)
.field("rows", &len)
.field("estimated_bytes", &self.estimated_bytes)
.finish()
}
}

impl Memtable for BTreeMemtable {
fn id(&self) -> MemtableId {
self.id
Expand Down
19 changes: 17 additions & 2 deletions src/storage/src/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
#[cfg(test)]
mod tests;
mod writer;

use std::collections::BTreeMap;
use std::fmt;
use std::sync::Arc;

use async_trait::async_trait;
Expand Down Expand Up @@ -49,7 +51,6 @@ use crate::wal::Wal;
use crate::write_batch::WriteBatch;

/// [Region] implementation.
#[derive(Debug)]
pub struct RegionImpl<S: LogStore> {
inner: Arc<RegionInner<S>>,
}
Expand All @@ -62,6 +63,21 @@ impl<S: LogStore> Clone for RegionImpl<S> {
}
}

impl<S: LogStore> fmt::Debug for RegionImpl<S> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("RegionImpl")
.field("id", &self.inner.shared.id)
.field("name", &self.inner.shared.name)
.field("wal", &self.inner.wal)
.field("flush_strategy", &self.inner.flush_strategy)
.field("flush_scheduler", &self.inner.flush_scheduler)
.field("compaction_scheduler", &self.inner.compaction_scheduler)
.field("sst_layer", &self.inner.sst_layer)
.field("manifest", &self.inner.manifest)
.finish()
}
}

#[async_trait]
impl<S: LogStore> Region for RegionImpl<S> {
type Error = Error;
Expand Down Expand Up @@ -440,7 +456,6 @@ impl SharedData {

pub type SharedDataRef = Arc<SharedData>;

#[derive(Debug)]
struct RegionInner<S: LogStore> {
shared: SharedDataRef,
writer: RegionWriterRef,
Expand Down
11 changes: 10 additions & 1 deletion src/storage/src/schema/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use std::fmt;
use std::sync::Arc;

use common_error::prelude::*;
Expand All @@ -32,7 +33,7 @@ use crate::schema::{StoreSchema, StoreSchemaRef};
///
/// The user schema is the schema that only contains columns that user could visit,
/// as well as what the schema user created.
#[derive(Debug, PartialEq, Eq)]
#[derive(PartialEq, Eq)]
pub struct RegionSchema {
/// Schema that only contains columns that user defined, excluding internal columns
/// that are reserved and used by the storage engine.
Expand All @@ -48,6 +49,14 @@ pub struct RegionSchema {
columns: ColumnsMetadataRef,
}

impl fmt::Debug for RegionSchema {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("RegionSchema")
.field("columns", &self.columns)
.finish()
}
}

impl RegionSchema {
pub fn new(columns: ColumnsMetadataRef, version: u32) -> Result<RegionSchema> {
let user_schema = Arc::new(build_user_schema(&columns, version)?);
Expand Down