From 8e5eaf5472c97cd4b4643d5ec834833dfa357024 Mon Sep 17 00:00:00 2001 From: JeremyHi Date: Fri, 22 Sep 2023 10:27:29 +0800 Subject: [PATCH] chore: remove unused region_stats method form table (#2458) chore: remove unused region_status method form table --- src/catalog/src/lib.rs | 67 +----------------------------------------- src/table/src/table.rs | 9 ------ 2 files changed, 1 insertion(+), 75 deletions(-) diff --git a/src/catalog/src/lib.rs b/src/catalog/src/lib.rs index 3dd45213ed7b..25e1f10d1753 100644 --- a/src/catalog/src/lib.rs +++ b/src/catalog/src/lib.rs @@ -20,10 +20,8 @@ use std::any::Any; use std::fmt::{Debug, Formatter}; use std::sync::Arc; -use api::v1::meta::RegionStat; -use common_telemetry::warn; use futures::future::BoxFuture; -use table::metadata::{TableId, TableType}; +use table::metadata::TableId; use table::requests::CreateTableRequest; use table::TableRef; @@ -124,66 +122,3 @@ pub struct RegisterSchemaRequest { pub catalog: String, pub schema: String, } - -/// The stat of regions in the datanode node. -/// The number of regions can be got from len of vec. -/// -/// Ignores any errors occurred during iterating regions. The intention of this method is to -/// collect region stats that will be carried in Datanode's heartbeat to Metasrv, so it's a -/// "try our best" job. -pub async fn datanode_stat(catalog_manager: &CatalogManagerRef) -> (u64, Vec) { - let mut region_number: u64 = 0; - let mut region_stats = Vec::new(); - - let Ok(catalog_names) = catalog_manager.catalog_names().await else { - return (region_number, region_stats); - }; - for catalog_name in catalog_names { - let Ok(schema_names) = catalog_manager.schema_names(&catalog_name).await else { - continue; - }; - for schema_name in schema_names { - let Ok(table_names) = catalog_manager - .table_names(&catalog_name, &schema_name) - .await - else { - continue; - }; - for table_name in table_names { - let Ok(Some(table)) = catalog_manager - .table(&catalog_name, &schema_name, &table_name) - .await - else { - continue; - }; - - if table.table_type() != TableType::Base { - continue; - } - - let table_info = table.table_info(); - let region_numbers = &table_info.meta.region_numbers; - region_number += region_numbers.len() as u64; - - let engine = &table_info.meta.engine; - - match table.region_stats() { - Ok(stats) => { - let stats = stats.into_iter().map(|stat| RegionStat { - region_id: stat.region_id, - approximate_bytes: stat.disk_usage_bytes as i64, - engine: engine.clone(), - ..Default::default() - }); - - region_stats.extend(stats); - } - Err(e) => { - warn!("Failed to get region status, err: {:?}", e); - } - }; - } - } - } - (region_number, region_stats) -} diff --git a/src/table/src/table.rs b/src/table/src/table.rs index 099481a9077b..8af3cfd1ffec 100644 --- a/src/table/src/table.rs +++ b/src/table/src/table.rs @@ -30,7 +30,6 @@ use crate::error::{Result, UnsupportedSnafu}; use crate::metadata::{FilterPushDownType, TableId, TableInfoRef, TableType}; use crate::requests::{AlterTableRequest, DeleteRequest, InsertRequest}; use crate::stats::TableStatistics; -use crate::RegionStat; pub type AlterContext = anymap::Map; @@ -101,14 +100,6 @@ pub trait Table: Send + Sync { Ok(()) } - /// Get region stats in this table. - fn region_stats(&self) -> Result> { - UnsupportedSnafu { - operation: "REGION_STATS", - } - .fail()? - } - /// Return true if contains the region fn contains_region(&self, _region: RegionNumber) -> Result { UnsupportedSnafu {