Skip to content

Commit 26ca646

Browse files
author
xiao.dong
committed
add operator== to literal
1 parent f41bd62 commit 26ca646

File tree

6 files changed

+9
-44
lines changed

6 files changed

+9
-44
lines changed

src/iceberg/expression/literal.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ std::strong_ordering CompareFloat(T lhs, T rhs) {
179179
return lhs_is_negative <=> rhs_is_negative;
180180
}
181181

182+
bool Literal::operator==(const iceberg::Literal& other) const {
183+
return (*this <=> other) == 0;
184+
}
185+
182186
// Three-way comparison operator
183187
std::partial_ordering Literal::operator<=>(const Literal& other) const {
184188
// If types are different, comparison is unordered

src/iceberg/expression/literal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ class ICEBERG_EXPORT Literal {
105105
/// was not valid
106106
Result<Literal> CastTo(const std::shared_ptr<PrimitiveType>& target_type) const;
107107

108+
bool operator==(const Literal& other) const;
109+
108110
/// \brief Compare two PrimitiveLiterals. Both literals must have the same type
109111
/// and should not be AboveMax or BelowMin.
110112
std::partial_ordering operator<=>(const Literal& other) const;

src/iceberg/manifest_entry.cc

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,6 @@
2727

2828
namespace iceberg {
2929

30-
bool DataFile::operator==(const iceberg::DataFile& other) const {
31-
return content == other.content && file_path == other.file_path &&
32-
file_format == other.file_format && partition <=> other.partition == 0 &&
33-
record_count == other.record_count &&
34-
file_size_in_bytes == other.file_size_in_bytes &&
35-
column_sizes == other.column_sizes && value_counts == other.value_counts &&
36-
null_value_counts == other.null_value_counts &&
37-
nan_value_counts == other.nan_value_counts &&
38-
lower_bounds == other.lower_bounds && upper_bounds == other.upper_bounds &&
39-
key_metadata == other.key_metadata && split_offsets == other.split_offsets &&
40-
equality_ids == other.equality_ids && sort_order_id == other.sort_order_id &&
41-
partition_spec_id == other.partition_spec_id &&
42-
first_row_id == other.first_row_id &&
43-
referenced_data_file == other.referenced_data_file &&
44-
content_offset == other.content_offset &&
45-
content_size_in_bytes == other.content_size_in_bytes;
46-
}
47-
4830
bool ManifestEntry::operator==(const iceberg::ManifestEntry& other) const {
4931
return status == other.status && snapshot_id == other.snapshot_id &&
5032
sequence_number == other.sequence_number &&

src/iceberg/manifest_entry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ struct ICEBERG_EXPORT DataFile {
261261
SchemaField::MakeOptional(145, "content_size_in_bytes", iceberg::int64(),
262262
"The length of referenced content stored in the file");
263263

264-
bool operator==(const DataFile& other) const;
264+
bool operator==(const DataFile& other) const = default;
265265

266266
static std::shared_ptr<StructType> Type(std::shared_ptr<StructType> partition_type);
267267
};

src/iceberg/manifest_list.cc

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,6 @@
2323

2424
namespace iceberg {
2525

26-
bool PartitionFieldSummary::operator==(
27-
const iceberg::PartitionFieldSummary& other) const {
28-
return contains_null == other.contains_null && contains_nan == other.contains_nan &&
29-
lower_bound == other.lower_bound && upper_bound == other.upper_bound;
30-
}
31-
32-
bool ManifestFile::operator==(const iceberg::ManifestFile& other) const {
33-
return manifest_path == other.manifest_path &&
34-
manifest_length == other.manifest_length &&
35-
partition_spec_id == other.partition_spec_id && content == other.content &&
36-
sequence_number == other.sequence_number &&
37-
min_sequence_number == other.min_sequence_number &&
38-
added_snapshot_id == other.added_snapshot_id &&
39-
added_files_count == other.added_files_count &&
40-
existing_files_count == other.existing_files_count &&
41-
deleted_files_count == other.deleted_files_count &&
42-
added_rows_count == other.added_rows_count &&
43-
existing_rows_count == other.existing_rows_count &&
44-
deleted_rows_count == other.deleted_rows_count &&
45-
partitions == other.partitions && key_metadata == other.key_metadata &&
46-
first_row_id == other.first_row_id;
47-
}
48-
4926
const StructType& PartitionFieldSummary::Type() {
5027
static const StructType kInstance{{
5128
PartitionFieldSummary::kContainsNull,

src/iceberg/manifest_list.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct ICEBERG_EXPORT PartitionFieldSummary {
6464
inline static const SchemaField kUpperBound = SchemaField::MakeOptional(
6565
511, "upper_bound", iceberg::binary(), "Partition upper bound for all files");
6666

67-
bool operator==(const PartitionFieldSummary& other) const;
67+
bool operator==(const PartitionFieldSummary& other) const = default;
6868

6969
static const StructType& Type();
7070
};
@@ -190,7 +190,7 @@ struct ICEBERG_EXPORT ManifestFile {
190190
520, "first_row_id", iceberg::int64(),
191191
"Starting row ID to assign to new rows in ADDED data files");
192192

193-
bool operator==(const ManifestFile& other) const;
193+
bool operator==(const ManifestFile& other) const = default;
194194

195195
static const StructType& Type();
196196
};

0 commit comments

Comments
 (0)