Skip to content

refactor: remove explicit operator!= using C++20 rewrite candidates #123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 19, 2025
Merged
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
4 changes: 0 additions & 4 deletions src/iceberg/partition_field.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ class ICEBERG_EXPORT PartitionField : public util::Formattable {
return lhs.Equals(rhs);
}

friend bool operator!=(const PartitionField& lhs, const PartitionField& rhs) {
return !(lhs == rhs);
}

private:
/// \brief Compare two fields for equality.
[[nodiscard]] bool Equals(const PartitionField& other) const;
Expand Down
4 changes: 0 additions & 4 deletions src/iceberg/partition_spec.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ class ICEBERG_EXPORT PartitionSpec : public util::Formattable {
return lhs.Equals(rhs);
}

friend bool operator!=(const PartitionSpec& lhs, const PartitionSpec& rhs) {
return !(lhs == rhs);
}

private:
/// \brief Compare two partition specs for equality.
[[nodiscard]] bool Equals(const PartitionSpec& other) const;
Expand Down
2 changes: 0 additions & 2 deletions src/iceberg/schema.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ class ICEBERG_EXPORT Schema : public StructType {

friend bool operator==(const Schema& lhs, const Schema& rhs) { return lhs.Equals(rhs); }

friend bool operator!=(const Schema& lhs, const Schema& rhs) { return !(lhs == rhs); }

private:
/// \brief Compare two schemas for equality.
[[nodiscard]] bool Equals(const Schema& other) const;
Expand Down
4 changes: 0 additions & 4 deletions src/iceberg/schema_field.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ class ICEBERG_EXPORT SchemaField : public iceberg::util::Formattable {
return lhs.Equals(rhs);
}

friend bool operator!=(const SchemaField& lhs, const SchemaField& rhs) {
return !(lhs == rhs);
}

private:
/// \brief Compare two fields for equality.
[[nodiscard]] bool Equals(const SchemaField& other) const;
Expand Down
16 changes: 0 additions & 16 deletions src/iceberg/snapshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ struct ICEBERG_EXPORT SnapshotRef {
return lhs.Equals(rhs);
}

/// \brief Compare two branches for inequality.
friend bool operator!=(const Branch& lhs, const Branch& rhs) { return !(lhs == rhs); }

private:
/// \brief Compare two branches for equality.
bool Equals(const Branch& other) const;
Expand All @@ -97,9 +94,6 @@ struct ICEBERG_EXPORT SnapshotRef {
/// \brief Compare two tags for equality.
friend bool operator==(const Tag& lhs, const Tag& rhs) { return lhs.Equals(rhs); }

/// \brief Compare two tags for inequality.
friend bool operator!=(const Tag& lhs, const Tag& rhs) { return !(lhs == rhs); }

private:
/// \brief Compare two tags for equality.
bool Equals(const Tag& other) const;
Expand All @@ -117,11 +111,6 @@ struct ICEBERG_EXPORT SnapshotRef {
return lhs.Equals(rhs);
}

/// \brief Compare two snapshot refs for inequality.
friend bool operator!=(const SnapshotRef& lhs, const SnapshotRef& rhs) {
return !(lhs == rhs);
}

private:
/// \brief Compare two snapshot refs for equality.
bool Equals(const SnapshotRef& other) const;
Expand Down Expand Up @@ -263,11 +252,6 @@ struct ICEBERG_EXPORT Snapshot {
return lhs.Equals(rhs);
}

/// \brief Compare two snapshots for inequality.
friend bool operator!=(const Snapshot& lhs, const Snapshot& rhs) {
return !(lhs == rhs);
}

private:
/// \brief Compare two snapshots for equality.
bool Equals(const Snapshot& other) const;
Expand Down
4 changes: 0 additions & 4 deletions src/iceberg/sort_field.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ class ICEBERG_EXPORT SortField : public util::Formattable {
return lhs.Equals(rhs);
}

friend bool operator!=(const SortField& lhs, const SortField& rhs) {
return !(lhs == rhs);
}

private:
/// \brief Compare two fields for equality.
[[nodiscard]] bool Equals(const SortField& other) const;
Expand Down
4 changes: 0 additions & 4 deletions src/iceberg/sort_order.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ class ICEBERG_EXPORT SortOrder : public util::Formattable {
return lhs.Equals(rhs);
}

friend bool operator!=(const SortOrder& lhs, const SortOrder& rhs) {
return !(lhs == rhs);
}

private:
/// \brief Compare two sort orders for equality.
bool Equals(const SortOrder& other) const;
Expand Down
16 changes: 0 additions & 16 deletions src/iceberg/statistics_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ struct ICEBERG_EXPORT BlobMetadata {
lhs.source_snapshot_sequence_number == rhs.source_snapshot_sequence_number &&
lhs.fields == rhs.fields && lhs.properties == rhs.properties;
}

/// \brief Compare two BlobMetadatas for inequality.
friend bool operator!=(const BlobMetadata& lhs, const BlobMetadata& rhs) {
return !(lhs == rhs);
}
};

/// \brief Represents a statistics file in the Puffin format
Expand All @@ -77,11 +72,6 @@ struct ICEBERG_EXPORT StatisticsFile {
lhs.file_footer_size_in_bytes == rhs.file_footer_size_in_bytes &&
lhs.blob_metadata == rhs.blob_metadata;
}

/// \brief Compare two StatisticsFiles for inequality.
friend bool operator!=(const StatisticsFile& lhs, const StatisticsFile& rhs) {
return !(lhs == rhs);
}
};

