diff --git a/src/iceberg/catalog/memory/in_memory_catalog.cc b/src/iceberg/catalog/memory/in_memory_catalog.cc index 8a082aad1..da56717d2 100644 --- a/src/iceberg/catalog/memory/in_memory_catalog.cc +++ b/src/iceberg/catalog/memory/in_memory_catalog.cc @@ -509,14 +509,15 @@ Result InMemoryCatalog::TableExists(const TableIdentifier& identifier) con return root_namespace_->TableExists(identifier); } -Status InMemoryCatalog::DropTable(const TableIdentifier& identifier, bool purge) { +Status InMemoryCatalog::DropTable(const TableIdentifier& identifier, + [[maybe_unused]] bool purge) { std::unique_lock lock(mutex_); // TODO(Guotao): Delete all metadata files if purge is true. return root_namespace_->UnregisterTable(identifier); } -Status InMemoryCatalog::RenameTable(const TableIdentifier& from, - const TableIdentifier& to) { +Status InMemoryCatalog::RenameTable([[maybe_unused]] const TableIdentifier& from, + [[maybe_unused]] const TableIdentifier& to) { std::unique_lock lock(mutex_); return NotImplemented("rename table"); } diff --git a/src/iceberg/catalog/rest/types.h b/src/iceberg/catalog/rest/types.h index 93e7048a5..86ab9669f 100644 --- a/src/iceberg/catalog/rest/types.h +++ b/src/iceberg/catalog/rest/types.h @@ -39,9 +39,9 @@ namespace iceberg::rest { /// \brief Server-provided configuration for the catalog. struct ICEBERG_REST_EXPORT CatalogConfig { - std::unordered_map defaults; // required - std::unordered_map overrides; // required - std::vector endpoints; + std::unordered_map defaults{}; // required + std::unordered_map overrides{}; // required + std::vector endpoints{}; /// \brief Validates the CatalogConfig. Status Validate() const { return {}; } @@ -54,7 +54,7 @@ struct ICEBERG_REST_EXPORT ErrorResponse { uint32_t code; // required std::string type; // required std::string message; // required - std::vector stack; + std::vector stack{}; /// \brief Validates the ErrorResponse. Status Validate() const { @@ -77,7 +77,7 @@ struct ICEBERG_REST_EXPORT ErrorResponse { /// \brief Request to create a namespace. struct ICEBERG_REST_EXPORT CreateNamespaceRequest { Namespace namespace_; // required - std::unordered_map properties; + std::unordered_map properties{}; /// \brief Validates the CreateNamespaceRequest. Status Validate() const { return {}; } @@ -87,8 +87,8 @@ struct ICEBERG_REST_EXPORT CreateNamespaceRequest { /// \brief Update or delete namespace properties request. struct ICEBERG_REST_EXPORT UpdateNamespacePropertiesRequest { - std::vector removals; - std::unordered_map updates; + std::vector removals{}; + std::unordered_map updates{}; /// \brief Validates the UpdateNamespacePropertiesRequest. Status Validate() const { @@ -142,13 +142,13 @@ struct ICEBERG_REST_EXPORT RenameTableRequest { /// \brief Request to create a table. struct ICEBERG_REST_EXPORT CreateTableRequest { - std::string name; // required - std::string location; - std::shared_ptr schema; // required - std::shared_ptr partition_spec; - std::shared_ptr write_order; + std::string name = ""; // required + std::string location = ""; + std::shared_ptr schema = nullptr; // required + std::shared_ptr partition_spec = nullptr; + std::shared_ptr write_order = nullptr; bool stage_create = false; - std::unordered_map properties; + std::unordered_map properties{}; /// \brief Validates the CreateTableRequest. Status Validate() const { @@ -169,9 +169,9 @@ using PageToken = std::string; /// \brief Result body for table create/load/register APIs. struct ICEBERG_REST_EXPORT LoadTableResult { - std::string metadata_location; - std::shared_ptr metadata; // required - std::unordered_map config; + std::string metadata_location = ""; + std::shared_ptr metadata = nullptr; // required + std::unordered_map config{}; // TODO(Li Feiyang): Add std::shared_ptr storage_credential; /// \brief Validates the LoadTableResult. @@ -194,7 +194,7 @@ using LoadTableResponse = LoadTableResult; /// \brief Response body for listing namespaces. struct ICEBERG_REST_EXPORT ListNamespacesResponse { PageToken next_page_token; - std::vector namespaces; + std::vector namespaces{}; /// \brief Validates the ListNamespacesResponse. Status Validate() const { return {}; } @@ -205,7 +205,7 @@ struct ICEBERG_REST_EXPORT ListNamespacesResponse { /// \brief Response body after creating a namespace. struct ICEBERG_REST_EXPORT CreateNamespaceResponse { Namespace namespace_; // required - std::unordered_map properties; + std::unordered_map properties{}; /// \brief Validates the CreateNamespaceResponse. Status Validate() const { return {}; } @@ -216,7 +216,7 @@ struct ICEBERG_REST_EXPORT CreateNamespaceResponse { /// \brief Response body for loading namespace properties. struct ICEBERG_REST_EXPORT GetNamespaceResponse { Namespace namespace_; // required - std::unordered_map properties; + std::unordered_map properties{}; /// \brief Validates the GetNamespaceResponse. Status Validate() const { return {}; } @@ -226,9 +226,9 @@ struct ICEBERG_REST_EXPORT GetNamespaceResponse { /// \brief Response body after updating namespace properties. struct ICEBERG_REST_EXPORT UpdateNamespacePropertiesResponse { - std::vector updated; // required - std::vector removed; // required - std::vector missing; + std::vector updated{}; // required + std::vector removed{}; // required + std::vector missing{}; /// \brief Validates the UpdateNamespacePropertiesResponse. Status Validate() const { return {}; } @@ -239,7 +239,7 @@ struct ICEBERG_REST_EXPORT UpdateNamespacePropertiesResponse { /// \brief Response body for listing tables in a namespace. struct ICEBERG_REST_EXPORT ListTablesResponse { PageToken next_page_token; - std::vector identifiers; + std::vector identifiers{}; /// \brief Validates the ListTablesResponse. Status Validate() const { return {}; } @@ -249,9 +249,9 @@ struct ICEBERG_REST_EXPORT ListTablesResponse { /// \brief Request to commit changes to a table. struct ICEBERG_REST_EXPORT CommitTableRequest { - TableIdentifier identifier; - std::vector> requirements; // required - std::vector> updates; // required + TableIdentifier identifier{}; + std::vector> requirements{}; // required + std::vector> updates{}; // required /// \brief Validates the CommitTableRequest. Status Validate() const { return {}; } diff --git a/src/iceberg/expression/binder.cc b/src/iceberg/expression/binder.cc index 9474151d7..3bea82a37 100644 --- a/src/iceberg/expression/binder.cc +++ b/src/iceberg/expression/binder.cc @@ -103,20 +103,23 @@ Result IsBoundVisitor::Or(bool left_result, bool right_result) { return left_result && right_result; } -Result IsBoundVisitor::Predicate(const std::shared_ptr& pred) { +Result IsBoundVisitor::Predicate( + [[maybe_unused]] const std::shared_ptr& pred) { return true; } -Result IsBoundVisitor::Predicate(const std::shared_ptr& pred) { +Result IsBoundVisitor::Predicate( + [[maybe_unused]] const std::shared_ptr& pred) { return false; } -Result IsBoundVisitor::Aggregate(const std::shared_ptr& aggregate) { +Result IsBoundVisitor::Aggregate( + [[maybe_unused]] const std::shared_ptr& aggregate) { return true; } Result IsBoundVisitor::Aggregate( - const std::shared_ptr& aggregate) { + [[maybe_unused]] const std::shared_ptr& aggregate) { return false; } diff --git a/src/iceberg/expression/expression.h b/src/iceberg/expression/expression.h index 35ffbfdfe..4b6fbb38b 100644 --- a/src/iceberg/expression/expression.h +++ b/src/iceberg/expression/expression.h @@ -77,7 +77,7 @@ class ICEBERG_EXPORT Expression : public util::Formattable { /// \brief Returns whether this expression will accept the same values as another. /// \param other another expression /// \return true if the expressions are equivalent - virtual bool Equals(const Expression& other) const { + virtual bool Equals([[maybe_unused]] const Expression& other) const { // only bound predicates can be equivalent return false; } diff --git a/src/iceberg/expression/expression_visitor.h b/src/iceberg/expression/expression_visitor.h index 27cfb99c1..25e13b0ec 100644 --- a/src/iceberg/expression/expression_visitor.h +++ b/src/iceberg/expression/expression_visitor.h @@ -117,13 +117,13 @@ class ICEBERG_EXPORT BoundVisitor : public ExpressionVisitor { /// \brief Visit an IS_NAN bound expression. /// \param expr The bound expression being tested - virtual Result IsNaN(const std::shared_ptr& expr) { + virtual Result IsNaN([[maybe_unused]] const std::shared_ptr& expr) { return NotSupported("IsNaN operation is not supported by this visitor"); } /// \brief Visit a NOT_NAN bound expression. /// \param expr The bound expression being tested - virtual Result NotNaN(const std::shared_ptr& expr) { + virtual Result NotNaN([[maybe_unused]] const std::shared_ptr& expr) { return NotSupported("NotNaN operation is not supported by this visitor"); } diff --git a/src/iceberg/expression/expressions.cc b/src/iceberg/expression/expressions.cc index 4b0e538ae..590fe1d10 100644 --- a/src/iceberg/expression/expressions.cc +++ b/src/iceberg/expression/expressions.cc @@ -292,7 +292,8 @@ std::shared_ptr Expressions::Ref(std::string name) { return ref; } -Literal Expressions::Lit(Literal::Value value, std::shared_ptr type) { +Literal Expressions::Lit([[maybe_unused]] Literal::Value value, + [[maybe_unused]] std::shared_ptr type) { throw ExpressionError("Literal creation is not implemented"); } diff --git a/src/iceberg/expression/inclusive_metrics_evaluator.cc b/src/iceberg/expression/inclusive_metrics_evaluator.cc index 29f5aba24..8dbb9de69 100644 --- a/src/iceberg/expression/inclusive_metrics_evaluator.cc +++ b/src/iceberg/expression/inclusive_metrics_evaluator.cc @@ -220,7 +220,8 @@ class InclusiveMetricsVisitor : public BoundVisitor { return kRowsMightMatch; } - Result NotEq(const std::shared_ptr& expr, const Literal& lit) override { + Result NotEq([[maybe_unused]] const std::shared_ptr& expr, + [[maybe_unused]] const Literal& lit) override { // because the bounds are not necessarily a min or max value, this cannot be answered // using them. notEq(col, X) with (X, Y) doesn't guarantee that X is a value in col. return kRowsMightMatch; @@ -267,8 +268,9 @@ class InclusiveMetricsVisitor : public BoundVisitor { return kRowsMightMatch; } - Result NotIn(const std::shared_ptr& expr, - const BoundSetPredicate::LiteralSet& literal_set) override { + Result NotIn( + [[maybe_unused]] const std::shared_ptr& expr, + [[maybe_unused]] const BoundSetPredicate::LiteralSet& literal_set) override { // because the bounds are not necessarily a min or max value, this cannot be answered // using them. notIn(col, {X, ...}) with (X, Y) doesn't guarantee that X is a value in // col. diff --git a/src/iceberg/expression/literal.cc b/src/iceberg/expression/literal.cc index 88bafd78d..3ed97443f 100644 --- a/src/iceberg/expression/literal.cc +++ b/src/iceberg/expression/literal.cc @@ -23,6 +23,7 @@ #include #include #include +#include #include "iceberg/util/checked_cast.h" #include "iceberg/util/conversions.h" @@ -245,7 +246,7 @@ Result LiteralCaster::CastFromBinary( switch (target_type->type_id()) { case TypeId::kFixed: { auto target_fixed_type = internal::checked_pointer_cast(target_type); - if (binary_val.size() == target_fixed_type->length()) { + if (std::cmp_equal(binary_val.size(), target_fixed_type->length())) { return Literal::Fixed(std::move(binary_val)); } return InvalidArgument("Failed to cast Binary with length {} to Fixed({})", @@ -525,8 +526,8 @@ bool Literal::IsAboveMax() const { return std::holds_alternative(value bool Literal::IsNull() const { return std::holds_alternative(value_); } bool Literal::IsNaN() const { - return std::holds_alternative(value_) && std::isnan(std::get(value_)) || - std::holds_alternative(value_) && std::isnan(std::get(value_)); + return (std::holds_alternative(value_) && std::isnan(std::get(value_))) || + (std::holds_alternative(value_) && std::isnan(std::get(value_))); } // LiteralCaster implementation diff --git a/src/iceberg/expression/manifest_evaluator.cc b/src/iceberg/expression/manifest_evaluator.cc index bc7d0bfe6..46783ee70 100644 --- a/src/iceberg/expression/manifest_evaluator.cc +++ b/src/iceberg/expression/manifest_evaluator.cc @@ -187,7 +187,8 @@ class ManifestEvalVisitor : public BoundVisitor { return kRowsMightMatch; } - Result NotEq(const std::shared_ptr& expr, const Literal& lit) override { + Result NotEq([[maybe_unused]] const std::shared_ptr& expr, + [[maybe_unused]] const Literal& lit) override { // because the bounds are not necessarily a min or max value, this cannot be answered // using them. notEq(col, X) with (X, Y) doesn't guarantee that X is a value in col. return kRowsMightMatch; @@ -222,8 +223,9 @@ class ManifestEvalVisitor : public BoundVisitor { return kRowsMightMatch; } - Result NotIn(const std::shared_ptr& expr, - const BoundSetPredicate::LiteralSet& literal_set) override { + Result NotIn( + [[maybe_unused]] const std::shared_ptr& expr, + [[maybe_unused]] const BoundSetPredicate::LiteralSet& literal_set) override { // because the bounds are not necessarily a min or max value, this cannot be answered // using them. notIn(col, {X, ...}) with (X, Y) doesn't guarantee that X is a value in // col. @@ -339,8 +341,8 @@ class ManifestEvalVisitor : public BoundVisitor { if (!type->is_primitive()) { return NotSupported("Bounds of non-primitive partition fields are not supported."); } - return Literal::Deserialize( - bound, std::move(internal::checked_pointer_cast(type))); + return Literal::Deserialize(bound, + internal::checked_pointer_cast(type)); } private: diff --git a/src/iceberg/expression/projections.cc b/src/iceberg/expression/projections.cc index dd83ef801..153695b6c 100644 --- a/src/iceberg/expression/projections.cc +++ b/src/iceberg/expression/projections.cc @@ -44,7 +44,7 @@ class ProjectionVisitor : public ExpressionVisitor> Result> AlwaysFalse() override { return False::Instance(); } Result> Not( - const std::shared_ptr& child_result) override { + [[maybe_unused]] const std::shared_ptr& child_result) override { return InvalidExpression("Project called on expression with a not"); } @@ -70,7 +70,7 @@ class ProjectionVisitor : public ExpressionVisitor> } Result> Predicate( - const std::shared_ptr& pred) override { + [[maybe_unused]] const std::shared_ptr& pred) override { return InvalidExpression("Bound predicates are not supported in projections"); } diff --git a/src/iceberg/expression/projections.h b/src/iceberg/expression/projections.h index b2022c4f1..59edc9236 100644 --- a/src/iceberg/expression/projections.h +++ b/src/iceberg/expression/projections.h @@ -43,7 +43,7 @@ class ICEBERG_EXPORT ProjectionEvaluator { Result> Project(const std::shared_ptr& expr); private: - friend class Projections; + friend struct Projections; /// \brief Create a ProjectionEvaluator. /// diff --git a/src/iceberg/expression/strict_metrics_evaluator.cc b/src/iceberg/expression/strict_metrics_evaluator.cc index e2fe34f14..63b058ad9 100644 --- a/src/iceberg/expression/strict_metrics_evaluator.cc +++ b/src/iceberg/expression/strict_metrics_evaluator.cc @@ -411,13 +411,13 @@ class StrictMetricsVisitor : public BoundVisitor { return kRowsMightNotMatch; } - Result StartsWith(const std::shared_ptr& expr, - const Literal& lit) override { + Result StartsWith([[maybe_unused]] const std::shared_ptr& expr, + [[maybe_unused]] const Literal& lit) override { return kRowsMightNotMatch; } - Result NotStartsWith(const std::shared_ptr& expr, - const Literal& lit) override { + Result NotStartsWith([[maybe_unused]] const std::shared_ptr& expr, + [[maybe_unused]] const Literal& lit) override { // TODO(xiao.dong) Handle cases that definitely cannot match, // such as notStartsWith("x") when // the bounds are ["a", "b"]. diff --git a/src/iceberg/file_io.h b/src/iceberg/file_io.h index 259da7556..ad5b44ad0 100644 --- a/src/iceberg/file_io.h +++ b/src/iceberg/file_io.h @@ -49,8 +49,8 @@ class ICEBERG_EXPORT FileIO { /// the length to read, e.g. S3 `GetObject` has a Range parameter. /// \return The content of the file if the read succeeded, an error code if the read /// failed. - virtual Result ReadFile(const std::string& file_location, - std::optional length) { + virtual Result ReadFile([[maybe_unused]] const std::string& file_location, + [[maybe_unused]] std::optional length) { // We provide a default implementation to avoid Windows linker error LNK2019. return NotImplemented("ReadFile not implemented"); } @@ -62,7 +62,8 @@ class ICEBERG_EXPORT FileIO { /// \param overwrite If true, overwrite the file if it exists. If false, fail if the /// file exists. /// \return void if the write succeeded, an error code if the write failed. - virtual Status WriteFile(const std::string& file_location, std::string_view content) { + virtual Status WriteFile([[maybe_unused]] const std::string& file_location, + [[maybe_unused]] std::string_view content) { return NotImplemented("WriteFile not implemented"); } @@ -70,7 +71,7 @@ class ICEBERG_EXPORT FileIO { /// /// \param file_location The location of the file to delete. /// \return void if the delete succeeded, an error code if the delete failed. - virtual Status DeleteFile(const std::string& file_location) { + virtual Status DeleteFile([[maybe_unused]] const std::string& file_location) { return NotImplemented("DeleteFile not implemented"); } }; diff --git a/src/iceberg/file_reader.h b/src/iceberg/file_reader.h index 923ac6bdb..fca0fb69a 100644 --- a/src/iceberg/file_reader.h +++ b/src/iceberg/file_reader.h @@ -92,23 +92,23 @@ struct ICEBERG_EXPORT ReaderOptions { /// \brief The path to the file to read. std::string path; /// \brief The total length of the file. - std::optional length; + std::optional length = std::nullopt; /// \brief The split to read. - std::optional split; + std::optional split = std::nullopt; /// \brief FileIO instance to open the file. Reader implementations should down cast it /// to the specific FileIO implementation. By default, the `iceberg-bundle` library uses /// `ArrowFileSystemFileIO` as the default implementation. - std::shared_ptr io; + std::shared_ptr io = nullptr; /// \brief The projection schema to read from the file. This field is required. - std::shared_ptr projection; + std::shared_ptr projection = nullptr; /// \brief The filter to apply to the data. Reader implementations may ignore this if /// the file format does not support filtering. - std::shared_ptr filter; + std::shared_ptr filter = nullptr; /// \brief Name mapping for schema evolution compatibility. Used when reading files /// that may have different field names than the current schema. - std::shared_ptr name_mapping; + std::shared_ptr name_mapping = nullptr; /// \brief Format-specific or implementation-specific properties. - ReaderProperties properties; + ReaderProperties properties{}; }; /// \brief Factory function to create a reader of a specific file format. diff --git a/src/iceberg/manifest/manifest_adapter.cc b/src/iceberg/manifest/manifest_adapter.cc index cf0a0515b..b3577858f 100644 --- a/src/iceberg/manifest/manifest_adapter.cc +++ b/src/iceberg/manifest/manifest_adapter.cc @@ -166,7 +166,8 @@ ManifestEntryAdapter::~ManifestEntryAdapter() { Status ManifestEntryAdapter::AppendPartitionValues( ArrowArray* array, const std::shared_ptr& partition_type, const PartitionValues& partition_values) { - if (array->n_children != partition_type->fields().size()) [[unlikely]] { + if (std::cmp_not_equal(array->n_children, partition_type->fields().size())) + [[unlikely]] { return InvalidArrowData("Arrow array of partition does not match partition type."); } if (partition_values.num_fields() != partition_type->fields().size()) [[unlikely]] { diff --git a/src/iceberg/manifest/manifest_entry.h b/src/iceberg/manifest/manifest_entry.h index c1f81d0ae..8f96799c5 100644 --- a/src/iceberg/manifest/manifest_entry.h +++ b/src/iceberg/manifest/manifest_entry.h @@ -73,14 +73,14 @@ struct ICEBERG_EXPORT DataFile { Content content = Content::kData; /// Field id: 100 /// Full URI for the file with FS scheme - std::string file_path; + std::string file_path = ""; /// Field id: 101 /// File format type, avro, orc, parquet, or puffin FileFormatType file_format = FileFormatType::kParquet; /// Field id: 102 /// Partition data tuple, schema based on the partition spec output using partition /// field ids - PartitionValues partition; + PartitionValues partition{}; /// Field id: 103 /// Number of records in this file, or the cardinality of a deletion vector int64_t record_count = 0; @@ -93,50 +93,50 @@ struct ICEBERG_EXPORT DataFile { /// Map from column id to the total size on disk of all regions that store the column. /// Does not include bytes necessary to read other columns, like footers. Leave null for /// row-oriented formats (Avro) - std::map column_sizes; + std::map column_sizes{}; /// Field id: 109 /// Key field id: 119 /// Value field id: 120 /// Map from column id to number of values in the column (including null and NaN values) - std::map value_counts; + std::map value_counts{}; /// Field id: 110 /// Key field id: 121 /// Value field id: 122 /// Map from column id to number of null values in the column - std::map null_value_counts; + std::map null_value_counts{}; /// Field id: 137 /// Key field id: 138 /// Value field id: 139 /// Map from column id to number of NaN values in the column - std::map nan_value_counts; + std::map nan_value_counts{}; /// Field id: 125 /// Key field id: 126 /// Value field id: 127 /// Map from column id to lower bound in the column serialized as binary. /// Each value must be less than or equal to all non-null, non-NaN values in the column /// for the file. - std::map> lower_bounds; + std::map> lower_bounds{}; /// Field id: 128 /// Key field id: 129 /// Value field id: 130 /// Map from column id to upper bound in the column serialized as binary. /// Each value must be greater than or equal to all non-null, non-NaN values in the /// column for the file. - std::map> upper_bounds; + std::map> upper_bounds{}; /// Field id: 131 /// Implementation-specific key metadata for encryption - std::vector key_metadata; + std::vector key_metadata{}; /// Field id: 132 /// Element Field id: 133 /// Split offsets for the data file. For example, all row group offsets in a Parquet /// file. Must be sorted ascending. - std::vector split_offsets; + std::vector split_offsets{}; /// Field id: 135 /// Element Field id: 136 /// Field ids used to determine row equality in equality delete files. Required when /// content=2 and should be null otherwise. Fields with ids listed in this column must /// be present in the delete file. - std::vector equality_ids; + std::vector equality_ids{}; /// Field id: 140 /// ID representing sort order for this file /// @@ -145,14 +145,14 @@ struct ICEBERG_EXPORT DataFile { /// id. Position deletes are required to be sorted by file and position, not a table /// order, and should set sort order id to null. Readers must ignore sort order id for /// position delete files. - std::optional sort_order_id; + std::optional sort_order_id = std::nullopt; /// Field id: 142 /// The _row_id for the first row in the data file. /// /// Reference: /// - [First Row ID /// Inheritance](https://github.com/apache/iceberg/blob/main/format/spec.md#first-row-id-inheritance) - std::optional first_row_id; + std::optional first_row_id = std::nullopt; /// Field id: 143 /// Fully qualified location (URI with FS scheme) of a data file that all deletes /// reference. @@ -160,7 +160,7 @@ struct ICEBERG_EXPORT DataFile { /// Position delete metadata can use referenced_data_file when all deletes tracked by /// the entry are in a single data file. Setting the referenced file is required for /// deletion vectors. - std::optional referenced_data_file; + std::optional referenced_data_file = std::nullopt; /// Field id: 144 /// The offset in the file where the content starts. /// @@ -168,16 +168,16 @@ struct ICEBERG_EXPORT DataFile { /// blob for direct access to a deletion vector. For deletion vectors, these values are /// required and must exactly match the offset and length stored in the Puffin footer /// for the deletion vector blob. - std::optional content_offset; + std::optional content_offset = std::nullopt; /// Field id: 145 /// The length of a referenced content stored in the file; required if content_offset is /// present - std::optional content_size_in_bytes; + std::optional content_size_in_bytes = std::nullopt; /// \brief Partition spec id for this data file. /// \note This field is for internal use only and will not be persisted to manifest /// entry. - std::optional partition_spec_id; + std::optional partition_spec_id = std::nullopt; static constexpr int32_t kContentFieldId = 134; inline static const SchemaField kContent = SchemaField::MakeOptional( diff --git a/src/iceberg/manifest/manifest_list.h b/src/iceberg/manifest/manifest_list.h index 2f3185a18..9268570a0 100644 --- a/src/iceberg/manifest/manifest_list.h +++ b/src/iceberg/manifest/manifest_list.h @@ -136,13 +136,13 @@ struct ICEBERG_EXPORT ManifestFile { /// Element field id: 508 /// A list of field summaries for each partition field in the spec. Each field in the /// list corresponds to a field in the manifest file's partition spec. - std::vector partitions; + std::vector partitions{}; /// Field id: 519 /// Implementation-specific key metadata for encryption - std::vector key_metadata; + std::vector key_metadata{}; /// Field id: 520 /// The starting _row_id to assign to rows added by ADDED data files - std::optional first_row_id; + std::optional first_row_id = std::nullopt; /// \brief Checks if this manifest file contains entries with ADDED status. bool has_added_files() const { return added_files_count.value_or(1) > 0; } diff --git a/src/iceberg/metrics_config.cc b/src/iceberg/metrics_config.cc index e378640e0..91d98d0ad 100644 --- a/src/iceberg/metrics_config.cc +++ b/src/iceberg/metrics_config.cc @@ -198,12 +198,12 @@ Result> MetricsConfig::LimitFieldIds(const Schema& s return {}; } - Status VisitPrimitive(const PrimitiveType& type) { return {}; } + Status VisitPrimitive([[maybe_unused]] const PrimitiveType& type) { return {}; } std::unordered_set Finish() const { return ids_; } private: - bool ShouldContinue() { return ids_.size() < limit_; } + bool ShouldContinue() { return std::cmp_less(ids_.size(), limit_); } private: std::unordered_set ids_; diff --git a/src/iceberg/metrics_config.h b/src/iceberg/metrics_config.h index 7a49e906f..19b4c1b94 100644 --- a/src/iceberg/metrics_config.h +++ b/src/iceberg/metrics_config.h @@ -51,7 +51,7 @@ struct ICEBERG_EXPORT MetricsMode { static MetricsMode Full(); Kind kind; - std::variant length; + std::variant length = std::monostate{}; }; /// \brief Configuration for collecting column metrics for an Iceberg table. diff --git a/src/iceberg/name_mapping.cc b/src/iceberg/name_mapping.cc index eaf6199ee..b8b548356 100644 --- a/src/iceberg/name_mapping.cc +++ b/src/iceberg/name_mapping.cc @@ -303,7 +303,7 @@ class CreateMappingVisitor { } template - Result> Visit(const T& type) const { + Result> Visit([[maybe_unused]] const T& type) const { return nullptr; } diff --git a/src/iceberg/name_mapping.h b/src/iceberg/name_mapping.h index 41ff2d14e..f5e58441c 100644 --- a/src/iceberg/name_mapping.h +++ b/src/iceberg/name_mapping.h @@ -44,7 +44,7 @@ struct ICEBERG_EXPORT MappedField { std::optional field_id; /// \brief An optional list of field mappings for child field of structs, maps, and /// lists. - std::shared_ptr nested_mapping; + std::shared_ptr nested_mapping = nullptr; friend bool operator==(const MappedField& lhs, const MappedField& rhs); }; diff --git a/src/iceberg/partition_spec.cc b/src/iceberg/partition_spec.cc index c00eab7d2..2e42dc9b6 100644 --- a/src/iceberg/partition_spec.cc +++ b/src/iceberg/partition_spec.cc @@ -106,7 +106,7 @@ Result PartitionSpec::PartitionPath(const PartitionValues& data) co "Partition spec and data mismatch, expected field num {}, got {}", fields_.size(), data.num_fields()); std::stringstream ss; - for (int32_t i = 0; i < fields_.size(); ++i) { + for (size_t i = 0; i < fields_.size(); ++i) { ICEBERG_ASSIGN_OR_RAISE(auto value, data.ValueAt(i)); if (i > 0) { ss << "/"; @@ -275,7 +275,8 @@ Result> PartitionSpec::Make( bool PartitionSpec::HasSequentialFieldIds(const PartitionSpec& spec) { for (size_t i = 0; i < spec.fields().size(); i += 1) { - if (spec.fields()[i].field_id() != PartitionSpec::kLegacyPartitionDataIdStart + i) { + if (std::cmp_not_equal(spec.fields()[i].field_id(), + kLegacyPartitionDataIdStart + i)) { return false; } } diff --git a/src/iceberg/schema.cc b/src/iceberg/schema.cc index 00905378a..e9b46975c 100644 --- a/src/iceberg/schema.cc +++ b/src/iceberg/schema.cc @@ -150,7 +150,7 @@ std::string Schema::ToString() const { return repr; } -bool Schema::Equals(const Schema& other) const { +bool Schema::EqualsSchema(const Schema& other) const { return schema_id_ == other.schema_id_ && fields_ == other.fields_ && identifier_field_ids_ == other.identifier_field_ids_; } diff --git a/src/iceberg/schema.h b/src/iceberg/schema.h index bcaccaa15..d3d466ee6 100644 --- a/src/iceberg/schema.h +++ b/src/iceberg/schema.h @@ -184,11 +184,13 @@ class ICEBERG_EXPORT Schema : public StructType { /// \return Error status if the schema is invalid. Status Validate(int32_t format_version) const; - friend bool operator==(const Schema& lhs, const Schema& rhs) { return lhs.Equals(rhs); } + friend bool operator==(const Schema& lhs, const Schema& rhs) { + return lhs.EqualsSchema(rhs); + } private: /// \brief Compare two schemas for equality. - bool Equals(const Schema& other) const; + bool EqualsSchema(const Schema& other) const; const int32_t schema_id_; // Field IDs that uniquely identify rows in the table. diff --git a/src/iceberg/snapshot.h b/src/iceberg/snapshot.h index f3e7ffb85..fb4660c23 100644 --- a/src/iceberg/snapshot.h +++ b/src/iceberg/snapshot.h @@ -390,19 +390,19 @@ struct ICEBERG_EXPORT Snapshot { /// A unique long ID. int64_t snapshot_id; /// The snapshot ID of the snapshot's parent. Omitted for any snapshot with no parent. - std::optional parent_snapshot_id; + std::optional parent_snapshot_id = std::nullopt; /// A monotonically increasing long that tracks the order of changes to a table. - int64_t sequence_number; + int64_t sequence_number = 0; /// A timestamp when the snapshot was created, used for garbage collection and table /// inspection. - TimePointMs timestamp_ms; + TimePointMs timestamp_ms{}; /// The location of a manifest list for this snapshot that tracks manifest files with /// additional metadata. - std::string manifest_list; + std::string manifest_list = ""; /// A string map that summaries the snapshot changes, including operation. - std::unordered_map summary; + std::unordered_map summary{}; /// ID of the table's current schema when the snapshot was created. - std::optional schema_id; + std::optional schema_id = std::nullopt; /// \brief Create a new Snapshot instance with validation on the inputs. static Result> Make( diff --git a/src/iceberg/table_metadata.cc b/src/iceberg/table_metadata.cc index d3b5629c8..14ea2add2 100644 --- a/src/iceberg/table_metadata.cc +++ b/src/iceberg/table_metadata.cc @@ -472,7 +472,8 @@ Result> TableMetadataUtil::Read( return TableMetadataFromJson(json); } -Result TableMetadataUtil::Write(FileIO& io, const TableMetadata* base, +Result TableMetadataUtil::Write(FileIO& io, + [[maybe_unused]] const TableMetadata* base, const std::string& base_metadata_location, TableMetadata& metadata) { int32_t version = ParseVersionFromLocation(base_metadata_location); @@ -559,7 +560,7 @@ class TableMetadataBuilder::Impl { // Constructor from existing metadata explicit Impl(const TableMetadata* base_metadata, - std::string base_metadata_location = "") + [[maybe_unused]] std::string base_metadata_location = "") : base_(base_metadata), metadata_(*base_metadata) { // Initialize index maps from base metadata for (const auto& schema : metadata_.schemas) { @@ -1351,7 +1352,7 @@ Result> TableMetadataBuilder::Impl::Build() { metadata_.metadata_log.emplace_back(base_->last_updated_ms, previous_metadata_location_); } - if (metadata_.metadata_log.size() > max_metadata_log_size) { + if (std::cmp_greater(metadata_.metadata_log.size(), max_metadata_log_size)) { metadata_.metadata_log.erase(metadata_.metadata_log.begin(), metadata_.metadata_log.end() - max_metadata_log_size); } @@ -1584,7 +1585,7 @@ TableMetadataBuilder& TableMetadataBuilder::SetDefaultPartitionSpec(int32_t spec TableMetadataBuilder& TableMetadataBuilder::AddPartitionSpec( std::shared_ptr spec) { - ICEBERG_BUILDER_ASSIGN_OR_RETURN(auto spec_id, impl_->AddPartitionSpec(*spec)); + ICEBERG_BUILDER_ASSIGN_OR_RETURN(auto _, impl_->AddPartitionSpec(*spec)); return *this; } @@ -1613,7 +1614,7 @@ TableMetadataBuilder& TableMetadataBuilder::SetDefaultSortOrder(int32_t order_id TableMetadataBuilder& TableMetadataBuilder::AddSortOrder( std::shared_ptr order) { - ICEBERG_BUILDER_ASSIGN_OR_RETURN(auto order_id, impl_->AddSortOrder(*order)); + ICEBERG_BUILDER_ASSIGN_OR_RETURN(auto _, impl_->AddSortOrder(*order)); return *this; } @@ -1647,7 +1648,7 @@ TableMetadataBuilder& TableMetadataBuilder::RemoveRef(const std::string& name) { } TableMetadataBuilder& TableMetadataBuilder::RemoveSnapshots( - const std::vector>& snapshots_to_remove) { + [[maybe_unused]] const std::vector>& snapshots_to_remove) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } @@ -1703,11 +1704,12 @@ TableMetadataBuilder& TableMetadataBuilder::SetLocation(std::string_view locatio } TableMetadataBuilder& TableMetadataBuilder::AddEncryptionKey( - std::shared_ptr key) { + [[maybe_unused]] std::shared_ptr key) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } -TableMetadataBuilder& TableMetadataBuilder::RemoveEncryptionKey(std::string_view key_id) { +TableMetadataBuilder& TableMetadataBuilder::RemoveEncryptionKey( + [[maybe_unused]] std::string_view key_id) { throw IcebergError(std::format("{} not implemented", __FUNCTION__)); } diff --git a/src/iceberg/table_metadata.h b/src/iceberg/table_metadata.h index cfae0ce2c..5b5fe1002 100644 --- a/src/iceberg/table_metadata.h +++ b/src/iceberg/table_metadata.h @@ -77,58 +77,58 @@ struct ICEBERG_EXPORT TableMetadata { static constexpr int64_t kInitialSequenceNumber = 0; static constexpr int64_t kInitialRowId = 0; - static inline const std::unordered_map kMinFormatVersions = {}; + static inline const std::unordered_map kMinFormatVersions{}; /// An integer version number for the format - int8_t format_version; + int8_t format_version = 0; /// A UUID that identifies the table - std::string table_uuid; + std::string table_uuid = ""; /// The table's base location - std::string location; + std::string location = ""; /// The table's highest assigned sequence number - int64_t last_sequence_number; + int64_t last_sequence_number = 0; /// Timestamp in milliseconds from the unix epoch when the table was last updated. - TimePointMs last_updated_ms; + TimePointMs last_updated_ms{}; /// The highest assigned column ID for the table - int32_t last_column_id; + int32_t last_column_id = 0; /// A list of schemas - std::vector> schemas; + std::vector> schemas{}; /// ID of the table's current schema - int32_t current_schema_id; + int32_t current_schema_id = 0; /// A list of partition specs - std::vector> partition_specs; + std::vector> partition_specs{}; /// ID of the current partition spec that writers should use by default - int32_t default_spec_id; + int32_t default_spec_id{}; /// The highest assigned partition field ID across all partition specs for the table - int32_t last_partition_id; + int32_t last_partition_id{}; /// A string to string map of table properties - TableProperties properties; + TableProperties properties{}; /// ID of the current table snapshot - int64_t current_snapshot_id; + int64_t current_snapshot_id = 0; /// A list of valid snapshots - std::vector> snapshots; + std::vector> snapshots{}; /// A list of timestamp and snapshot ID pairs that encodes changes to the current /// snapshot for the table - std::vector snapshot_log; + std::vector snapshot_log{}; /// A list of timestamp and metadata file location pairs that encodes changes to the /// previous metadata files for the table - std::vector metadata_log; + std::vector metadata_log{}; /// A list of sort orders - std::vector> sort_orders; + std::vector> sort_orders{}; /// Default sort order id of the table - int32_t default_sort_order_id; + int32_t default_sort_order_id = 0; /// A map of snapshot references - std::unordered_map> refs; + std::unordered_map> refs{}; /// A list of table statistics - std::vector> statistics; + std::vector> statistics{}; /// A list of partition statistics - std::vector> partition_statistics; + std::vector> partition_statistics{}; /// A `long` higher than all assigned row IDs - int64_t next_row_id; + int64_t next_row_id = 0; static Result> Make( - const iceberg::Schema& schema, const iceberg::PartitionSpec& spec, - const iceberg::SortOrder& sort_order, const std::string& location, + const Schema& schema, const PartitionSpec& spec, const SortOrder& sort_order, + const std::string& location, const std::unordered_map& properties, int format_version = kDefaultTableFormatVersion); diff --git a/src/iceberg/table_update.cc b/src/iceberg/table_update.cc index 01612d765..e325df453 100644 --- a/src/iceberg/table_update.cc +++ b/src/iceberg/table_update.cc @@ -40,7 +40,8 @@ void AssignUUID::ApplyTo(TableMetadataBuilder& builder) const { builder.AssignUUID(uuid_); } -void AssignUUID::GenerateRequirements(TableUpdateContext& context) const { +void AssignUUID::GenerateRequirements( + [[maybe_unused]] TableUpdateContext& context) const { // AssignUUID does not generate additional requirements. } @@ -62,7 +63,8 @@ void UpgradeFormatVersion::ApplyTo(TableMetadataBuilder& builder) const { builder.UpgradeFormatVersion(format_version_); } -void UpgradeFormatVersion::GenerateRequirements(TableUpdateContext& context) const { +void UpgradeFormatVersion::GenerateRequirements( + [[maybe_unused]] TableUpdateContext& context) const { // UpgradeFormatVersion doesn't generate any requirements } @@ -230,7 +232,8 @@ void AddSortOrder::ApplyTo(TableMetadataBuilder& builder) const { builder.AddSortOrder(sort_order_); } -void AddSortOrder::GenerateRequirements(TableUpdateContext& context) const { +void AddSortOrder::GenerateRequirements( + [[maybe_unused]] TableUpdateContext& context) const { // AddSortOrder doesn't generate any requirements } @@ -280,7 +283,8 @@ void AddSnapshot::ApplyTo(TableMetadataBuilder& builder) const { builder.AddSnapshot(snapshot_); } -void AddSnapshot::GenerateRequirements(TableUpdateContext& context) const { +void AddSnapshot::GenerateRequirements( + [[maybe_unused]] TableUpdateContext& context) const { // AddSnapshot doesn't generate any requirements } @@ -308,7 +312,8 @@ void RemoveSnapshots::ApplyTo(TableMetadataBuilder& builder) const { builder.RemoveSnapshots(snapshot_ids_); } -void RemoveSnapshots::GenerateRequirements(TableUpdateContext& context) const { +void RemoveSnapshots::GenerateRequirements( + [[maybe_unused]] TableUpdateContext& context) const { // RemoveSnapshots doesn't generate any requirements } @@ -330,7 +335,8 @@ void RemoveSnapshotRef::ApplyTo(TableMetadataBuilder& builder) const { builder.RemoveRef(ref_name_); } -void RemoveSnapshotRef::GenerateRequirements(TableUpdateContext& context) const { +void RemoveSnapshotRef::GenerateRequirements( + [[maybe_unused]] TableUpdateContext& context) const { // RemoveSnapshotRef doesn't generate any requirements } @@ -397,7 +403,8 @@ void SetProperties::ApplyTo(TableMetadataBuilder& builder) const { builder.SetProperties(updated_); } -void SetProperties::GenerateRequirements(TableUpdateContext& context) const { +void SetProperties::GenerateRequirements( + [[maybe_unused]] TableUpdateContext& context) const { // SetProperties doesn't generate any requirements } @@ -419,7 +426,8 @@ void RemoveProperties::ApplyTo(TableMetadataBuilder& builder) const { builder.RemoveProperties(removed_); } -void RemoveProperties::GenerateRequirements(TableUpdateContext& context) const { +void RemoveProperties::GenerateRequirements( + [[maybe_unused]] TableUpdateContext& context) const { // RemoveProperties doesn't generate any requirements } @@ -441,7 +449,8 @@ void SetLocation::ApplyTo(TableMetadataBuilder& builder) const { builder.SetLocation(location_); } -void SetLocation::GenerateRequirements(TableUpdateContext& context) const { +void SetLocation::GenerateRequirements( + [[maybe_unused]] TableUpdateContext& context) const { // SetLocation doesn't generate any requirements } @@ -465,7 +474,8 @@ void SetStatistics::ApplyTo(TableMetadataBuilder& builder) const { builder.SetStatistics(statistics_file_); } -void SetStatistics::GenerateRequirements(TableUpdateContext& context) const { +void SetStatistics::GenerateRequirements( + [[maybe_unused]] TableUpdateContext& context) const { // SetStatistics doesn't generate any requirements } @@ -493,7 +503,8 @@ void RemoveStatistics::ApplyTo(TableMetadataBuilder& builder) const { builder.RemoveStatistics(snapshot_id_); } -void RemoveStatistics::GenerateRequirements(TableUpdateContext& context) const { +void RemoveStatistics::GenerateRequirements( + [[maybe_unused]] TableUpdateContext& context) const { // RemoveStatistics doesn't generate any requirements } @@ -519,7 +530,8 @@ void SetPartitionStatistics::ApplyTo(TableMetadataBuilder& builder) const { builder.SetPartitionStatistics(partition_statistics_file_); } -void SetPartitionStatistics::GenerateRequirements(TableUpdateContext& context) const { +void SetPartitionStatistics::GenerateRequirements( + [[maybe_unused]] TableUpdateContext& context) const { // SetPartitionStatistics doesn't generate any requirements } @@ -548,7 +560,8 @@ void RemovePartitionStatistics::ApplyTo(TableMetadataBuilder& builder) const { builder.RemovePartitionStatistics(snapshot_id_); } -void RemovePartitionStatistics::GenerateRequirements(TableUpdateContext& context) const { +void RemovePartitionStatistics::GenerateRequirements( + [[maybe_unused]] TableUpdateContext& context) const { // RemovePartitionStatistics doesn't generate any requirements } diff --git a/src/iceberg/test/assign_id_visitor_test.cc b/src/iceberg/test/assign_id_visitor_test.cc index 8bec0ad53..af3e46d33 100644 --- a/src/iceberg/test/assign_id_visitor_test.cc +++ b/src/iceberg/test/assign_id_visitor_test.cc @@ -116,7 +116,7 @@ TEST(AssignFreshIdVisitorTest, NestedSchema) { AssignFreshIds(Schema::kInitialSchemaId, *schema, next_id)); ASSERT_EQ(4, fresh_schema->fields().size()); - for (int32_t i = 0; i < fresh_schema->fields().size(); ++i) { + for (size_t i = 0; i < fresh_schema->fields().size(); ++i) { EXPECT_EQ(i + 1, fresh_schema->fields()[i].field_id()); } diff --git a/src/iceberg/test/schema_test.cc b/src/iceberg/test/schema_test.cc index 9dab35fa7..e8b5246bf 100644 --- a/src/iceberg/test/schema_test.cc +++ b/src/iceberg/test/schema_test.cc @@ -710,7 +710,7 @@ struct SelectTestParam { std::vector select_fields; std::function()> expected_schema; bool should_succeed; - std::string expected_error_message; + std::string expected_error_message = ""; bool case_sensitive = true; }; @@ -851,7 +851,7 @@ struct ProjectTestParam { std::unordered_set selected_ids; std::function()> expected_schema; bool should_succeed; - std::string expected_error_message; + std::string expected_error_message = ""; }; class ProjectParamTest : public ::testing::TestWithParam {}; diff --git a/src/iceberg/test/schema_util_test.cc b/src/iceberg/test/schema_util_test.cc index fe6579ab3..59dc75535 100644 --- a/src/iceberg/test/schema_util_test.cc +++ b/src/iceberg/test/schema_util_test.cc @@ -82,22 +82,6 @@ std::shared_ptr CreateNestedStruct() { }); } -std::shared_ptr CreateListOfList() { - return std::make_shared(SchemaField::MakeRequired( - /*field_id=*/401, "element", - std::make_shared(SchemaField::MakeOptional( - /*field_id=*/402, "element", iceberg::float64())))); -} - -std::shared_ptr CreateMapOfList() { - return std::make_shared( - SchemaField::MakeRequired(/*field_id=*/501, "key", iceberg::string()), - SchemaField::MakeRequired( - /*field_id=*/502, "value", - std::make_shared(SchemaField::MakeOptional( - /*field_id=*/503, "element", iceberg::int32())))); -} - } // namespace TEST(SchemaUtilTest, ProjectIdenticalSchemas) { diff --git a/src/iceberg/test/transform_human_string_test.cc b/src/iceberg/test/transform_human_string_test.cc index 28f4a4849..3050d819a 100644 --- a/src/iceberg/test/transform_human_string_test.cc +++ b/src/iceberg/test/transform_human_string_test.cc @@ -29,9 +29,9 @@ namespace iceberg { struct HumanStringTestParam { std::string test_name; - std::shared_ptr source_type; + std::shared_ptr source_type = nullptr; Literal literal; - std::vector expecteds; + std::vector expecteds{}; }; class IdentityHumanStringTest : public ::testing::TestWithParam { @@ -41,7 +41,7 @@ class IdentityHumanStringTest : public ::testing::TestWithParamToHumanString(param.literal), HasValue(::testing::Eq(param.expecteds[i]))); } diff --git a/src/iceberg/test/transform_test.cc b/src/iceberg/test/transform_test.cc index 47a1e87e6..d6e00e741 100644 --- a/src/iceberg/test/transform_test.cc +++ b/src/iceberg/test/transform_test.cc @@ -197,10 +197,10 @@ TEST(TransformResultTypeTest, NegativeCases) { // Parameterized tests for transform functions struct TransformParam { - std::string str; + std::string str = ""; // The integer parameter associated with the transform. - int32_t param; - std::shared_ptr source_type; + int32_t param = 0; + std::shared_ptr source_type = nullptr; Literal source; Literal expected; }; diff --git a/src/iceberg/update/expire_snapshots.cc b/src/iceberg/update/expire_snapshots.cc index 68cf08caf..87d62b75d 100644 --- a/src/iceberg/update/expire_snapshots.cc +++ b/src/iceberg/update/expire_snapshots.cc @@ -111,7 +111,7 @@ Result> ExpireSnapshots::ComputeBranchSnapshotsToRet for (const auto& ancestor : snapshots) { ICEBERG_DCHECK(ancestor != nullptr, "Ancestor snapshot is null"); - if (ids_to_retain.size() < min_snapshots_to_keep || + if (std::cmp_less(ids_to_retain.size(), min_snapshots_to_keep) || ancestor->timestamp_ms >= expire_snapshot_older_than) { ids_to_retain.insert(ancestor->snapshot_id); } else { diff --git a/src/iceberg/update/fast_append.cc b/src/iceberg/update/fast_append.cc index 3c132a407..6fac89e9a 100644 --- a/src/iceberg/update/fast_append.cc +++ b/src/iceberg/update/fast_append.cc @@ -90,7 +90,8 @@ FastAppend& FastAppend::AppendManifest(const ManifestFile& manifest) { std::string FastAppend::operation() { return DataOperation::kAppend; } Result> FastAppend::Apply( - const TableMetadata& metadata_to_update, const std::shared_ptr& snapshot) { + [[maybe_unused]] const TableMetadata& metadata_to_update, + const std::shared_ptr& snapshot) { std::vector manifests; ICEBERG_ASSIGN_OR_RAISE(auto new_written_manifests, WriteNewManifests()); diff --git a/src/iceberg/update/snapshot_manager.cc b/src/iceberg/update/snapshot_manager.cc index d882dd320..a92eb9192 100644 --- a/src/iceberg/update/snapshot_manager.cc +++ b/src/iceberg/update/snapshot_manager.cc @@ -54,7 +54,7 @@ SnapshotManager::SnapshotManager(std::shared_ptr transaction, SnapshotManager::~SnapshotManager() = default; -SnapshotManager& SnapshotManager::Cherrypick(int64_t snapshot_id) { +SnapshotManager& SnapshotManager::Cherrypick([[maybe_unused]] int64_t snapshot_id) { ICEBERG_BUILDER_RETURN_IF_ERROR(CommitIfRefUpdatesExist()); // TODO(anyone): Implement cherrypick operation ICEBERG_BUILDER_CHECK(false, "Cherrypick operation not yet implemented"); diff --git a/src/iceberg/update/snapshot_update.h b/src/iceberg/update/snapshot_update.h index fdbb2660d..35d678712 100644 --- a/src/iceberg/update/snapshot_update.h +++ b/src/iceberg/update/snapshot_update.h @@ -173,8 +173,8 @@ class ICEBERG_EXPORT SnapshotUpdate : public PendingUpdate { /// /// \param current_metadata Current table metadata to validate /// \param snapshot Ending snapshot on the lineage which is being validated - virtual Status Validate(const TableMetadata& current_metadata, - const std::shared_ptr& snapshot) { + virtual Status Validate([[maybe_unused]] const TableMetadata& current_metadata, + [[maybe_unused]] const std::shared_ptr& snapshot) { return {}; }; diff --git a/src/iceberg/update/update_schema.cc b/src/iceberg/update/update_schema.cc index a4c453491..1b080fb72 100644 --- a/src/iceberg/update/update_schema.cc +++ b/src/iceberg/update/update_schema.cc @@ -118,7 +118,7 @@ class ApplyChangesVisitor { /// \brief Apply changes to a list type Result> VisitList(const ListType& list_type, const std::shared_ptr& base_type, - int32_t parent_id) { + [[maybe_unused]] int32_t parent_id) { const auto& element = list_type.element(); ICEBERG_ASSIGN_OR_RAISE(auto element_type_result, @@ -142,7 +142,7 @@ class ApplyChangesVisitor { /// \brief Apply changes to a map type Result> VisitMap(const MapType& map_type, const std::shared_ptr& base_type, - int32_t parent_id) { + [[maybe_unused]] int32_t parent_id) { const auto& key = map_type.key(); const auto& value = map_type.value(); @@ -172,9 +172,9 @@ class ApplyChangesVisitor { return std::make_shared(key, new_value); } - Result> VisitPrimitive(const PrimitiveType& primitive_type, - const std::shared_ptr& base_type, - int32_t parent_id) { + Result> VisitPrimitive( + [[maybe_unused]] const PrimitiveType& primitive_type, + const std::shared_ptr& base_type, [[maybe_unused]] int32_t parent_id) { return base_type; } @@ -532,7 +532,8 @@ UpdateSchema& UpdateSchema::MoveAfter(std::string_view name, return MoveInternal(name, Move::After(field_id, after_id)); } -UpdateSchema& UpdateSchema::UnionByNameWith(std::shared_ptr new_schema) { +UpdateSchema& UpdateSchema::UnionByNameWith( + [[maybe_unused]] std::shared_ptr new_schema) { // TODO(Guotao Yu): Implement UnionByNameWith AddError(NotImplemented("UpdateSchema::UnionByNameWith not implemented")); return *this; diff --git a/src/iceberg/util/bucket_util.cc b/src/iceberg/util/bucket_util.cc index 88b240de7..e18aa1675 100644 --- a/src/iceberg/util/bucket_util.cc +++ b/src/iceberg/util/bucket_util.cc @@ -29,7 +29,7 @@ namespace iceberg { namespace { template -int32_t HashLiteral(const Literal& literal) { +int32_t HashLiteral([[maybe_unused]] const Literal& literal) { std::unreachable(); } diff --git a/src/iceberg/util/conversions.cc b/src/iceberg/util/conversions.cc index 0cc7c55d8..dcfdd4206 100644 --- a/src/iceberg/util/conversions.cc +++ b/src/iceberg/util/conversions.cc @@ -22,6 +22,7 @@ #include #include #include +#include #include "iceberg/util/decimal.h" #include "iceberg/util/endian.h" @@ -200,7 +201,7 @@ Result Conversions::FromBytes(const PrimitiveType& type, return Literal::Value{std::vector(data.begin(), data.end())}; case TypeId::kFixed: { const auto& fixed_type = static_cast(type); - if (data.size() != fixed_type.length()) { + if (std::cmp_not_equal(data.size(), fixed_type.length())) { return InvalidArgument("Invalid data size for Fixed literal, got size: {}", data.size()); } diff --git a/src/iceberg/util/projection_util_internal.h b/src/iceberg/util/projection_util_internal.h index df4fe9789..a4010f22a 100644 --- a/src/iceberg/util/projection_util_internal.h +++ b/src/iceberg/util/projection_util_internal.h @@ -289,9 +289,8 @@ class ProjectionUtil { ICEBERG_DCHECK(std::holds_alternative(literal.value()), "Expected int32_t"); if (auto value = std::get(literal.value()); value < 0) { - return UnboundPredicateImpl::Make(Expression::Operation::kLt, - std::move(projected->term()), - Literal::Int(value + 1)); + return UnboundPredicateImpl::Make( + Expression::Operation::kLt, projected->term(), Literal::Int(value + 1)); } return projected; @@ -304,9 +303,8 @@ class ProjectionUtil { "Expected int32_t"); if (auto value = std::get(literal.value()); value < 0) { - return UnboundPredicateImpl::Make(Expression::Operation::kLtEq, - std::move(projected->term()), - Literal::Int(value + 1)); + return UnboundPredicateImpl::Make( + Expression::Operation::kLtEq, projected->term(), Literal::Int(value + 1)); } return projected; } @@ -325,7 +323,7 @@ class ProjectionUtil { // match either the incorrect value (projectedValue + 1) or the correct value // (projectedValue) return UnboundPredicateImpl::Make( - Expression::Operation::kIn, std::move(projected->term()), + Expression::Operation::kIn, projected->term(), {literal, Literal::Int(value + 1)}); } return projected; @@ -355,9 +353,8 @@ class ProjectionUtil { std::views::transform(value_set, [](int32_t value) { return Literal::Int(value); }) | std::ranges::to(); - return UnboundPredicateImpl::Make(Expression::Operation::kIn, - std::move(projected->term()), - std::move(values)); + return UnboundPredicateImpl::Make( + Expression::Operation::kIn, projected->term(), std::move(values)); } return projected; } @@ -397,9 +394,8 @@ class ProjectionUtil { ICEBERG_DCHECK(std::holds_alternative(literal.value()), "Expected int32_t"); if (auto value = std::get(literal.value()); value <= 0) { - return UnboundPredicateImpl::Make(Expression::Operation::kGt, - std::move(projected->term()), - Literal::Int(value + 1)); + return UnboundPredicateImpl::Make( + Expression::Operation::kGt, projected->term(), Literal::Int(value + 1)); } return projected; } @@ -410,9 +406,8 @@ class ProjectionUtil { ICEBERG_DCHECK(std::holds_alternative(literal.value()), "Expected int32_t"); if (auto value = std::get(literal.value()); value <= 0) { - return UnboundPredicateImpl::Make(Expression::Operation::kGtEq, - std::move(projected->term()), - Literal::Int(value + 1)); + return UnboundPredicateImpl::Make( + Expression::Operation::kGtEq, projected->term(), Literal::Int(value + 1)); } return projected; } @@ -429,7 +424,7 @@ class ProjectionUtil { "Expected int32_t"); if (auto value = std::get(literal.value()); value < 0) { return UnboundPredicateImpl::Make( - Expression::Operation::kNotIn, std::move(projected->term()), + Expression::Operation::kNotIn, projected->term(), {literal, Literal::Int(value + 1)}); } return projected; @@ -459,9 +454,8 @@ class ProjectionUtil { std::views::transform(value_set, [](int32_t value) { return Literal::Int(value); }) | std::ranges::to(); - return UnboundPredicateImpl::Make(Expression::Operation::kNotIn, - std::move(projected->term()), - std::move(values)); + return UnboundPredicateImpl::Make( + Expression::Operation::kNotIn, projected->term(), std::move(values)); } return projected; } diff --git a/src/iceberg/util/temporal_util.cc b/src/iceberg/util/temporal_util.cc index 05aafb961..828b9270b 100644 --- a/src/iceberg/util/temporal_util.cc +++ b/src/iceberg/util/temporal_util.cc @@ -60,7 +60,7 @@ inline constexpr int32_t MonthsSinceEpoch(const year_month_day& ymd) { } template -Result ExtractYearImpl(const Literal& literal) { +Result ExtractYearImpl([[maybe_unused]] const Literal& literal) { std::unreachable(); } @@ -84,7 +84,7 @@ Result ExtractYearImpl(const Literal& literal) { } template -Result ExtractMonthImpl(const Literal& literal) { +Result ExtractMonthImpl([[maybe_unused]] const Literal& literal) { std::unreachable(); } @@ -108,7 +108,7 @@ Result ExtractMonthImpl(const Literal& literal) { } template -Result ExtractDayImpl(const Literal& literal) { +Result ExtractDayImpl([[maybe_unused]] const Literal& literal) { std::unreachable(); } @@ -129,7 +129,7 @@ Result ExtractDayImpl(const Literal& literal) { } template -Result ExtractHourImpl(const Literal& literal) { +Result ExtractHourImpl([[maybe_unused]] const Literal& literal) { std::unreachable(); } diff --git a/src/iceberg/util/truncate_util.cc b/src/iceberg/util/truncate_util.cc index 9d0c6e7ea..882e66ffa 100644 --- a/src/iceberg/util/truncate_util.cc +++ b/src/iceberg/util/truncate_util.cc @@ -30,7 +30,8 @@ namespace iceberg { namespace { template -Literal TruncateLiteralImpl(const Literal& literal, int32_t width) { +Literal TruncateLiteralImpl([[maybe_unused]] const Literal& literal, + [[maybe_unused]] int32_t width) { std::unreachable(); } @@ -66,7 +67,7 @@ Literal TruncateLiteralImpl(const Literal& literal, int32_t wid // In contrast to strings, binary values do not have an assumed encoding and are // truncated to `width` bytes. const auto& data = std::get>(literal.value()); - if (data.size() <= width) { + if (std::cmp_less_equal(data.size(), width)) { return literal; } return Literal::Binary(std::vector(data.begin(), data.begin() + width)); diff --git a/src/iceberg/util/type_util.cc b/src/iceberg/util/type_util.cc index c6b9bb3ed..550b2eb76 100644 --- a/src/iceberg/util/type_util.cc +++ b/src/iceberg/util/type_util.cc @@ -35,7 +35,7 @@ IdToFieldVisitor::IdToFieldVisitor( std::unordered_map>& id_to_field) : id_to_field_(id_to_field) {} -Status IdToFieldVisitor::Visit(const PrimitiveType& type) { return {}; } +Status IdToFieldVisitor::Visit([[maybe_unused]] const PrimitiveType& type) { return {}; } Status IdToFieldVisitor::Visit(const NestedType& type) { const auto& nested = internal::checked_cast(type); @@ -123,8 +123,9 @@ Status NameToIdVisitor::Visit(const StructType& type, const std::string& path, return {}; } -Status NameToIdVisitor::Visit(const PrimitiveType& type, const std::string& path, - const std::string& short_path) { +Status NameToIdVisitor::Visit([[maybe_unused]] const PrimitiveType& type, + [[maybe_unused]] const std::string& path, + [[maybe_unused]] const std::string& short_path) { return {}; } @@ -180,9 +181,9 @@ Status PositionPathVisitor::Visit(const StructType& type) { } // Non-struct types are not supported yet, but it is not an error. -Status PositionPathVisitor::Visit(const ListType& type) { return {}; } +Status PositionPathVisitor::Visit([[maybe_unused]] const ListType& type) { return {}; } -Status PositionPathVisitor::Visit(const MapType& type) { return {}; } +Status PositionPathVisitor::Visit([[maybe_unused]] const MapType& type) { return {}; } std::unordered_map> PositionPathVisitor::Finish() { return std::move(position_path_); @@ -297,7 +298,10 @@ Status GetProjectedIdsVisitor::VisitNested(const NestedType& type) { return {}; } -Status GetProjectedIdsVisitor::VisitPrimitive(const PrimitiveType& type) { return {}; } +Status GetProjectedIdsVisitor::VisitPrimitive( + [[maybe_unused]] const PrimitiveType& type) { + return {}; +} std::unordered_set GetProjectedIdsVisitor::Finish() const { return ids_; }