Skip to content
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

Merged
merged 6 commits into from
Nov 5, 2024

Conversation

mxdzs0612
Copy link
Contributor

Purpose

Linked issue: close #4205

Tests

testPartitionCache

API and Format

CachingCatalog.getPartitions
CachingCatalog.refreshPartitions

Documentation

Allow cache and refresh partitions for CachingCatalog.

@JingsongLi JingsongLi closed this Nov 1, 2024
@JingsongLi JingsongLi reopened this Nov 1, 2024
Copy link
Contributor

@JingsongLi JingsongLi left a 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.

return ((FileStoreTable) table).newSnapshotReader().partitionEntries();
}

public List<PartitionEntry> refreshPartitions(Identifier identifier)
Copy link
Contributor

Choose a reason for hiding this comment

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

private

Copy link
Contributor Author

@mxdzs0612 mxdzs0612 Nov 4, 2024

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.

if (enablePartitionCache(table)
&& partitionCache.asMap().values().stream().mapToInt(List::size).sum()
< this.partitionMaxNum) {
partitionCache.put(identifier, partitions);
Copy link
Contributor

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?

Copy link
Contributor Author

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);
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

@JingsongLi JingsongLi left a comment

Choose a reason for hiding this comment

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

+1

@JingsongLi JingsongLi merged commit 5a8bde0 into apache:master Nov 5, 2024
13 checks passed
@mxdzs0612 mxdzs0612 deleted the partition_cache branch November 5, 2024 05:55
hang8929201 pushed a commit to hang8929201/paimon that referenced this pull request Nov 7, 2024
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.

[Feature] In paimon catalog, add partition query and cache
3 participants