/// \brief Represents a partition statistics file
Expand All @@ -100,12 +90,6 @@ struct ICEBERG_EXPORT PartitionStatisticsFile {
return lhs.snapshot_id == rhs.snapshot_id && lhs.path == rhs.path &&
lhs.file_size_in_bytes == rhs.file_size_in_bytes;
}

/// \brief Compare two PartitionStatisticsFiles for inequality.
friend bool operator!=(const PartitionStatisticsFile& lhs,
const PartitionStatisticsFile& rhs) {
return !(lhs == rhs);
}
};

/// \brief Returns a string representation of a BlobMetadata
Expand Down
12 changes: 0 additions & 12 deletions src/iceberg/table_metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ struct ICEBERG_EXPORT SnapshotLogEntry {
friend bool operator==(const SnapshotLogEntry& lhs, const SnapshotLogEntry& rhs) {
return lhs.timestamp_ms == rhs.timestamp_ms && lhs.snapshot_id == rhs.snapshot_id;
}

friend bool operator!=(const SnapshotLogEntry& lhs, const SnapshotLogEntry& rhs) {
return !(lhs == rhs);
}
};

/// \brief Represents a metadata log entry
Expand All @@ -60,10 +56,6 @@ struct ICEBERG_EXPORT MetadataLogEntry {
friend bool operator==(const MetadataLogEntry& lhs, const MetadataLogEntry& rhs) {
return lhs.timestamp_ms == rhs.timestamp_ms && lhs.metadata_file == rhs.metadata_file;
}

friend bool operator!=(const MetadataLogEntry& lhs, const MetadataLogEntry& rhs) {
return !(lhs == rhs);
}
};

/// \brief Represents the metadata for an Iceberg table
Expand Down Expand Up @@ -137,10 +129,6 @@ struct ICEBERG_EXPORT TableMetadata {
Result<std::shared_ptr<SortOrder>> SortOrder() const;

friend bool operator==(const TableMetadata& lhs, const TableMetadata& rhs);

friend bool operator!=(const TableMetadata& lhs, const TableMetadata& rhs) {
return !(lhs == rhs);
}
};

/// \brief Returns a string representation of a SnapshotLogEntry
Expand Down
9 changes: 0 additions & 9 deletions src/iceberg/transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,6 @@ class ICEBERG_EXPORT Transform : public util::Formattable {
return lhs.Equals(rhs);
}

/// \brief Inequality comparison.
friend bool operator!=(const Transform& lhs, const Transform& rhs) {
return !(lhs == rhs);
}

private:
/// \brief Constructs a Transform of the specified type (for non-parametric types).
/// \param transform_type The transform type (e.g., identity, year, day).
Expand Down Expand Up @@ -188,10 +183,6 @@ class ICEBERG_EXPORT TransformFunction {
return lhs.Equals(rhs);
}

friend bool operator!=(const TransformFunction& lhs, const TransformFunction& rhs) {
return !(lhs == rhs);
}

private:
/// \brief Compare two partition specs for equality.
[[nodiscard]] virtual bool Equals(const TransformFunction& other) const;
Expand Down
3 changes: 2 additions & 1 deletion src/iceberg/type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ StructType::StructType(std::vector<SchemaField> fields) : fields_(std::move(fiel
}

TypeId StructType::type_id() const { return kTypeId; }

std::string StructType::ToString() const {
std::string repr = "struct<\n";
for (const auto& field : fields_) {
Expand All @@ -59,7 +60,7 @@ std::optional<std::reference_wrapper<const SchemaField>> StructType::GetFieldByI
}
std::optional<std::reference_wrapper<const SchemaField>> StructType::GetFieldByIndex(
int32_t index) const {
if (index < 0 || index >= static_cast<int>(fields_.size())) {
if (index < 0 || index >= static_cast<int32_t>(fields_.size())) {
return std::nullopt;
}
return fields_[index];
Expand Down
3 changes: 0 additions & 3 deletions src/iceberg/type.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ class ICEBERG_EXPORT Type : public iceberg::util::Formattable {
/// \brief Compare two types for equality.
friend bool operator==(const Type& lhs, const Type& rhs) { return lhs.Equals(rhs); }

/// \brief Compare two types for inequality.
friend bool operator!=(const Type& lhs, const Type& rhs) { return !(lhs == rhs); }

protected:
/// \brief Compare two types for equality.
[[nodiscard]] virtual bool Equals(const Type& other) const = 0;
Expand Down
Loading