diff --git a/cmake_modules/IcebergBuildUtils.cmake b/cmake_modules/IcebergBuildUtils.cmake index fa1accd253..4036c30baf 100644 --- a/cmake_modules/IcebergBuildUtils.cmake +++ b/cmake_modules/IcebergBuildUtils.cmake @@ -184,6 +184,10 @@ function(add_iceberg_lib LIB_NAME) if(MSVC_TOOLCHAIN) target_compile_options(${LIB_NAME}_shared PRIVATE /bigobj) + else() + target_compile_options(${LIB_NAME}_shared + PRIVATE "$<$:-Wall>" + ) endif() install(TARGETS ${LIB_NAME}_shared @@ -254,6 +258,10 @@ function(add_iceberg_lib LIB_NAME) if(MSVC_TOOLCHAIN) target_compile_options(${LIB_NAME}_static PRIVATE /bigobj) + else() + target_compile_options(${LIB_NAME}_static + PRIVATE "$<$:-Wall>" + ) endif() install(TARGETS ${LIB_NAME}_static diff --git a/src/iceberg/avro/avro_data_util.cc b/src/iceberg/avro/avro_data_util.cc index 5c6c19decf..967efb6d02 100644 --- a/src/iceberg/avro/avro_data_util.cc +++ b/src/iceberg/avro/avro_data_util.cc @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -358,7 +359,7 @@ Status AppendPrimitiveValueToBuilder(const ::avro::NodePtr& avro_node, const auto& fixed = avro_datum.value<::avro::GenericFixed>(); const auto& fixed_type = internal::checked_cast(projected_type); - if (static_cast(fixed.value().size()) != fixed_type.length()) { + if (std::cmp_not_equal(fixed.value().size(), fixed_type.length())) { return InvalidArgument("Expected Avro fixed[{}], got: {}", fixed_type.length(), ToString(avro_node)); } diff --git a/src/iceberg/avro/avro_schema_util.cc b/src/iceberg/avro/avro_schema_util.cc index 94d0a6116b..5772cd2e84 100644 --- a/src/iceberg/avro/avro_schema_util.cc +++ b/src/iceberg/avro/avro_schema_util.cc @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -636,8 +637,9 @@ Status ValidateAvroSchemaEvolution(const Type& expected_type, break; case TypeId::kFixed: if (avro_node->type() == ::avro::AVRO_FIXED && - avro_node->fixedSize() == - internal::checked_cast(expected_type).length()) { + std::cmp_equal( + avro_node->fixedSize(), + internal::checked_cast(expected_type).length())) { return {}; } break; diff --git a/src/iceberg/avro/avro_stream_internal.cc b/src/iceberg/avro/avro_stream_internal.cc index e868bab4b4..ffc96fed6d 100644 --- a/src/iceberg/avro/avro_stream_internal.cc +++ b/src/iceberg/avro/avro_stream_internal.cc @@ -29,9 +29,7 @@ namespace iceberg::avro { AvroInputStream::AvroInputStream( std::shared_ptr input_stream, int64_t buffer_size) - : input_stream_(std::move(input_stream)), - buffer_size_(buffer_size), - buffer_(buffer_size) {} + : input_stream_(std::move(input_stream)), buffer_(buffer_size) {} AvroInputStream::~AvroInputStream() = default; @@ -99,9 +97,7 @@ void AvroInputStream::seek(int64_t position) { AvroOutputStream::AvroOutputStream(std::shared_ptr output_stream, int64_t buffer_size) - : output_stream_(std::move(output_stream)), - buffer_size_(buffer_size), - buffer_(buffer_size) {} + : output_stream_(std::move(output_stream)), buffer_(buffer_size) {} AvroOutputStream::~AvroOutputStream() = default; diff --git a/src/iceberg/avro/avro_stream_internal.h b/src/iceberg/avro/avro_stream_internal.h index 18653cca6b..9aee7199c8 100644 --- a/src/iceberg/avro/avro_stream_internal.h +++ b/src/iceberg/avro/avro_stream_internal.h @@ -55,7 +55,6 @@ class AvroInputStream : public ::avro::SeekableInputStream { private: std::shared_ptr<::arrow::io::RandomAccessFile> input_stream_; - const int64_t buffer_size_; std::vector buffer_; size_t byte_count_ = 0; // bytes read from the input stream size_t buffer_pos_ = 0; // next position to read in the buffer @@ -91,7 +90,6 @@ class AvroOutputStream : public ::avro::OutputStream { private: std::shared_ptr<::arrow::io::OutputStream> output_stream_; - const int64_t buffer_size_; std::vector buffer_; size_t buffer_pos_ = 0; // position in the buffer uint64_t flushed_bytes_ = 0; // bytes flushed to the output stream diff --git a/src/iceberg/catalog/rest/json_serde.cc b/src/iceberg/catalog/rest/json_serde.cc index 7b862e7293..42ec1a6208 100644 --- a/src/iceberg/catalog/rest/json_serde.cc +++ b/src/iceberg/catalog/rest/json_serde.cc @@ -115,8 +115,6 @@ constexpr std::string_view kDeleteFileReferences = "delete-file-references"; constexpr std::string_view kResidualFilter = "residual-filter"; constexpr std::string_view kStart = "start"; constexpr std::string_view kLength = "length"; -constexpr std::string_view kMapKeys = "keys"; -constexpr std::string_view kMapValues = "values"; Result StorageCredentialToJson(const StorageCredential& credential) { ICEBERG_RETURN_UNEXPECTED(credential.Validate()); diff --git a/src/iceberg/data/position_delete_writer.cc b/src/iceberg/data/position_delete_writer.cc index 6238774eb2..c9f9da3c44 100644 --- a/src/iceberg/data/position_delete_writer.cc +++ b/src/iceberg/data/position_delete_writer.cc @@ -130,7 +130,8 @@ class PositionDeleteWriter::Impl { buffered_positions_.push_back(pos); referenced_paths_.emplace(file_path); - if (buffered_paths_.size() >= options_.flush_threshold) { + if (options_.flush_threshold >= 0 && + std::cmp_greater_equal(buffered_paths_.size(), options_.flush_threshold)) { return FlushBuffer(); } return {}; diff --git a/src/iceberg/deletes/roaring_position_bitmap.cc b/src/iceberg/deletes/roaring_position_bitmap.cc index e043d7640c..49961079c1 100644 --- a/src/iceberg/deletes/roaring_position_bitmap.cc +++ b/src/iceberg/deletes/roaring_position_bitmap.cc @@ -51,14 +51,6 @@ int64_t ToPosition(int32_t key, uint32_t pos32) { return (int64_t{key} << 32) | int64_t{pos32}; } -Status ValidatePosition(int64_t pos) { - if (pos < 0 || pos > RoaringPositionBitmap::kMaxPosition) { - return InvalidArgument("Bitmap supports positions that are >= 0 and <= {}: {}", - RoaringPositionBitmap::kMaxPosition, pos); - } - return {}; -} - void WriteBitmaps(const std::vector& bitmaps, uint8_t* buf) { WriteLittleEndian(static_cast(bitmaps.size()), buf); buf += kBitmapCountSizeBytes; diff --git a/src/iceberg/expression/manifest_evaluator.cc b/src/iceberg/expression/manifest_evaluator.cc index 7720aab1a5..d26cbe56f1 100644 --- a/src/iceberg/expression/manifest_evaluator.cc +++ b/src/iceberg/expression/manifest_evaluator.cc @@ -340,8 +340,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/residual_evaluator.h b/src/iceberg/expression/residual_evaluator.h index 60bf67f25c..c900cea273 100644 --- a/src/iceberg/expression/residual_evaluator.h +++ b/src/iceberg/expression/residual_evaluator.h @@ -65,7 +65,7 @@ class ICEBERG_EXPORT ResidualEvaluator { const Schema& schema, bool case_sensitive = true); - ~ResidualEvaluator(); + virtual ~ResidualEvaluator(); /// \brief Returns a residual expression for the given partition values. /// diff --git a/src/iceberg/manifest/manifest_adapter.cc b/src/iceberg/manifest/manifest_adapter.cc index 766a27ef71..0f42b25a23 100644 --- a/src/iceberg/manifest/manifest_adapter.cc +++ b/src/iceberg/manifest/manifest_adapter.cc @@ -86,7 +86,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/metrics_config.cc b/src/iceberg/metrics_config.cc index f5e30ace9e..7705692d1b 100644 --- a/src/iceberg/metrics_config.cc +++ b/src/iceberg/metrics_config.cc @@ -192,7 +192,7 @@ Result> MetricsConfig::LimitFieldIds(const Schema& s int32_t limit) { class Visitor { public: - explicit Visitor(int32_t limit) : limit_(limit) {} + explicit Visitor(int32_t limit) : limit_(static_cast(limit)) {} Status Visit(const Type& type) { if (type.is_nested()) { @@ -231,7 +231,7 @@ Result> MetricsConfig::LimitFieldIds(const Schema& s private: std::unordered_set ids_; - int32_t limit_; + size_t limit_; }; Visitor visitor(limit); diff --git a/src/iceberg/parquet/parquet_data_util.cc b/src/iceberg/parquet/parquet_data_util.cc index b5024c4867..8eea3b9d43 100644 --- a/src/iceberg/parquet/parquet_data_util.cc +++ b/src/iceberg/parquet/parquet_data_util.cc @@ -18,6 +18,7 @@ */ #include +#include #include #include @@ -203,7 +204,7 @@ Result> ProjectStructArray( "Inconsistent number of fields ({}) and number of projections ({})", struct_type.fields().size(), projections.size()); } - if (struct_type.fields().size() != output_struct_type->num_fields()) { + if (std::cmp_not_equal(struct_type.fields().size(), output_struct_type->num_fields())) { return InvalidSchema( "Inconsistent number of fields ({}) and number of output fields ({})", struct_type.fields().size(), output_struct_type->num_fields()); diff --git a/src/iceberg/parquet/parquet_writer.cc b/src/iceberg/parquet/parquet_writer.cc index 356b7bb0fa..2b5bf458e6 100644 --- a/src/iceberg/parquet/parquet_writer.cc +++ b/src/iceberg/parquet/parquet_writer.cc @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -163,7 +164,7 @@ class FieldMetricsCollector { "Expected Arrow struct array for Iceberg struct metrics collection"); const auto& struct_array = static_cast(array); ICEBERG_PRECHECK( - struct_array.num_fields() == type.fields().size(), + std::cmp_equal(struct_array.num_fields(), type.fields().size()), "Arrow struct field count does not match Iceberg struct field count"); for (int i = 0; i < struct_array.num_fields(); ++i) { diff --git a/src/iceberg/partition_spec.cc b/src/iceberg/partition_spec.cc index 29ff046c14..6c32fb65bf 100644 --- a/src/iceberg/partition_spec.cc +++ b/src/iceberg/partition_spec.cc @@ -123,7 +123,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 << "/"; @@ -289,7 +289,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(), + PartitionSpec::kLegacyPartitionDataIdStart + i)) { return false; } } diff --git a/src/iceberg/schema_internal.cc b/src/iceberg/schema_internal.cc index e5cf891c9d..9718f9a3d7 100644 --- a/src/iceberg/schema_internal.cc +++ b/src/iceberg/schema_internal.cc @@ -36,7 +36,6 @@ namespace { // Constants for Arrow schema metadata constexpr const char* kArrowExtensionName = "ARROW:extension:name"; -constexpr const char* kArrowExtensionMetadata = "ARROW:extension:metadata"; constexpr int32_t kUnknownFieldId = -1; Status CheckArrowCompatible(const Type& type) { diff --git a/src/iceberg/sort_order.cc b/src/iceberg/sort_order.cc index 04de6b8351..2003f7dcd5 100644 --- a/src/iceberg/sort_order.cc +++ b/src/iceberg/sort_order.cc @@ -131,7 +131,7 @@ Result> SortOrder::Make(int32_t sort_id, std::unordered_set SortOrder::OrderPreservingSortedColumns( const Schema& schema, const SortOrder& order) { - return order.fields() | std::views::filter([&schema](const SortField& field) { + return order.fields() | std::views::filter([](const SortField& field) { return field.transform()->PreservesOrder(); }) | std::views::transform([&schema](const SortField& field) { diff --git a/src/iceberg/table_metadata.cc b/src/iceberg/table_metadata.cc index be7e76a553..6961cc2859 100644 --- a/src/iceberg/table_metadata.cc +++ b/src/iceberg/table_metadata.cc @@ -1437,7 +1437,8 @@ 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 (max_metadata_log_size >= 0 && + 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); } @@ -1674,7 +1675,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_RETURN_IF_ERROR(impl_->AddPartitionSpec(*spec)); return *this; } @@ -1703,7 +1704,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_RETURN_IF_ERROR(impl_->AddSortOrder(*order)); return *this; } diff --git a/src/iceberg/table_scan.cc b/src/iceberg/table_scan.cc index a29ee00434..94bea351c5 100644 --- a/src/iceberg/table_scan.cc +++ b/src/iceberg/table_scan.cc @@ -262,9 +262,9 @@ int64_t FileScanTask::estimated_row_count() const { FileScanTaskGroup::FileScanTaskGroup(std::vector> tasks) : tasks_(std::move(tasks)) { - for (const auto& task : tasks_) { - ICEBERG_DCHECK(task != nullptr, "Task in a file scan task group cannot be null"); - } + ICEBERG_DCHECK( + std::ranges::all_of(tasks_, [](const auto& task) { return task != nullptr; }), + "Task in a file scan task group cannot be null"); } int64_t FileScanTaskGroup::size_bytes() const { diff --git a/src/iceberg/transform.cc b/src/iceberg/transform.cc index d243e6c530..5c3b658ba2 100644 --- a/src/iceberg/transform.cc +++ b/src/iceberg/transform.cc @@ -38,7 +38,6 @@ namespace iceberg { namespace { -constexpr std::string_view kUnknownName = "unknown"; constexpr std::string_view kIdentityName = "identity"; constexpr std::string_view kBucketName = "bucket"; constexpr std::string_view kTruncateName = "truncate"; diff --git a/src/iceberg/update/cherry_pick_operation.h b/src/iceberg/update/cherry_pick_operation.h index 5c3211c417..12dee70efe 100644 --- a/src/iceberg/update/cherry_pick_operation.h +++ b/src/iceberg/update/cherry_pick_operation.h @@ -55,6 +55,7 @@ class ICEBERG_EXPORT CherryPickOperation : public MergingSnapshotUpdate { CherryPickOperation& Cherrypick(int64_t snapshot_id); protected: + using MergingSnapshotUpdate::Apply; Result Apply() override; std::string operation() override; diff --git a/src/iceberg/update/expire_snapshots.cc b/src/iceberg/update/expire_snapshots.cc index fd14308e88..541d16e45d 100644 --- a/src/iceberg/update/expire_snapshots.cc +++ b/src/iceberg/update/expire_snapshots.cc @@ -820,7 +820,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 (ids_to_retain.size() < static_cast(min_snapshots_to_keep) || ancestor->timestamp_ms >= expire_snapshot_older_than) { ids_to_retain.insert(ancestor->snapshot_id); } else { diff --git a/src/iceberg/util/conversions.cc b/src/iceberg/util/conversions.cc index 5c5356103a..ef65fdec6b 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" @@ -204,7 +205,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/mumbling_bitmap.cc b/src/iceberg/util/mumbling_bitmap.cc index cbe43e8905..e864bac17e 100644 --- a/src/iceberg/util/mumbling_bitmap.cc +++ b/src/iceberg/util/mumbling_bitmap.cc @@ -61,6 +61,7 @@ bool ContainsByte(const uint8_t* container, uint8_t length, uint8_t value) { return false; } +#if !ICEBERG_MUMBLING_SSE2 // Portable SWAR (SIMD within a register) version of ContainsByte: compares 8 // bytes per 64-bit word. Reads 32 bytes at `container`, so the caller must // make sure they are inside the buffer. @@ -82,7 +83,7 @@ bool ContainsByte32(const uint8_t* container, uint8_t length, uint8_t value) { return found != 0; } -#if ICEBERG_MUMBLING_SSE2 +#else // SSE2 version of ContainsByte32. Reads 32 bytes at `container`, so the caller // must make sure they are inside the buffer. bool ContainsByte32Sse2(const uint8_t* container, uint8_t length, uint8_t value) { diff --git a/src/iceberg/util/struct_like_set.cc b/src/iceberg/util/struct_like_set.cc index 86e67701d0..44f0d139b8 100644 --- a/src/iceberg/util/struct_like_set.cc +++ b/src/iceberg/util/struct_like_set.cc @@ -303,7 +303,7 @@ Status ValidateScalarAgainstType(const Scalar& scalar, const Type& type) { "Expected fixed but got {}", ScalarTypeName(scalar)); const auto& fixed = static_cast(type); auto value = std::get(scalar); - ICEBERG_PRECHECK(value.size() == fixed.length(), + ICEBERG_PRECHECK(std::cmp_equal(value.size(), fixed.length()), "Expected fixed({}) but got byte length {}", fixed.length(), value.size()); return {}; diff --git a/src/iceberg/util/truncate_util.cc b/src/iceberg/util/truncate_util.cc index a7622578df..abbc0d297e 100644 --- a/src/iceberg/util/truncate_util.cc +++ b/src/iceberg/util/truncate_util.cc @@ -176,7 +176,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));