-
Notifications
You must be signed in to change notification settings - Fork 949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[core] Allow cache and refresh partitions for CachingCatalog #4427
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add an option? For example, it is called cache.partition.max-num
, which defaults to 0, meaning no cache partition.
paimon-core/src/main/java/org/apache/paimon/catalog/CachingCatalog.java
Outdated
Show resolved
Hide resolved
paimon-common/src/main/java/org/apache/paimon/options/CatalogOptions.java
Outdated
Show resolved
Hide resolved
return ((FileStoreTable) table).newSnapshotReader().partitionEntries(); | ||
} | ||
|
||
public List<PartitionEntry> refreshPartitions(Identifier identifier) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other engines may call this method regularly, so it should be public.
paimon-core/src/main/java/org/apache/paimon/catalog/CachingCatalog.java
Outdated
Show resolved
Hide resolved
paimon-core/src/main/java/org/apache/paimon/catalog/CachingCatalog.java
Outdated
Show resolved
Hide resolved
if (enablePartitionCache(table) | ||
&& partitionCache.asMap().values().stream().mapToInt(List::size).sum() | ||
< this.partitionMaxNum) { | ||
partitionCache.put(identifier, partitions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this put, if the total cached partitions in partitionCache is larger than partitionMaxNum. How do you handle this situation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No more partitions will be put in util some are expired, I suppose it tolerable.
throws TableNotExistException, PartitionNotExistException { | ||
wrapped.dropPartition(identifier, partitions); | ||
if (partitionCache != null) { | ||
partitionCache.invalidate(identifier); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why invalidate all partitions of this identifier in the cache?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't find a better way, any ideas?
paimon-core/src/test/java/org/apache/paimon/catalog/CachingCatalogTest.java
Outdated
Show resolved
Hide resolved
paimon-core/src/test/java/org/apache/paimon/catalog/CachingCatalogTest.java
Outdated
Show resolved
Hide resolved
paimon-core/src/test/java/org/apache/paimon/catalog/CachingCatalogTest.java
Outdated
Show resolved
Hide resolved
paimon-core/src/main/java/org/apache/paimon/catalog/CachingCatalog.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
Purpose
Linked issue: close #4205
Tests
testPartitionCache
API and Format
CachingCatalog.getPartitions
CachingCatalog.refreshPartitions
Documentation
Allow cache and refresh partitions for CachingCatalog.