Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove unnecessary result wrappings #3084

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/common/meta/src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ impl TableMetadataManager {
&region_storage_path,
region_options,
region_wal_options,
region_distribution(&x.region_routes)?,
region_distribution(&x.region_routes),
)?;
txn = txn.merge(create_datanode_table_txn);
}
Expand Down Expand Up @@ -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)?;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/common/meta/src/key/table_route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ impl TableRouteManager {
) -> Result<Option<RegionDistribution>> {
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()
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/common/meta/src/rpc/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use crate::peer::Peer;
use crate::table_name::TableName;
use crate::DatanodeId;

pub fn region_distribution(region_routes: &[RegionRoute]) -> Result<RegionDistribution> {
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() {
Expand All @@ -42,7 +42,7 @@ pub fn region_distribution(region_routes: &[RegionRoute]) -> Result<RegionDistri
// id asc
regions.sort()
}
Ok(regions_id_map)
regions_id_map
}

#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ mod tests {
.unwrap()
.into_inner();

let map = region_distribution(table_route_value.region_routes().unwrap()).unwrap();
let map = region_distribution(table_route_value.region_routes().unwrap());
assert_eq!(map.len(), 2);
assert_eq!(map.get(&2), Some(&vec![1, 3]));
assert_eq!(map.get(&3), Some(&vec![2, 4]));
Expand Down
1 change: 0 additions & 1 deletion tests-integration/src/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,6 @@ CREATE TABLE {table_name} (
.region_routes()
.expect("physical table route"),
)
.unwrap()
.iter()
.map(|(k, v)| (v[0], *k))
.collect::<HashMap<u32, u64>>();
Expand Down
1 change: 0 additions & 1 deletion tests-integration/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ mod tests {
.region_routes()
.expect("region routes should be physical"),
)
.unwrap()
.iter()
.map(|(k, v)| (v[0], *k))
.collect::<HashMap<u32, u64>>();
Expand Down
Loading