Skip to content

Commit aec5acf

Browse files
smaheshwar-pltrSreesh Maheshwar
andauthored
refactor: default equality operators for statistic file structs (apache#202)
Elsewhere in the project, equality operators are defaulted e.g. https://github.com/apache/iceberg-cpp/blob/9f13bac62617e5b457be894e9f17eb89c78a0adb/src/iceberg/manifest_list.h#L196 I think for consistency, the `src/iceberg/statistics_file.h` equality operators can be defaulted too, as they do memberwise comparisons using each type's `operator==`. (I'm new to this project, so please take with a pinch of salt 😄) Co-authored-by: Sreesh Maheshwar <[email protected]>
1 parent 9f13bac commit aec5acf

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

src/iceberg/statistics_file.h

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ struct ICEBERG_EXPORT BlobMetadata {
4545
std::unordered_map<std::string, std::string> properties;
4646

4747
/// \brief Compare two BlobMetadatas for equality.
48-
friend bool operator==(const BlobMetadata& lhs, const BlobMetadata& rhs) {
49-
return lhs.type == rhs.type && lhs.source_snapshot_id == rhs.source_snapshot_id &&
50-
lhs.source_snapshot_sequence_number == rhs.source_snapshot_sequence_number &&
51-
lhs.fields == rhs.fields && lhs.properties == rhs.properties;
52-
}
48+
friend bool operator==(const BlobMetadata& lhs, const BlobMetadata& rhs) = default;
5349
};
5450

5551
/// \brief Represents a statistics file in the Puffin format
@@ -66,12 +62,7 @@ struct ICEBERG_EXPORT StatisticsFile {
6662
std::vector<BlobMetadata> blob_metadata;
6763

6864
/// \brief Compare two StatisticsFiles for equality.
69-
friend bool operator==(const StatisticsFile& lhs, const StatisticsFile& rhs) {
70-
return lhs.snapshot_id == rhs.snapshot_id && lhs.path == rhs.path &&
71-
lhs.file_size_in_bytes == rhs.file_size_in_bytes &&
72-
lhs.file_footer_size_in_bytes == rhs.file_footer_size_in_bytes &&
73-
lhs.blob_metadata == rhs.blob_metadata;
74-
}
65+
friend bool operator==(const StatisticsFile& lhs, const StatisticsFile& rhs) = default;
7566
};
7667

7768
/// \brief Represents a partition statistics file
@@ -86,10 +77,7 @@ struct ICEBERG_EXPORT PartitionStatisticsFile {
8677

8778
/// \brief Compare two PartitionStatisticsFiles for equality.
8879
friend bool operator==(const PartitionStatisticsFile& lhs,
89-
const PartitionStatisticsFile& rhs) {
90-
return lhs.snapshot_id == rhs.snapshot_id && lhs.path == rhs.path &&
91-
lhs.file_size_in_bytes == rhs.file_size_in_bytes;
92-
}
80+
const PartitionStatisticsFile& rhs) = default;
9381
};
9482

9583
/// \brief Returns a string representation of a BlobMetadata

0 commit comments

Comments
 (0)