mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-25 01:10:37 +00:00
feat: region storage path (#2404)
* feat: region storage path * Update src/common/meta/src/key/datanode_table.rs Co-authored-by: Weny Xu <wenymedia@gmail.com> * chore: by cr * feat: upgrade proto --------- Co-authored-by: Weny Xu <wenymedia@gmail.com>
This commit is contained in:
@@ -32,15 +32,21 @@ pub fn region_name(table_id: TableId, region_number: RegionNumber) -> String {
|
||||
format!("{table_id}_{region_number:010}")
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn table_dir(catalog_name: &str, schema_name: &str, table_id: TableId) -> String {
|
||||
format!("{DATA_DIR}{catalog_name}/{schema_name}/{table_id}/")
|
||||
// TODO(jeremy): There are still some dependencies on it. Someone will be here soon to remove it.
|
||||
pub fn table_dir_with_catalog_and_schema(catalog: &str, schema: &str, table_id: TableId) -> String {
|
||||
let path = format!("{}/{}", catalog, schema);
|
||||
table_dir(&path, table_id)
|
||||
}
|
||||
|
||||
pub fn region_dir(catalog_name: &str, schema_name: &str, region_id: RegionId) -> String {
|
||||
#[inline]
|
||||
pub fn table_dir(path: &str, table_id: TableId) -> String {
|
||||
format!("{DATA_DIR}{path}/{table_id}/")
|
||||
}
|
||||
|
||||
pub fn region_dir(path: &str, region_id: RegionId) -> String {
|
||||
format!(
|
||||
"{}{}",
|
||||
table_dir(catalog_name, schema_name, region_id.table_id()),
|
||||
table_dir(path, region_id.table_id()),
|
||||
region_name(region_id.table_id(), region_id.region_number())
|
||||
)
|
||||
}
|
||||
@@ -53,7 +59,7 @@ mod tests {
|
||||
fn test_region_dir() {
|
||||
let region_id = RegionId::new(42, 1);
|
||||
assert_eq!(
|
||||
region_dir("my_catalog", "my_schema", region_id),
|
||||
region_dir("my_catalog/my_schema", region_id),
|
||||
"data/my_catalog/my_schema/42/42_0000000001"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ impl RegionRequest {
|
||||
.map(ColumnMetadata::try_from_column_def)
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
let region_id = create.region_id.into();
|
||||
let region_dir = region_dir(&create.catalog, &create.schema, region_id);
|
||||
let region_dir = region_dir(&create.path, region_id);
|
||||
Ok(vec![(
|
||||
region_id,
|
||||
Self::Create(RegionCreateRequest {
|
||||
@@ -89,7 +89,7 @@ impl RegionRequest {
|
||||
)]),
|
||||
region_request::Body::Open(open) => {
|
||||
let region_id = open.region_id.into();
|
||||
let region_dir = region_dir(&open.catalog, &open.schema, region_id);
|
||||
let region_dir = region_dir(&open.path, region_id);
|
||||
Ok(vec![(
|
||||
region_id,
|
||||
Self::Open(RegionOpenRequest {
|
||||
|
||||
Reference in New Issue
Block a user