-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Kernel]Generalize the actions after commit(like checkpoint) by introducing post commit action to kernel #4115
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
7790fd1
make checkpoint post commit
huan233usc 0fc403d
post commit action
huan233usc 9278d0b
use async example
huan233usc 396e902
fix ident
huan233usc e18b792
add example for writing async
huan233usc 8f75f46
fix test
huan233usc debd1ae
add doc
huan233usc c1cbc47
fix ident
huan233usc f262fe0
fix java format
huan233usc 4d5ed9c
seperate commit action to hook package
huan233usc 60942c2
fix doc
huan233usc ddf351d
fix doc
huan233usc 9ab9587
package
huan233usc 1d96f54
ident
huan233usc d8cdaff
fix import
huan233usc 8a21a64
update the doc
huan233usc 006eb10
update message
huan233usc fd21ec1
update doc
huan233usc c9428e2
update doc
huan233usc c926f85
fix doc
huan233usc 6cf22c0
full stop
huan233usc b787781
fix doc
huan233usc b09a550
fix doc
huan233usc d8ce4f5
add itemize
huan233usc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Should we add more docs here declaring what type of work is considered a PostCommitHook? And how an engine should treat them? i.e. are they required, how do they relate to the commit, etc
Alternatively, maybe more thorough docs for each type?
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.
Added some doc, PTAL. Thanks
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.
Also add what sort of operations and latency wise. So that the connector can choose to run it async.
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.
Updated the documentation to indicate supported operations and latency indication for checkpoint in below section.