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

feat(TableRouteValue): add panic notes and type checks #3023

Closed
wants to merge 4 commits into from

Conversation

AntiTopQuark
Copy link
Contributor

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

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.
  • This PR does not require documentation updates.

Refer to a related PR or issue link (optional)

#3016

Comment on lines 118 to 120
if (!self.is_physical()) {
panic!("Mistakenly been treated as a Physical TableRoute: {self:?}");
}
Copy link
Member

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.

Copy link
Contributor Author

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.

@evenyag evenyag changed the base branch from develop to main December 28, 2023 03:51
@evenyag
Copy link
Contributor

evenyag commented Dec 28, 2023

Hi, we are going to switch to the main branch, as mentioned in #3025.

I have changed the target branch of this PR to main.

@github-actions github-actions bot added Size: M and removed Size: S labels Dec 28, 2023
Copy link

codecov bot commented Dec 28, 2023

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (485a91f) 85.71% compared to head (bafa459) 85.18%.

❗ Current head bafa459 differs from pull request most recent head d71c3d9. Consider uploading reports for the commit d71c3d9 to get more accurate results

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     

@AntiTopQuark AntiTopQuark changed the title [WIP]refactor(TableRouteValue): add panic notes and type checks refactor(TableRouteValue): add panic notes and type checks Dec 28, 2023
@AntiTopQuark AntiTopQuark changed the title refactor(TableRouteValue): add panic notes and type checks chore(TableRouteValue): add panic notes and type checks Dec 28, 2023
@AntiTopQuark AntiTopQuark changed the title chore(TableRouteValue): add panic notes and type checks feat(TableRouteValue): add panic notes and type checks Dec 28, 2023
Comment on lines +30 to +32
> [!WARNING]
> Our default branch has changed from `develop` to main. Please update your local repository to use the `main` branch.

Copy link
Contributor

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.

Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-not-required This change does not impact docs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants