Skip to content

Conversation

@WZhuo
Copy link
Contributor

@WZhuo WZhuo commented Jan 5, 2026

No description provided.

kFull,
};

static Result<std::shared_ptr<MetricsMode>> FromString(const std::string& mode);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static Result<std::shared_ptr<MetricsMode>> FromString(const std::string& mode);
static Result<std::shared_ptr<MetricsMode>> FromString(std::string_view mode);


static const std::shared_ptr<MetricsMode>& None();
static const std::shared_ptr<MetricsMode>& Counts();
static const std::shared_ptr<MetricsMode>& Truncate();
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no used, remove it

Comment on lines 98 to 99
std::unordered_map<std::string, std::shared_ptr<MetricsMode>> column_modes,
std::shared_ptr<MetricsMode> default_mode);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Member

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?

Copy link
Contributor Author

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


namespace iceberg {

class ICEBERG_EXPORT MetricsMode : public util::Formattable {
Copy link
Member

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;
};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static Result<std::shared_ptr<MetricsConfig>> Make(std::shared_ptr<Table> table);
static Result<std::unique_ptr<MetricsConfig>> Make(const Table& table);

return MetricsMode::Full();
}

if (mode.starts_with(kTruncatePrefix) && mode.ends_with(")")) {
Copy link
Member

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.

public:
explicit Visitor(int32_t limit) : limit_(limit) {}

Status Visit(const std::shared_ptr<Type>& type) {
Copy link
Member

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()) {
Copy link
Member

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.

@WZhuo WZhuo force-pushed the metric_config branch 2 times, most recently from 3877187 to 8a562d6 Compare January 9, 2026 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants