-
Notifications
You must be signed in to change notification settings - Fork 79
feat: impl metrics config #488
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
base: main
Are you sure you want to change the base?
Conversation
src/iceberg/metrics_config.h
Outdated
| kFull, | ||
| }; | ||
|
|
||
| static Result<std::shared_ptr<MetricsMode>> FromString(const std::string& mode); |
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.
| static Result<std::shared_ptr<MetricsMode>> FromString(const std::string& mode); | |
| static Result<std::shared_ptr<MetricsMode>> FromString(std::string_view mode); |
src/iceberg/metrics_config.h
Outdated
|
|
||
| static const std::shared_ptr<MetricsMode>& None(); | ||
| static const std::shared_ptr<MetricsMode>& Counts(); | ||
| static const std::shared_ptr<MetricsMode>& Truncate(); |
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.
Is it useful to keep this parameterless Truncate?
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.
no used, remove it
src/iceberg/metrics_config.h
Outdated
| std::unordered_map<std::string, std::shared_ptr<MetricsMode>> column_modes, | ||
| std::shared_ptr<MetricsMode> default_mode); |
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.
| std::unordered_map<std::string, std::shared_ptr<MetricsMode>> column_modes, | |
| std::shared_ptr<MetricsMode> default_mode); | |
| std::unordered_map<std::string, std::string>> properties); |
Should we use this as the function signature? I think MetricsConfig is created directly from the table property map.
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.
BTW, should we make it a private ctor and add a Make function to create one by validating all inputs?
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.
The constructor will not be called directly, defined as private
src/iceberg/metrics_config.h
Outdated
|
|
||
| namespace iceberg { | ||
|
|
||
| class ICEBERG_EXPORT MetricsMode : public util::Formattable { |
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.
Is it an overkill to use class hierarchy for it? Can we do this instead?
struct MetricsMode {
enum class Kind : uint8_t { kNone, ... };
Kind kind;
std::variant<std::monostate, int32_t> param;
};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.
looks good
src/iceberg/metrics_config.h
Outdated
| static const std::shared_ptr<MetricsConfig>& Default(); | ||
|
|
||
| /// \brief Creates a metrics config from a table. | ||
| static Result<std::shared_ptr<MetricsConfig>> Make(std::shared_ptr<Table> table); |
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.
| static Result<std::shared_ptr<MetricsConfig>> Make(std::shared_ptr<Table> table); | |
| static Result<std::unique_ptr<MetricsConfig>> Make(const Table& table); |
src/iceberg/metrics_config.cc
Outdated
| return MetricsMode::Full(); | ||
| } | ||
|
|
||
| if (mode.starts_with(kTruncatePrefix) && mode.ends_with(")")) { |
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.
It should also usse case insensitive comparison.
src/iceberg/metrics_config.cc
Outdated
| public: | ||
| explicit Visitor(int32_t limit) : limit_(limit) {} | ||
|
|
||
| Status Visit(const std::shared_ptr<Type>& type) { |
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.
Similarly, it looks weird to use const std::shared_ptr<Type>& and const NestedType& inconsistently. Can you fix this? You may find VisitTypeInline useful.
| if (!ShouldContinue()) { | ||
| break; | ||
| } | ||
| if (field.type()->is_primitive()) { |
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.
Add a TODO comment to support variant type in the future.
3877187 to
8a562d6
Compare
No description provided.