From 255d5dc23b74d475e707e92eb40ef4c3aeb9138f Mon Sep 17 00:00:00 2001 From: Li Feiyang Date: Fri, 10 Oct 2025 16:19:54 +0800 Subject: [PATCH] refactor: remove unnecessary nodiscard attributes --- src/iceberg/partition_field.h | 2 +- src/iceberg/partition_spec.h | 2 +- src/iceberg/schema_field.h | 12 ++++++------ src/iceberg/sort_field.h | 2 +- src/iceberg/transform.h | 4 ++-- src/iceberg/type.h | 29 ++++++++++++++--------------- 6 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/iceberg/partition_field.h b/src/iceberg/partition_field.h index 5206cf260..be021048d 100644 --- a/src/iceberg/partition_field.h +++ b/src/iceberg/partition_field.h @@ -64,7 +64,7 @@ class ICEBERG_EXPORT PartitionField : public util::Formattable { private: /// \brief Compare two fields for equality. - [[nodiscard]] bool Equals(const PartitionField& other) const; + bool Equals(const PartitionField& other) const; int32_t source_id_; int32_t field_id_; diff --git a/src/iceberg/partition_spec.h b/src/iceberg/partition_spec.h index f105a27eb..65545d645 100644 --- a/src/iceberg/partition_spec.h +++ b/src/iceberg/partition_spec.h @@ -77,7 +77,7 @@ class ICEBERG_EXPORT PartitionSpec : public util::Formattable { private: /// \brief Compare two partition specs for equality. - [[nodiscard]] bool Equals(const PartitionSpec& other) const; + bool Equals(const PartitionSpec& other) const; std::shared_ptr schema_; const int32_t spec_id_; diff --git a/src/iceberg/schema_field.h b/src/iceberg/schema_field.h index e947f2036..ab100df73 100644 --- a/src/iceberg/schema_field.h +++ b/src/iceberg/schema_field.h @@ -56,21 +56,21 @@ class ICEBERG_EXPORT SchemaField : public iceberg::util::Formattable { std::shared_ptr type, std::string doc = {}); /// \brief Get the field ID. - [[nodiscard]] int32_t field_id() const; + int32_t field_id() const; /// \brief Get the field name. - [[nodiscard]] std::string_view name() const; + std::string_view name() const; /// \brief Get the field type. - [[nodiscard]] const std::shared_ptr& type() const; + const std::shared_ptr& type() const; /// \brief Get whether the field is optional. - [[nodiscard]] bool optional() const; + bool optional() const; /// \brief Get the field documentation. std::string_view doc() const; - [[nodiscard]] std::string ToString() const override; + std::string ToString() const override; friend bool operator==(const SchemaField& lhs, const SchemaField& rhs) { return lhs.Equals(rhs); @@ -78,7 +78,7 @@ class ICEBERG_EXPORT SchemaField : public iceberg::util::Formattable { private: /// \brief Compare two fields for equality. - [[nodiscard]] bool Equals(const SchemaField& other) const; + bool Equals(const SchemaField& other) const; int32_t field_id_; std::string name_; diff --git a/src/iceberg/sort_field.h b/src/iceberg/sort_field.h index 459472c6c..70caa312b 100644 --- a/src/iceberg/sort_field.h +++ b/src/iceberg/sort_field.h @@ -115,7 +115,7 @@ class ICEBERG_EXPORT SortField : public util::Formattable { private: /// \brief Compare two fields for equality. - [[nodiscard]] bool Equals(const SortField& other) const; + bool Equals(const SortField& other) const; int32_t source_id_; std::shared_ptr transform_; diff --git a/src/iceberg/transform.h b/src/iceberg/transform.h index e5a082355..6a303557b 100644 --- a/src/iceberg/transform.h +++ b/src/iceberg/transform.h @@ -169,7 +169,7 @@ class ICEBERG_EXPORT Transform : public util::Formattable { Transform(TransformType transform_type, int32_t param); /// \brief Checks equality with another Transform instance. - [[nodiscard]] virtual bool Equals(const Transform& other) const; + virtual bool Equals(const Transform& other) const; TransformType transform_type_; /// Optional parameter (e.g., num_buckets, width) @@ -210,7 +210,7 @@ class ICEBERG_EXPORT TransformFunction { private: /// \brief Compare two partition specs for equality. - [[nodiscard]] virtual bool Equals(const TransformFunction& other) const; + virtual bool Equals(const TransformFunction& other) const; TransformType transform_type_; std::shared_ptr source_type_; diff --git a/src/iceberg/type.h b/src/iceberg/type.h index 01c911dd8..6a3c53b59 100644 --- a/src/iceberg/type.h +++ b/src/iceberg/type.h @@ -53,20 +53,20 @@ class ICEBERG_EXPORT Type : public iceberg::util::Formattable { ~Type() override = default; /// \brief Get the type ID. - [[nodiscard]] virtual TypeId type_id() const = 0; + virtual TypeId type_id() const = 0; /// \brief Is this a primitive type (may not have child fields)? - [[nodiscard]] virtual bool is_primitive() const = 0; + virtual bool is_primitive() const = 0; /// \brief Is this a nested type (may have child fields)? - [[nodiscard]] virtual bool is_nested() const = 0; + virtual bool is_nested() const = 0; /// \brief Compare two types for equality. friend bool operator==(const Type& lhs, const Type& rhs) { return lhs.Equals(rhs); } protected: /// \brief Compare two types for equality. - [[nodiscard]] virtual bool Equals(const Type& other) const = 0; + virtual bool Equals(const Type& other) const = 0; }; /// \brief A data type that does not have child fields. @@ -83,28 +83,27 @@ class ICEBERG_EXPORT NestedType : public Type { bool is_nested() const override { return true; } /// \brief Get a view of the child fields. - [[nodiscard]] virtual std::span fields() const = 0; + virtual std::span fields() const = 0; using SchemaFieldConstRef = std::reference_wrapper; /// \brief Get a field by field ID. /// /// \note This is O(1) complexity. - [[nodiscard]] virtual Result> GetFieldById( + virtual Result> GetFieldById( int32_t field_id) const = 0; /// \brief Get a field by index. /// /// \note This is O(1) complexity. - [[nodiscard]] virtual Result> GetFieldByIndex( + virtual Result> GetFieldByIndex( int32_t index) const = 0; /// \brief Get a field by name. Return an error Status if /// the field name is not unique; prefer GetFieldById or GetFieldByIndex /// when possible. /// /// \note This is O(1) complexity. - [[nodiscard]] virtual Result> GetFieldByName( + virtual Result> GetFieldByName( std::string_view name, bool case_sensitive) const = 0; /// \brief Get a field by name (case-sensitive). - [[nodiscard]] Result> GetFieldByName( - std::string_view name) const; + Result> GetFieldByName(std::string_view name) const; }; /// \defgroup type-nested Nested Types @@ -305,10 +304,10 @@ class ICEBERG_EXPORT DecimalType : public PrimitiveType { ~DecimalType() override = default; /// \brief Get the precision (the number of decimal digits). - [[nodiscard]] int32_t precision() const; + int32_t precision() const; /// \brief Get the scale (essentially, the number of decimal digits after /// the decimal point; precisely, the value is scaled by $$10^{-s}$$.). - [[nodiscard]] int32_t scale() const; + int32_t scale() const; TypeId type_id() const override; std::string ToString() const override; @@ -358,9 +357,9 @@ class ICEBERG_EXPORT TimeType : public PrimitiveType { class ICEBERG_EXPORT TimestampBase : public PrimitiveType { public: /// \brief Is this type zoned or naive? - [[nodiscard]] virtual bool is_zoned() const = 0; + virtual bool is_zoned() const = 0; /// \brief The time resolution. - [[nodiscard]] virtual TimeUnit time_unit() const = 0; + virtual TimeUnit time_unit() const = 0; }; /// \brief A data type representing a timestamp in microseconds without @@ -442,7 +441,7 @@ class ICEBERG_EXPORT FixedType : public PrimitiveType { ~FixedType() override = default; /// \brief The length (the number of bytes to store). - [[nodiscard]] int32_t length() const; + int32_t length() const; TypeId type_id() const override; std::string ToString() const override;