Skip to content

Conversation

@wgtmac
Copy link
Member

@wgtmac wgtmac commented Nov 26, 2025

Introduced a TableMetadataCache to support lazy initialization of mappings for schemas, partition specs, sort orders and snapshots.

@wgtmac wgtmac force-pushed the lazy_map_for_table branch from ff3a3f9 to 96741af Compare November 26, 2025 09:43
Result<TableMetadataCache::SchemasMap> TableMetadataCache::InitSchemasMap(
const TableMetadata* metadata) {
SchemasMap schemas_map;
schemas_map.reserve(metadata->schemas.size());
Copy link
Contributor

@HuaHuaY HuaHuaY Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just FYI. We can use std::ranges::to in #include <ranges> and don't need to call reserve. For example:

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>();
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

../src/iceberg/table_metadata.cc: In static member function ‘static iceberg::Result<std::unordered_map<int, std::shared_ptriceberg::Schema, std::hash, std::equal_to, std::allocator<std::pair<const int, std::shared_ptriceberg::Schema > > > > iceberg::TableMetadataCache::InitSchemasMap(const iceberg::TableMetadata*)’:
../src/iceberg/table_metadata.cc:194:23: error: ‘to’ is not a member of ‘std::ranges’
194 | std::ranges::to();
| ^~
../src/iceberg/table_metadata.cc:194:36: error: expected primary-expression before ‘>’ token
194 | std::ranges::to();
| ^
../src/iceberg/table_metadata.cc:194:38: error: expected primary-expression before ‘)’ token
194 | std::ranges::to();
|

Copy link
Contributor

@HuaHuaY HuaHuaY Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sad. std::ranges::to is supported by gcc 14. But we use gcc 13 in ci.
I test in my local environment. vendoredarrow-src can be compiled by gcc 14 but can not be compiled by clang base on gcc 14. The difference is cmake will generate different compile flags. Clang will report that atomic_load is deprecated.
Maybe we can upgrade gcc's version in ci from 13 to 14.

Copy link
Contributor

@HeartLinked HeartLinked left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Contributor

@Fokko Fokko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, that looks much cleaner @wgtmac 🙌

@wgtmac
Copy link
Member Author

wgtmac commented Nov 27, 2025

Thanks @HuaHuaY @HeartLinked @Fokko @zhjwpku for the review!

@wgtmac wgtmac merged commit af746c7 into apache:main Nov 27, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants