Skip to content

Commit

Permalink
chore: add build_table_route_prefix (#1269)
Browse files Browse the repository at this point in the history
  • Loading branch information
shuiyisong authored Mar 28, 2023
1 parent e72ce5e commit 509d07b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/meta-srv/src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 509d07b

Please sign in to comment.