Skip to content

Commit

Permalink
fix/database-base-ttl:
Browse files Browse the repository at this point in the history
 Refactor SchemaMetadataManager and adjust Cargo.toml dependencies

 - Remove unused imports in schema_metadata_manager.rs
 - Add conditional compilation for SchemaMetadataManager::new
 - Update Cargo.toml to remove "testing" feature from common-meta dependency in main section and add it to dev-dependencies
  • Loading branch information
v0y4g3r committed Nov 3, 2024
1 parent 169f335 commit 9c67d44
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
31 changes: 23 additions & 8 deletions src/common/meta/src/key/schema_metadata_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@

use std::sync::Arc;

use common_telemetry::info;
use snafu::OptionExt;
use store_api::storage::TableId;
use table::metadata::{RawTableInfo, TableType};

use crate::error::TableInfoNotFoundSnafu;
use crate::key::schema_name::{SchemaManager, SchemaNameKey, SchemaNameValue};
use crate::key::table_info::{TableInfoManager, TableInfoManagerRef, TableInfoValue};
use crate::key::schema_name::{SchemaManager, SchemaNameKey};
use crate::key::table_info::{TableInfoManager, TableInfoManagerRef};
use crate::kv_backend::KvBackendRef;
use crate::{error, SchemaOptions};

Expand All @@ -32,11 +30,24 @@ pub type SchemaMetadataManagerRef = Arc<SchemaMetadataManager>;
pub struct SchemaMetadataManager {
table_info_manager: TableInfoManagerRef,
schema_manager: SchemaManager,
#[cfg(any(test, feature = "testing"))]
kv_backend: KvBackendRef,
}

impl SchemaMetadataManager {
/// Creates a new database meta
#[cfg(not(any(test, feature = "testing")))]
pub fn new(kv_backend: KvBackendRef) -> Self {
let table_info_manager = Arc::new(TableInfoManager::new(kv_backend.clone()));
let schema_manager = SchemaManager::new(kv_backend);
Self {
table_info_manager,
schema_manager,
}
}

/// Creates a new database meta
#[cfg(any(test, feature = "testing"))]
pub fn new(kv_backend: KvBackendRef) -> Self {
let table_info_manager = Arc::new(TableInfoManager::new(kv_backend.clone()));
let schema_manager = SchemaManager::new(kv_backend.clone());
Expand Down Expand Up @@ -74,9 +85,10 @@ impl SchemaMetadataManager {
table_name: &str,
schema_name: &str,
catalog_name: &str,
schema_value: Option<SchemaNameValue>,
schema_value: Option<crate::key::schema_name::SchemaNameValue>,
) {
let value = TableInfoValue::new(RawTableInfo {
use table::metadata::{RawTableInfo, TableType};
let value = crate::key::table_info::TableInfoValue::new(RawTableInfo {
ident: Default::default(),
name: table_name.to_string(),
desc: None,
Expand All @@ -99,9 +111,12 @@ impl SchemaMetadataManager {
.create(key, schema_value, false)
.await
.expect("Failed to create schema metadata");
info!(
common_telemetry::info!(
"Register table: {}, id: {}, schema: {}, catalog: {}",
table_name, table_id, schema_name, catalog_name
table_name,
table_id,
schema_name,
catalog_name
);
}
}
3 changes: 2 additions & 1 deletion src/mito2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ common-datasource.workspace = true
common-decimal.workspace = true
common-error.workspace = true
common-macro.workspace = true
common-meta = { workspace = true, features = ["testing"] }
common-meta.workspace = true
common-query.workspace = true
common-recordbatch.workspace = true
common-runtime.workspace = true
Expand Down Expand Up @@ -75,6 +75,7 @@ uuid.workspace = true

[dev-dependencies]
common-function.workspace = true
common-meta = { workspace = true, features = ["testing"] }
common-procedure-test.workspace = true
common-test-util.workspace = true
criterion = "0.4"
Expand Down

0 comments on commit 9c67d44

Please sign in to comment.