Skip to content

Commit 183d0ec

Browse files
committed
avoid std::reference_wrapper because expected requires default constructor
1 parent 37a8c30 commit 183d0ec

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/iceberg/table_metadata.cc

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ std::string ToString(const MetadataLogEntry& entry) {
3939
entry.metadata_file);
4040
}
4141

42-
Result<std::reference_wrapper<const std::shared_ptr<Schema>>> TableMetadata::Schema()
43-
const {
42+
Result<std::shared_ptr<Schema>> TableMetadata::Schema() const {
4443
auto iter = std::ranges::find_if(schemas, [this](const auto& schema) {
4544
return schema->schema_id() == current_schema_id;
4645
});
@@ -50,11 +49,10 @@ Result<std::reference_wrapper<const std::shared_ptr<Schema>>> TableMetadata::Sch
5049
.message = std::format("Current schema is not found"),
5150
});
5251
}
53-
return std::cref(*iter);
52+
return *iter;
5453
}
5554

56-
Result<std::reference_wrapper<const std::shared_ptr<PartitionSpec>>>
57-
TableMetadata::PartitionSpec() const {
55+
Result<std::shared_ptr<PartitionSpec>> TableMetadata::PartitionSpec() const {
5856
auto iter = std::ranges::find_if(partition_specs, [this](const auto& spec) {
5957
return spec->spec_id() == default_spec_id;
6058
});
@@ -64,11 +62,10 @@ TableMetadata::PartitionSpec() const {
6462
.message = std::format("Default partition spec is not found"),
6563
});
6664
}
67-
return std::cref(*iter);
65+
return *iter;
6866
}
6967

70-
Result<std::reference_wrapper<const std::shared_ptr<SortOrder>>>
71-
TableMetadata::SortOrder() const {
68+
Result<std::shared_ptr<SortOrder>> TableMetadata::SortOrder() const {
7269
auto iter = std::ranges::find_if(sort_orders, [this](const auto& order) {
7370
return order->order_id() == default_sort_order_id;
7471
});
@@ -78,7 +75,7 @@ TableMetadata::SortOrder() const {
7875
.message = std::format("Default sort order is not found"),
7976
});
8077
}
81-
return std::cref(*iter);
78+
return *iter;
8279
}
8380

8481
Result<TimePointMs> TimePointMsFromUnixMs(int64_t unix_ms) {

src/iceberg/table_metadata.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,11 @@ struct ICEBERG_EXPORT TableMetadata {
138138
int64_t next_row_id;
139139

140140
/// \brief Get the current schema, return NotFoundError if not found
141-
Result<std::reference_wrapper<const std::shared_ptr<Schema>>> Schema() const;
141+
Result<std::shared_ptr<Schema>> Schema() const;
142142
/// \brief Get the current partition spec, return NotFoundError if not found
143-
Result<std::reference_wrapper<const std::shared_ptr<PartitionSpec>>> PartitionSpec()
144-
const;
143+
Result<std::shared_ptr<PartitionSpec>> PartitionSpec() const;
145144
/// \brief Get the current sort order, return NotFoundError if not found
146-
Result<std::reference_wrapper<const std::shared_ptr<SortOrder>>> SortOrder() const;
145+
Result<std::shared_ptr<SortOrder>> SortOrder() const;
147146
};
148147

149148
/// \brief Returns a string representation of a SnapshotLogEntry

0 commit comments

Comments
 (0)