sunxiaojian commented on code in PR #2911:
URL: https://github.com/apache/incubator-paimon/pull/2911#discussion_r1522396068
##########
paimon-core/src/main/java/org/apache/paimon/utils/BranchManager.java:
##########
@@ -124,11 +153,101 @@ public void deleteBranch(String branchName) {
LOG.info(
String.format(
"Deleting the branch failed due to an exception in
deleting the directory %s. Please try again.",
- getBranchPath(tablePath, branchName)),
+ getBranchPath(fileIO, tablePath, branchName)),
e);
}
}
+ /** Replace specify branch to main branch. */
+ public void replaceBranch(String branchName) {
+ checkArgument(!StringUtils.isBlank(branchName), "Branch name '%s' is
blank.", branchName);
+ checkArgument(branchExists(branchName), "Branch name '%s' not
exists.", branchName);
+ try {
+ // 0. Cache previous tag,snapshot,schema directory.
+ Path tagDirectory = tagManager.tagDirectory();
+ Path snapshotDirectory = snapshotManager.snapshotDirectory();
+ Path schemaDirectory = schemaManager.schemaDirectory();
+ // 1. Calculate and copy the snapshots, tags and schemas which
should be copied from the
+ // main branch to target branch.
+ calculateCopyMainToBranch(branchName);
Review Comment:
> What is the purpose of this operation?
@FangYongs When a branch begins to rewrite data starting from a specific
point and is set as the main branch, we need to copy the schema, snapshot, and
tag from before the branch was created to the current branch to ensure the
integrity of the data.
--
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]