rdblue commented on a change in pull request #1432:
URL: https://github.com/apache/iceberg/pull/1432#discussion_r485980437
##########
File path: core/src/main/java/org/apache/iceberg/CachingCatalog.java
##########
@@ -63,7 +67,29 @@ private TableIdentifier
canonicalizeIdentifier(TableIdentifier tableIdentifier)
@Override
public Table loadTable(TableIdentifier ident) {
- return tableCache.get(canonicalizeIdentifier(ident), catalog::loadTable);
+ TableIdentifier canonicalized = canonicalizeIdentifier(ident);
+ Table cached = tableCache.getIfPresent(canonicalized);
+ if (cached != null) {
+ return cached;
+ }
+
+ if (isValidMetadataIdentifier(canonicalized)) {
+ TableIdentifier originTableIdentifier =
TableIdentifier.of(canonicalized.namespace().levels());
+ Table originTable = tableCache.get(originTableIdentifier,
catalog::loadTable);
+
+ // share TableOperations instance of origin table for all metadata
tables, so that metadata table instances are
+ // also refreshed as well when origin table instance is refreshed.
+ if (originTable instanceof HasTableOperations) {
+ TableOperations ops = ((HasTableOperations) originTable).operations();
+ MetadataTableType type = MetadataTableType.from(canonicalized.name());
+
+ Table metadataTable = createMetadataTableInstance(ops,
originTableIdentifier, type);
+ tableCache.put(canonicalized, metadataTable);
+ return metadataTable;
+ }
+ }
+
+ return tableCache.get(canonicalized, catalog::loadTable);
Review comment:
This implementation looks good to me.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]