HuaHuaY commented on code in PR #344:
URL: https://github.com/apache/iceberg-cpp/pull/344#discussion_r2564633305
##########
src/iceberg/table_metadata.cc:
##########
@@ -162,6 +162,70 @@ bool operator==(const TableMetadata& lhs, const
TableMetadata& rhs) {
lhs.next_row_id == rhs.next_row_id;
}
+// TableMetadataCache implementation
+
+Result<TableMetadataCache::SchemasMapRef> TableMetadataCache::GetSchemasById()
const {
+ return schemas_map_.Get(metadata_);
+}
+
+Result<TableMetadataCache::PartitionSpecsMapRef>
+TableMetadataCache::GetPartitionSpecsById() const {
+ return partition_specs_map_.Get(metadata_);
+}
+
+Result<TableMetadataCache::SortOrdersMapRef>
TableMetadataCache::GetSortOrdersById()
+ const {
+ return sort_orders_map_.Get(metadata_);
+}
+
+Result<TableMetadataCache::SnapshotsMapRef>
TableMetadataCache::GetSnapshotsById() const {
+ return snapshot_map_.Get(metadata_);
+}
+
+Result<TableMetadataCache::SchemasMap> TableMetadataCache::InitSchemasMap(
+ const TableMetadata* metadata) {
+ SchemasMap schemas_map;
+ schemas_map.reserve(metadata->schemas.size());
Review Comment:
Just a suggestion. We can use `std::ranges::to` in `#include <ranges>` and
don't need to call `reserve`. For example:
```cpp
Result<TableMetadataCache::SchemasMap> TableMetadataCache::InitSchemasMap(
const TableMetadata* metadata) {
return metadata->schemas | std::views::transform([](auto& schema) {
return std::pair(schema->schema_id().value(), schema);
}) |
std::ranges::to<SchemasMap>();
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]