Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cmake_modules/IcebergBuildUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$<$<COMPILE_LANG_AND_ID:CXX,GNU,Clang,AppleClang>:-Wall>"
)
endif()

install(TARGETS ${LIB_NAME}_shared
Expand Down Expand Up @@ -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 "$<$<COMPILE_LANG_AND_ID:CXX,GNU,Clang,AppleClang>:-Wall>"
)
endif()

install(TARGETS ${LIB_NAME}_static
Expand Down
3 changes: 2 additions & 1 deletion src/iceberg/avro/avro_data_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <algorithm>
#include <bit>
#include <span>
#include <utility>

#include <arrow/array/builder_binary.h>
#include <arrow/array/builder_decimal.h>
Expand Down Expand Up @@ -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<const FixedType&>(projected_type);

if (static_cast<size_t>(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));
}
Expand Down
6 changes: 4 additions & 2 deletions src/iceberg/avro/avro_schema_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <format>
#include <sstream>
#include <string_view>
#include <utility>

#include <arrow/type.h>
#include <avro/CustomAttributes.hh>
Expand Down Expand Up @@ -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<const FixedType&>(expected_type).length()) {
std::cmp_equal(
avro_node->fixedSize(),
internal::checked_cast<const FixedType&>(expected_type).length())) {
return {};
}
break;
Expand Down
8 changes: 2 additions & 6 deletions src/iceberg/avro/avro_stream_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ namespace iceberg::avro {

AvroInputStream::AvroInputStream(
std::shared_ptr<arrow::io::RandomAccessFile> 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;

Expand Down Expand Up @@ -99,9 +97,7 @@ void AvroInputStream::seek(int64_t position) {

AvroOutputStream::AvroOutputStream(std::shared_ptr<arrow::io::OutputStream> 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;

Expand Down
2 changes: 0 additions & 2 deletions src/iceberg/avro/avro_stream_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8_t> buffer_;
size_t byte_count_ = 0; // bytes read from the input stream
size_t buffer_pos_ = 0; // next position to read in the buffer
Expand Down Expand Up @@ -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<uint8_t> buffer_;
size_t buffer_pos_ = 0; // position in the buffer
uint64_t flushed_bytes_ = 0; // bytes flushed to the output stream
Expand Down
2 changes: 0 additions & 2 deletions src/iceberg/catalog/rest/json_serde.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<nlohmann::json> StorageCredentialToJson(const StorageCredential& credential) {
ICEBERG_RETURN_UNEXPECTED(credential.Validate());
Expand Down
3 changes: 2 additions & 1 deletion src/iceberg/data/position_delete_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
Expand Down
8 changes: 0 additions & 8 deletions src/iceberg/deletes/roaring_position_bitmap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<roaring::Roaring>& bitmaps, uint8_t* buf) {
WriteLittleEndian(static_cast<int64_t>(bitmaps.size()), buf);
buf += kBitmapCountSizeBytes;
Expand Down
4 changes: 2 additions & 2 deletions src/iceberg/expression/manifest_evaluator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,8 @@ class ManifestEvalVisitor : public BoundVisitor<bool> {
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<PrimitiveType>(type)));
return Literal::Deserialize(bound,
internal::checked_pointer_cast<PrimitiveType>(type));
}

private:
Expand Down
2 changes: 1 addition & 1 deletion src/iceberg/expression/residual_evaluator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down
3 changes: 2 additions & 1 deletion src/iceberg/manifest/manifest_adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ ManifestEntryAdapter::~ManifestEntryAdapter() {
Status ManifestEntryAdapter::AppendPartitionValues(
ArrowArray* array, const std::shared_ptr<StructType>& 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]] {
Expand Down
4 changes: 2 additions & 2 deletions src/iceberg/metrics_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ Result<std::unordered_set<int32_t>> 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<size_t>(limit)) {}

Status Visit(const Type& type) {
if (type.is_nested()) {
Expand Down Expand Up @@ -231,7 +231,7 @@ Result<std::unordered_set<int32_t>> MetricsConfig::LimitFieldIds(const Schema& s

private:
std::unordered_set<int32_t> ids_;
int32_t limit_;
size_t limit_;
};

Visitor visitor(limit);
Expand Down
3 changes: 2 additions & 1 deletion src/iceberg/parquet/parquet_data_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

#include <algorithm>
#include <utility>

#include <arrow/array.h>
#include <arrow/array/builder_primitive.h>
Expand Down Expand Up @@ -203,7 +204,7 @@ Result<std::shared_ptr<::arrow::Array>> 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());
Expand Down
3 changes: 2 additions & 1 deletion src/iceberg/parquet/parquet_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <string_view>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>

#include <arrow/array.h>
Expand Down Expand Up @@ -163,7 +164,7 @@ class FieldMetricsCollector {
"Expected Arrow struct array for Iceberg struct metrics collection");
const auto& struct_array = static_cast<const ::arrow::StructArray&>(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) {
Expand Down
5 changes: 3 additions & 2 deletions src/iceberg/partition_spec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Result<std::string> 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 << "/";
Expand Down Expand Up @@ -289,7 +289,8 @@ Result<std::unique_ptr<PartitionSpec>> 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;
}
}
Expand Down
1 change: 0 additions & 1 deletion src/iceberg/schema_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/iceberg/sort_order.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Result<std::unique_ptr<SortOrder>> SortOrder::Make(int32_t sort_id,

std::unordered_set<std::string_view> 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) {
Expand Down
7 changes: 4 additions & 3 deletions src/iceberg/table_metadata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,8 @@ Result<std::unique_ptr<TableMetadata>> 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);
}
Expand Down Expand Up @@ -1674,7 +1675,7 @@ TableMetadataBuilder& TableMetadataBuilder::SetDefaultPartitionSpec(int32_t spec

TableMetadataBuilder& TableMetadataBuilder::AddPartitionSpec(
std::shared_ptr<PartitionSpec> spec) {
ICEBERG_BUILDER_ASSIGN_OR_RETURN(auto spec_id, impl_->AddPartitionSpec(*spec));
ICEBERG_BUILDER_RETURN_IF_ERROR(impl_->AddPartitionSpec(*spec));
return *this;
}

Expand Down Expand Up @@ -1703,7 +1704,7 @@ TableMetadataBuilder& TableMetadataBuilder::SetDefaultSortOrder(int32_t order_id

TableMetadataBuilder& TableMetadataBuilder::AddSortOrder(
std::shared_ptr<SortOrder> order) {
ICEBERG_BUILDER_ASSIGN_OR_RETURN(auto order_id, impl_->AddSortOrder(*order));
ICEBERG_BUILDER_RETURN_IF_ERROR(impl_->AddSortOrder(*order));
return *this;
}

Expand Down
6 changes: 3 additions & 3 deletions src/iceberg/table_scan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ int64_t FileScanTask::estimated_row_count() const {

FileScanTaskGroup::FileScanTaskGroup(std::vector<std::shared_ptr<FileScanTask>> 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 {
Expand Down
1 change: 0 additions & 1 deletion src/iceberg/transform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions src/iceberg/update/cherry_pick_operation.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class ICEBERG_EXPORT CherryPickOperation : public MergingSnapshotUpdate {
CherryPickOperation& Cherrypick(int64_t snapshot_id);

protected:
using MergingSnapshotUpdate::Apply;
Result<ApplyResult> Apply() override;

std::string operation() override;
Expand Down
2 changes: 1 addition & 1 deletion src/iceberg/update/expire_snapshots.cc
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ Result<std::unordered_set<int64_t>> 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<size_t>(min_snapshots_to_keep) ||
ancestor->timestamp_ms >= expire_snapshot_older_than) {
ids_to_retain.insert(ancestor->snapshot_id);
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/iceberg/util/conversions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <cstring>
#include <span>
#include <string>
#include <utility>

#include "iceberg/util/decimal.h"
#include "iceberg/util/endian.h"
Expand Down Expand Up @@ -204,7 +205,7 @@ Result<Literal::Value> Conversions::FromBytes(const PrimitiveType& type,
return Literal::Value{std::vector<uint8_t>(data.begin(), data.end())};
case TypeId::kFixed: {
const auto& fixed_type = static_cast<const FixedType&>(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());
}
Expand Down
3 changes: 2 additions & 1 deletion src/iceberg/util/mumbling_bitmap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/iceberg/util/struct_like_set.cc
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ Status ValidateScalarAgainstType(const Scalar& scalar, const Type& type) {
"Expected fixed but got {}", ScalarTypeName(scalar));
const auto& fixed = static_cast<const FixedType&>(type);
auto value = std::get<std::string_view>(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 {};
Expand Down
2 changes: 1 addition & 1 deletion src/iceberg/util/truncate_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ Literal TruncateLiteralImpl<TypeId::kBinary>(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<std::vector<uint8_t>>(literal.value());
if (data.size() <= width) {
if (std::cmp_less_equal(data.size(), width)) {
return literal;
}
return Literal::Binary(std::vector<uint8_t>(data.begin(), data.begin() + width));
Expand Down
Loading