From 1ff2386bcb9c83a728b4556d5bb39b31da06a0d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E7=95=A5?= Date: Wed, 3 Jan 2024 15:10:42 +0800 Subject: [PATCH] patch: remove unnecessary result wrappings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 蔡略 --- src/common/meta/src/key.rs | 10 +++++----- src/common/meta/src/key/table_route.rs | 2 +- src/common/meta/src/rpc/router.rs | 4 ++-- .../src/procedure/region_failover/update_metadata.rs | 2 +- tests-integration/src/grpc.rs | 1 - tests-integration/src/instance.rs | 1 - 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/common/meta/src/key.rs b/src/common/meta/src/key.rs index abe116f973e5..0c62d89e4dfb 100644 --- a/src/common/meta/src/key.rs +++ b/src/common/meta/src/key.rs @@ -427,7 +427,7 @@ impl TableMetadataManager { ®ion_storage_path, region_options, region_wal_options, - region_distribution(&x.region_routes)?, + region_distribution(&x.region_routes), )?; txn = txn.merge(create_datanode_table_txn); } @@ -483,7 +483,7 @@ impl TableMetadataManager { .build_delete_txn(table_id, table_info_value)?; // Deletes datanode table key value pairs. - let distribution = region_distribution(table_route_value.region_routes()?)?; + let distribution = region_distribution(table_route_value.region_routes()?); let delete_datanode_txn = self .datanode_table_manager() .build_delete_txn(table_id, distribution)?; @@ -608,8 +608,8 @@ impl TableMetadataManager { ) -> Result<()> { // Updates the datanode table key value pairs. let current_region_distribution = - region_distribution(current_table_route_value.region_routes()?)?; - let new_region_distribution = region_distribution(&new_region_routes)?; + region_distribution(current_table_route_value.region_routes()?); + let new_region_distribution = region_distribution(&new_region_routes); let update_datanode_table_txn = self.datanode_table_manager().build_update_txn( table_id, @@ -1191,7 +1191,7 @@ mod tests { table_id: u32, region_routes: &[RegionRoute], ) { - let region_distribution = region_distribution(region_routes).unwrap(); + let region_distribution = region_distribution(region_routes); for (datanode, regions) in region_distribution { let got = table_metadata_manager .datanode_table_manager() diff --git a/src/common/meta/src/key/table_route.rs b/src/common/meta/src/key/table_route.rs index 4d2ac35001f3..bd2e86d0501a 100644 --- a/src/common/meta/src/key/table_route.rs +++ b/src/common/meta/src/key/table_route.rs @@ -376,7 +376,7 @@ impl TableRouteManager { ) -> Result> { self.get(table_id) .await? - .map(|table_route| region_distribution(table_route.region_routes()?)) + .map(|table_route| Ok(region_distribution(table_route.region_routes()?))) .transpose() } } diff --git a/src/common/meta/src/rpc/router.rs b/src/common/meta/src/rpc/router.rs index e37529635390..806ce5f6575a 100644 --- a/src/common/meta/src/rpc/router.rs +++ b/src/common/meta/src/rpc/router.rs @@ -30,7 +30,7 @@ use crate::peer::Peer; use crate::table_name::TableName; use crate::DatanodeId; -pub fn region_distribution(region_routes: &[RegionRoute]) -> Result { +pub fn region_distribution(region_routes: &[RegionRoute]) -> RegionDistribution { let mut regions_id_map = RegionDistribution::new(); for route in region_routes.iter() { if let Some(peer) = route.leader_peer.as_ref() { @@ -42,7 +42,7 @@ pub fn region_distribution(region_routes: &[RegionRoute]) -> Result>(); diff --git a/tests-integration/src/instance.rs b/tests-integration/src/instance.rs index 5b7ed080d9d9..5b84c6811ce9 100644 --- a/tests-integration/src/instance.rs +++ b/tests-integration/src/instance.rs @@ -221,7 +221,6 @@ mod tests { .region_routes() .expect("region routes should be physical"), ) - .unwrap() .iter() .map(|(k, v)| (v[0], *k)) .collect::>();