Skip to content

Commit

Permalink
imply debug for CacheManager
Browse files Browse the repository at this point in the history
  • Loading branch information
Ted-Jiang committed Sep 16, 2023
1 parent aaa912d commit 9e471bd
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
4 changes: 0 additions & 4 deletions datafusion/core/src/datasource/listing/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -992,10 +992,6 @@ mod tests {
use arrow::record_batch::RecordBatch;
use datafusion_common::assert_contains;
use datafusion_common::GetExt;
use datafusion_execution::cache::cache_manager::CacheManagerConfig;
use datafusion_execution::cache::cache_unit;
use datafusion_execution::cache::cache_unit::DefaultFileStatisticsCache;
use datafusion_execution::runtime_env::{RuntimeConfig, RuntimeEnv};
use datafusion_expr::LogicalPlanBuilder;
use rstest::*;
use std::collections::HashMap;
Expand Down
9 changes: 8 additions & 1 deletion datafusion/execution/src/cache/cache_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::cache::CacheAccessor;
use datafusion_common::{Result, Statistics};
use object_store::path::Path;
use object_store::ObjectMeta;
use std::fmt::{Debug, Formatter};
use std::sync::Arc;

/// The cache of listing files statistics.
Expand All @@ -28,7 +29,13 @@ use std::sync::Arc;
pub type FileStatisticsCache =
Arc<dyn CacheAccessor<Path, Arc<Statistics>, Extra = ObjectMeta>>;

#[derive(Default)]
impl Debug for dyn CacheAccessor<Path, Arc<Statistics>, Extra = ObjectMeta> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "Cache name: {} with length: {}", self.name(), self.len())
}
}

#[derive(Default, Debug)]
pub struct CacheManager {
file_statistic_cache: Option<FileStatisticsCache>,
}
Expand Down
4 changes: 4 additions & 0 deletions datafusion/execution/src/cache/cache_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ impl CacheAccessor<Path, Arc<Statistics>> for DefaultFileStatisticsCache {
fn clear(&self) {
self.statistics.clear()
}

fn name(&self) -> String {
"DefaultFileStatisticsCache".to_string()
}
}

#[cfg(test)]
Expand Down
2 changes: 2 additions & 0 deletions datafusion/execution/src/cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ pub trait CacheAccessor<K, V>: Send + Sync {
}
/// Removes all entries from the cache.
fn clear(&self);
/// Return the cache name.
fn name(&self) -> String;
}
2 changes: 1 addition & 1 deletion testing

0 comments on commit 9e471bd

Please sign in to comment.