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
Introduce magic_enum into tiflash #5843
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
Welcome @Ziy1-Tan! |
Hey, @ywqzzy @JaySon-Huang. Do I need more tests, or do I need to modify the existing enum related code with |
c6a160c
to
010ea08
Compare
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.
#include <gtest/gtest.h> | ||
|
||
#include <magic_enum.hpp> | ||
using namespace magic_enum; |
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.
using namespace magic_enum; |
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.
Nice one! I'll consider to add more tests using api which may replace existing enum related code.
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 evaluated the enum usage in existing projects and added the magic API test cases for accessing and converting enum types, I can add some more advanced APIs in the future if needed.
@Ziy1-Tan I think you can pick one of the enum in the code base which self-implemented some features that magic_enum provides, and use magic_enum to simplify it. This should be sufficient as a working usage example and why we would like to introduce magic_enum. For example, you may consider
toString(ThreadType) .
|
Good! I'll try it. |
I think using the v0.8.1 43a9272 instead of the 1b1194b from master is better for tracking the third-party library version |
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.
Cool!
@Ziy1-Tan Could you rebase your change over the latest master? We introduced several enum change recently.., which brings some conflict with this PR. |
@Lloyd-Pottiger Please take a look for the recent change |
OK, Let me check it. |
dbms/src/Storages/DeltaMerge/DeltaMergeStore_InternalSegment.cpp
Outdated
Show resolved
Hide resolved
ASSERT_EQ(entry.first, magic_enum::enum_cast<Mode>(entry.second)); | ||
} | ||
} | ||
} // namespace DB::tests |
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.
could you please add for some unusual case like magic_enum::enum_name(-1)
, magic_enum::enum_name(999999999)
?
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.
Okay.
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.
magic_enum::enum_name
based on reflection allows us to catch errors before compiling and can only pass enums instead of integers. So it's not easy to test. But I test ohters API in unusal cases.
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.
cool!
/cc @Lloyd-Pottiger PTAL. |
/run-all-tests |
Coverage for changed files
Coverage summary
full coverage report (for internal network access only) |
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.
LGTM
Thank you for your work!
/merge |
@Lloyd-Pottiger: It seems you want to merge this PR, I will help you trigger all the tests: /run-all-tests You only need to trigger If you have any questions about the PR merge process, please refer to pr process. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
This pull request has been accepted and is ready to merge. Commit hash: 21657a5
|
Coverage for changed files
Coverage summary
full coverage report (for internal network access only) |
What problem does this PR solve?
Issue Number: ref #5758
Problem Summary:
What is changed and how it works?
Neargye/magic_enum
into tiflash viagit submodule
;dbms/src/Common/tests/gtest_magic_enum.cpp
, which perfectly makes the conversion between the enum type and the enum name.Check List
Tests
Side effects
Documentation
Release note