mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-27 18:30:38 +00:00
refactor: remote catalog uses memory (#1926)
* refactor: remote catalog uses memory * rebase develop * fix: resolve PR comments
This commit is contained in:
@@ -70,7 +70,7 @@ pub enum Error {
|
||||
#[snafu(display("Get null from cache, key: {}", key))]
|
||||
CacheNotGet { key: String, location: Location },
|
||||
|
||||
#[snafu(display("Failed to request MetaSrv, source: {}", source))]
|
||||
#[snafu(display("{source}"))]
|
||||
MetaSrv {
|
||||
source: BoxedError,
|
||||
location: Location,
|
||||
|
||||
@@ -24,6 +24,7 @@ use crate::key::{to_removed_key, TableMetaKey};
|
||||
use crate::kv_backend::memory::MemoryKvBackend;
|
||||
use crate::kv_backend::KvBackendRef;
|
||||
use crate::rpc::store::{CompareAndPutRequest, MoveValueRequest, RangeRequest};
|
||||
use crate::table_name::TableName;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct TableNameKey<'a> {
|
||||
@@ -77,6 +78,16 @@ impl TableMetaKey for TableNameKey<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a TableName> for TableNameKey<'a> {
|
||||
fn from(value: &'a TableName) -> Self {
|
||||
Self {
|
||||
catalog: &value.catalog_name,
|
||||
schema: &value.schema_name,
|
||||
table: &value.table_name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq)]
|
||||
pub struct TableNameValue {
|
||||
table_id: TableId,
|
||||
@@ -207,9 +218,18 @@ mod tests {
|
||||
test_err(b"__table_name/x/000_invalid_schema/z");
|
||||
test_err(b"__table_name/x/y/000_invalid_table");
|
||||
|
||||
let table_name =
|
||||
TableNameKey::strip_table_name(b"__table_name/my_catalog/my_schema/my_table").unwrap();
|
||||
assert_eq!(table_name, "my_table");
|
||||
fn test_ok(table_name: &str) {
|
||||
assert_eq!(
|
||||
table_name,
|
||||
TableNameKey::strip_table_name(
|
||||
format!("__table_name/my_catalog/my_schema/{}", table_name).as_bytes()
|
||||
)
|
||||
.unwrap()
|
||||
);
|
||||
}
|
||||
test_ok("my_table");
|
||||
test_ok("cpu:metrics");
|
||||
test_ok(":cpu:metrics");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user