From c88f25fbd853d072f2021fa88fbb465a2def7bd6 Mon Sep 17 00:00:00 2001 From: Kould <2435992353@qq.com> Date: Mon, 29 Jan 2024 00:01:08 +0800 Subject: [PATCH] style: Histogram -> ColumnMeta --- src/execution/volcano/dml/analyze.rs | 6 +++--- src/optimizer/core/column_meta.rs | 2 +- src/optimizer/core/histogram.rs | 1 + src/storage/kip.rs | 2 +- src/storage/mod.rs | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/execution/volcano/dml/analyze.rs b/src/execution/volcano/dml/analyze.rs index bcb2e53d..98d75148 100644 --- a/src/execution/volcano/dml/analyze.rs +++ b/src/execution/volcano/dml/analyze.rs @@ -17,7 +17,7 @@ use std::sync::Arc; use std::time::{SystemTime, UNIX_EPOCH}; const DEFAULT_NUM_OF_BUCKETS: usize = 100; -const DEFAULT_HISTOGRAM_PATH: &'static str = "kipsql_histograms"; +const DEFAULT_COLUMN_METAS_PATH: &'static str = "kipsql_column_metas"; pub struct Analyze { table_name: TableName, @@ -86,7 +86,7 @@ impl Analyze { .as_secs(); let dir_path = dirs::config_dir() .expect("Your system does not have a Config directory!") - .join(DEFAULT_HISTOGRAM_PATH) + .join(DEFAULT_COLUMN_METAS_PATH) .join(table_name.as_str()) .join(ts.to_string()); fs::create_dir_all(&dir_path)?; @@ -108,7 +108,7 @@ impl Analyze { transaction.save_table_meta(&meta)?; let columns: Vec = vec![Arc::new(ColumnCatalog::new_dummy( - "HISTOGRAM_PATH".to_string(), + "COLUMN_META_PATH".to_string(), ))]; let values = meta .colum_meta_paths diff --git a/src/optimizer/core/column_meta.rs b/src/optimizer/core/column_meta.rs index e935c903..8c0506e5 100644 --- a/src/optimizer/core/column_meta.rs +++ b/src/optimizer/core/column_meta.rs @@ -31,7 +31,7 @@ impl<'a, T: Transaction> ColumnMetaLoader<'a, T> { return if let Some(column_metas) = option { Ok(column_metas) } else { - let paths = self.tx.histogram_paths(&table_name)?; + let paths = self.tx.column_meta_paths(&table_name)?; let mut column_metas = Vec::with_capacity(paths.len()); for path in paths { diff --git a/src/optimizer/core/histogram.rs b/src/optimizer/core/histogram.rs index c04bf916..ebcddf40 100644 --- a/src/optimizer/core/histogram.rs +++ b/src/optimizer/core/histogram.rs @@ -33,6 +33,7 @@ pub struct Histogram { values_len: usize, buckets: Vec, + // TODO: How to use? // Correlation is the statistical correlation between physical row ordering and logical ordering of // the column values correlation: f64, diff --git a/src/storage/kip.rs b/src/storage/kip.rs index c04e3560..197248b6 100644 --- a/src/storage/kip.rs +++ b/src/storage/kip.rs @@ -354,7 +354,7 @@ impl Transaction for KipTransaction { Ok(()) } - fn histogram_paths(&self, table_name: &str) -> Result, StorageError> { + fn column_meta_paths(&self, table_name: &str) -> Result, StorageError> { if let Some(bytes) = self .tx .get(&TableCodec::encode_root_table_key(table_name))? diff --git a/src/storage/mod.rs b/src/storage/mod.rs index 26e7b96a..72e76ca1 100644 --- a/src/storage/mod.rs +++ b/src/storage/mod.rs @@ -96,7 +96,7 @@ pub trait Transaction: Sync + Send + 'static { fn table(&self, table_name: TableName) -> Option<&TableCatalog>; fn table_metas(&self) -> Result, StorageError>; fn save_table_meta(&mut self, table_meta: &TableMeta) -> Result<(), StorageError>; - fn histogram_paths(&self, table_name: &str) -> Result, StorageError>; + fn column_meta_paths(&self, table_name: &str) -> Result, StorageError>; fn meta_loader(&self) -> ColumnMetaLoader where Self: Sized;