-
Notifications
You must be signed in to change notification settings - Fork 332
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
feat(TableRouteValue): add panic notes and type checks #3023
Conversation
if (!self.is_physical()) { | ||
panic!("Mistakenly been treated as a Physical TableRoute: {self:?}"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There may be some misunderstanding. Add a panic!
Here is not helpful. Without this panic!
, it also will panic if the table_route
is not the TableRouteValue::Physical
fn physical_table_route(&self) -> &PhysicalTableRouteValue {
match self {
TableRouteValue::Physical(x) => x,
_ => unreachable!("Mistakenly been treated as a Physical TableRoute: {self:?}"),
}
}
We should add a check before calling the methods like region_routes
.
i.e.,
ensure!(
table_route.is_physical(),
error::UnexpectedTableRouteTypeSnafu {}
);
// We should check the safety before calling a method with a panic note.
let region_route = table_route.region_routes();
BTW, this doc may be helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some error definitions and checks, following some comments given by the compiler. I'm not quite sure now if these are compliant with the greptime coding specification. Could you please check again and I'll fix it if there are any problems?
Thank you very much.
Signed-off-by: Ruihang Xia <[email protected]>
Hi, we are going to switch to the I have changed the target branch of this PR to |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #3023 +/- ##
==========================================
- Coverage 85.71% 85.18% -0.54%
==========================================
Files 791 786 -5
Lines 127884 127363 -521
==========================================
- Hits 109615 108489 -1126
- Misses 18269 18874 +605 |
> [!WARNING] | ||
> Our default branch has changed from `develop` to main. Please update your local repository to use the `main` branch. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could merge the main
branch instead of the develop
branch. You could rename the develop
branch to main
in your forked repo via GitHub UI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, I submit a new PR:
#3031
I hereby agree to the terms of the GreptimeDB CLA
What's changed and what's your intention?
add panic notes and type checks for TableRouteValue
Checklist
Refer to a related PR or issue link (optional)
#3016