mxdzs0612 commented on code in PR #4427:
URL: https://github.com/apache/paimon/pull/4427#discussion_r1827129237


##########
paimon-core/src/main/java/org/apache/paimon/catalog/CachingCatalog.java:
##########
@@ -227,6 +244,47 @@ private void putTableCache(Identifier identifier, Table 
table) {
         tableCache.put(identifier, table);
     }
 
+    public List<PartitionEntry> getPartitions(Identifier identifier) throws 
TableNotExistException {
+        Table table = this.getTable(identifier);
+        if (enablePartitionCache(table)) {
+            List<PartitionEntry> partitions;
+            partitions = partitionCache.getIfPresent(identifier);
+            if (partitions == null || partitions.isEmpty()) {
+                partitions = this.refreshPartitions(identifier);
+            }
+            return partitions;
+        }
+        return ((FileStoreTable) table).newSnapshotReader().partitionEntries();
+    }
+
+    public List<PartitionEntry> refreshPartitions(Identifier identifier)
+            throws TableNotExistException {
+        Table table = this.getTable(identifier);
+        List<PartitionEntry> partitions =
+                ((FileStoreTable) 
table).newSnapshotReader().partitionEntries();
+        if (enablePartitionCache(table)
+                && 
partitionCache.asMap().values().stream().mapToInt(List::size).sum()
+                        < this.partitionMaxNum) {
+            partitionCache.put(identifier, partitions);

Review Comment:
   No more partitions will be put in util some are expired, I suppose it 
tolerable.



-- 
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]

Reply via email to