chore: add build_table_route_prefix (#1269)

This commit is contained in:
shuiyisong
2023-03-28 16:26:24 +08:00
committed by GitHub
parent e72ce5eaa9
commit 509d07b798

View File

@@ -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<str>, schema: impl AsRef<str>) -> 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<Vec<u8>> 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 {