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

The region_distribution should returns RegionDistribution instead of Result<RegionDistribution> #3079

Closed
WenyXu opened this issue Jan 3, 2024 · 2 comments · Fixed by #3084
Assignees
Labels
good first issue Good for newcomers

Comments

@WenyXu
Copy link
Member

WenyXu commented Jan 3, 2024

What type of enhancement is this?

Tech debt reduction

What does the enhancement do?

pub fn region_distribution(region_routes: &[RegionRoute]) -> Result<RegionDistribution> {
let mut regions_id_map = RegionDistribution::new();
for route in region_routes.iter() {
if let Some(peer) = route.leader_peer.as_ref() {
let region_id = route.region.id.region_number();
regions_id_map.entry(peer.id).or_default().push(region_id);
}
}
for (_, regions) in regions_id_map.iter_mut() {
// id asc
regions.sort()
}
Ok(regions_id_map)
}

Here is no reason to return Result<RegionDistribution>, Let's refactor it.

Implementation challenges

No response

@ClSlaid
Copy link
Contributor

ClSlaid commented Jan 3, 2024

I'd like to take a look.

@WenyXu
Copy link
Member Author

WenyXu commented Jan 3, 2024

I'd like to take a look.

Have fun!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants