Skip to content

Commit

Permalink
use async example
Browse files Browse the repository at this point in the history
  • Loading branch information
huan233usc committed Feb 3, 2025
1 parent 0fc403d commit 9278d0b
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -410,11 +410,17 @@ public void insertWithOptionalCheckpoint(String tablePath) throws IOException {
for (int i = 0; i < 12; i++) {
TransactionCommitResult commitResult = insertDataIntoUnpartitionedTable(tablePath);
for(PostCommitAction action: commitResult.getPostCommitActions())
if (action.getType().equals("checkpoint")) {
// Checkpoint the table
action.threadSafeInvoke();
didCheckpoint = true;
}
didCheckpoint = didCheckpoint || CompletableFuture.supplyAsync(() -> {
// run the code async
try{
action.threadSafeInvoke();
} catch (IOException e) {
return false;
}
return action.getType().equals("checkpoint");
}
).join(); // wait async finish.
}

if (!didCheckpoint) {
Expand Down

0 comments on commit 9278d0b

Please sign in to comment.