-
Notifications
You must be signed in to change notification settings - Fork 3k
Add UpdateSnapshotReference #3612
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
Conversation
jackye1995
left a comment
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.
Thank you for working on this! I added some comments first on the API part.
It seems to me that we are missing at least the 2 methods below:
- tag(String name, long snapshotId)
- setBranch(String name, long snapshotId)
otherwise there is no way to create a branch/tag without custom config.
| /** | ||
| * API for updating snapshot reference. | ||
| * <p> | ||
| * Apply returns the updated snapshot reference as a {@link SnapshotReference} for validation. |
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.
it is unclear to me what you mean by this, I think this sentence is not needed because the return type is self-explanatory.
| * @return this | ||
| * @throws IllegalArgumentException If there is no such snapshot reference named name | ||
| */ | ||
| UpdateSnapshotReference removeReference(String name); |
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.
nit: prefer to use ref over reference, such as removeRef
| * @return this | ||
| */ | ||
|
|
||
| UpdateSnapshotReference setMaxRefAgeMs(String name, Long maxRefAgeMs); |
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.
maybe setRefLifetime?
| * @param name new name for snapshot reference | ||
| * @return this | ||
| */ | ||
| UpdateSnapshotReference updateName(String oldName, String name); |
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.
I think this one and updateReference below are not needed, what are their use cases? We can always remove the old one and add a new one
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.
updateName is used when user want just update the name of one reference and inherit old config like reflifetime. And updateReference is used when user want update multiple properties of one old reference, so they can update these by just once operation.
| * <p> | ||
| * Apply returns the updated snapshot reference as a {@link SnapshotReference} for validation. | ||
| * <p> | ||
| * When committing, these changes will be applied to the current table metadata. Commit conflicts |
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.
Consider the situation that user A sets a retention policy for branch, and B sets retention policy for the same branch. Then both commits would succeed and one of the commit would be clobbered.
So I think the safest way to go is to not resolve commit conflicts. If the metadata is no longer current, a CommitFailedException should be thrown.
| * @param name name of snapshot reference what will be update | ||
| * @return this | ||
| */ | ||
|
|
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.
nit: extra blank line
| * @param name name of snapshot reference what will be update | ||
| * @return this | ||
| */ | ||
|
|
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.
nit: extra blank line
| UpdateSnapshotReference removeReference(String name); | ||
|
|
||
| /** | ||
| * Update minSnapshotsToKeep of snapshotReference what will be search by referenceName and snapshotReferenceType. |
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.
nit: I think we can be more concise here, something like "Set retention policy of snapshots in a branch". The retention policy settings should be explained in @param part using the definition provided in the spec (#3425)
| UpdateSnapshotReference setBranchRetention(String name, Long ageMs, Integer numToKeep); | ||
|
|
||
| /** | ||
| * Update minSnapshotsToKeep of snapshotReference what will be search by referenceName and snapshotReferenceType. |
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.
javadoc does not match
| * @return this | ||
| */ | ||
|
|
||
| UpdateSnapshotReference setBranchRetention(String name, Long ageMs, Integer numToKeep); |
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.
I think we should use primitive values so that people must specify a value. Having a method call like setBranchRetention("test", null, null) is unfriendly to readers of the code.
But I understand we want to have the flexibility for users to use defaults. We can potentially introduce 2 different methods for these two settings separately, like setBranchSnapshotLifetime(String name, long ageMs) and setMinSnapshotsInBranch(String name, int num), but maybe its a bit overkill.
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.
I used code several method like setBranchSnapshotLifetime and setMinSnapshotsInBranch. But i also think its a bit overkill, if it's necessary i will add these method.
|
I'd like to also invite @rdblue to take a look since we have been discussing about this feature. |
|
@jackye1995 fixed all |
Base on #3104.