-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Kernel]Generalize the actions after commit(like checkpoint) by intro…
…ducing post commit action to kernel (#4115) <!-- Thanks for sending a pull request! Here are some tips for you: 1. If this is your first time, please read our contributor guidelines: https://github.com/delta-io/delta/blob/master/CONTRIBUTING.md 2. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP] Your PR title ...'. 3. Be sure to keep the PR description updated to reflect all changes. 4. Please write your PR title to summarize what this PR proposes. 5. If possible, provide a concise example to reproduce the issue for a faster review. 6. If applicable, include the corresponding issue number in the PR title and link it in the body. --> #### Which Delta project/connector is this regarding? <!-- Please add the component selected below to the beginning of the pull request title For example: [Spark] Title of my pull request --> - [ ] Spark - [ ] Standalone - [ ] Flink - [X] Kernel - [ ] Other (fill in here) ## Description <!-- - Describe what this PR changes. - Describe why we need the change. If this PR resolves an issue be sure to include "Resolves #XXX" to correctly link and close the issue upon merge. --> This PR doesn't make any functional changes, but abstract checkpoint into post commit action. This is prepared adding more post commit actions such as CRC write (#4116) ## How was this patch tested? Existing unit test, manual test using delta/kernel/examples/run-kernel-examples.py --use-local <!-- If tests were added, say they were added here. Please make sure to test the changes thoroughly including negative and positive cases if possible. If the changes were tested in any way other than unit tests, please clarify how you tested step by step (ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future). If the changes were not tested, please explain why. --> ## Does this PR introduce _any_ user-facing changes? <!-- If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible. If possible, please also clarify if this is a user-facing change compared to the released Delta Lake versions or within the unreleased branches such as master. If no, write 'No'. --> No
- Loading branch information
1 parent
2d07216
commit 685379c
Showing
7 changed files
with
160 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
kernel/kernel-api/src/main/java/io/delta/kernel/hook/PostCommitHook.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (2025) The Delta Lake Project Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.delta.kernel.hook; | ||
|
||
import io.delta.kernel.engine.Engine; | ||
import java.io.IOException; | ||
|
||
/** | ||
* A hook for executing operation after a transaction commit. Hooks are added in the Transaction and | ||
* engine need to invoke the hook explicitly for executing the operation. Supported operations are | ||
* listed in {@link PostCommitHookType}. | ||
*/ | ||
public interface PostCommitHook { | ||
|
||
enum PostCommitHookType { | ||
/** | ||
* Writes a new checkpoint at the version committed by the transaction. This hook is present | ||
* when the table is ready for checkpoint according to its configured checkpoint interval. To | ||
* perform this operation, reading previous checkpoint + logs is required to construct a new | ||
* checkpoint, with latency scaling based on log size (typically seconds to minutes). | ||
*/ | ||
CHECKPOINT | ||
} | ||
|
||
/** Invokes the post commit operation whose implementation must be thread safe. */ | ||
void threadSafeInvoke(Engine engine) throws IOException; | ||
|
||
PostCommitHookType getType(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
kernel/kernel-api/src/main/java/io/delta/kernel/internal/hook/CheckpointHook.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (2025) The Delta Lake Project Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.delta.kernel.internal.hook; | ||
|
||
import io.delta.kernel.Table; | ||
import io.delta.kernel.engine.Engine; | ||
import io.delta.kernel.hook.PostCommitHook; | ||
import io.delta.kernel.internal.fs.Path; | ||
import java.io.IOException; | ||
|
||
/** Write a new checkpoint at the version committed by the txn. */ | ||
public class CheckpointHook implements PostCommitHook { | ||
|
||
private final Path tablePath; | ||
private final long checkpointVersion; | ||
|
||
public CheckpointHook(Path tablePath, long checkpointVersion) { | ||
this.tablePath = tablePath; | ||
this.checkpointVersion = checkpointVersion; | ||
} | ||
|
||
@Override | ||
public void threadSafeInvoke(Engine engine) throws IOException { | ||
Table.forPath(engine, tablePath.toString()).checkpoint(engine, checkpointVersion); | ||
} | ||
|
||
@Override | ||
public PostCommitHookType getType() { | ||
return PostCommitHookType.CHECKPOINT; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters