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] Add cache for snapshots in CachingCatalog #4565

Merged
merged 8 commits into from
Nov 22, 2024

Conversation

JingsongLi
Copy link
Contributor

@JingsongLi JingsongLi commented Nov 21, 2024

Purpose

Considering that all snapshot files are immutable, we are considering adding cache to them. It is safe to cache them in Table Object.

Tests

API and Format

Documentation

@JingsongLi JingsongLi changed the title [WIP][core] Add cache for snapshots and tags and schemas [WIP][core] Add cache for snapshots and schemas Nov 21, 2024
@JingsongLi JingsongLi changed the title [WIP][core] Add cache for snapshots and schemas [core] Add cache for snapshots and schemas Nov 21, 2024
SNAPSHOT_CACHE.put(path, snapshot);
}
return snapshot;
} catch (FileNotFoundException e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

May be we can only catch IOException? There's no need to catch FileNotFoundException and throw it direct?

Copy link
Contributor Author

@JingsongLi JingsongLi Nov 22, 2024

Choose a reason for hiding this comment

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

tryFromPath is just for FileNotFoundException, invoker can know the file does not exists.

invalidateMetaCacheForPrefix(SCHEMA_CACHE, path);
}

private static void invalidateMetaCacheForPrefix(Cache<Path, ?> cache, String tablePath) {
Copy link
Contributor

Choose a reason for hiding this comment

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

May be invalidateMetaCacheByPrefix?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

deleted

import org.apache.paimon.schema.TableSchema;
import org.apache.paimon.tag.Tag;

/** Cache for {@link Snapshot} and {@link Tag} and {@link TableSchema}. */
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this class reserved for future use?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

deleted

@@ -680,6 +681,9 @@ protected void dropTableImpl(Identifier identifier) {
false,
true));

Path path = getTableLocation(identifier);
invalidateMetaCacheForPrefix(path);
Copy link
Contributor

Choose a reason for hiding this comment

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

May invalidateMetaCacheForPrefix(path) can execute in AbstractCatalog#dropTable after dropTableImpl(identifier)?
Because If a new Catalog @OverRide AbstractCatalog#dropTableImpl, it may forget to call invalidateMetaCacheForPrefix(path).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

deleted

}
}

public static Tag tryFromPath(FileIO fileIO, Path path) throws FileNotFoundException {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not cache Tag and Changelog like Snapshot?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tag is mutable, it is danger.

@JingsongLi JingsongLi changed the title [core] Add cache for snapshots and schemas [core] Add cache for snapshots in CachingCatalog Nov 22, 2024
Copy link
Contributor

@yuzelin yuzelin 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 5f9a8fb into apache:master Nov 22, 2024
10 of 13 checks passed
@ranxianglei
Copy link
Contributor

mark!

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.

4 participants