From 509d07b798c526f50d6a548d783eabe9d7e8c448 Mon Sep 17 00:00:00 2001 From: shuiyisong <113876041+shuiyisong@users.noreply.github.com> Date: Tue, 28 Mar 2023 16:26:24 +0800 Subject: [PATCH] chore: add `build_table_route_prefix` (#1269) --- src/meta-srv/src/keys.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/meta-srv/src/keys.rs b/src/meta-srv/src/keys.rs index cbebe55c75..26a7298617 100644 --- a/src/meta-srv/src/keys.rs +++ b/src/meta-srv/src/keys.rs @@ -178,6 +178,15 @@ pub(crate) fn to_removed_key(key: &str) -> String { format!("{REMOVED_PREFIX}-{key}") } +pub fn build_table_route_prefix(catalog: impl AsRef, schema: impl AsRef) -> String { + format!( + "{}-{}-{}-", + TABLE_ROUTE_PREFIX, + catalog.as_ref(), + schema.as_ref() + ) +} + #[derive(Eq, PartialEq, Debug, Clone, Hash, Copy)] pub struct StatKey { pub cluster_id: u64, @@ -279,6 +288,14 @@ impl TryFrom> for StatValue { mod tests { use super::*; + #[test] + fn test_build_prefix() { + assert_eq!( + "__meta_table_route-CATALOG-SCHEMA-", + build_table_route_prefix("CATALOG", "SCHEMA") + ) + } + #[test] fn test_stat_key_round_trip() { let key = StatKey {