Skip to content

Commit 18bd8a4

Browse files
authored
[fileio] Introduce FileIO.overwriteHintFile (#5304)
1 parent 671c5b4 commit 18bd8a4

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

paimon-common/src/main/java/org/apache/paimon/fs/FileIO.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,15 @@ default void overwriteFileUtf8(Path path, String content) throws IOException {
348348
}
349349
}
350350

351+
/**
352+
* Overwrite hint file by content atomically, the characteristic of Hint file is that it can not
353+
* exist for a period of time, which allows some file systems to perform overwrite writing by
354+
* deleting and renaming.
355+
*/
356+
default void overwriteHintFile(Path path, String content) throws IOException {
357+
overwriteFileUtf8(path, content);
358+
}
359+
351360
/**
352361
* Copy content of one file into another.
353362
*

paimon-core/src/main/java/org/apache/paimon/utils/HintFileUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public static void commitHint(FileIO fileIO, long id, String fileName, Path dir)
109109
int loopTime = 3;
110110
while (loopTime-- > 0) {
111111
try {
112-
fileIO.overwriteFileUtf8(hintFile, String.valueOf(id));
112+
fileIO.overwriteHintFile(hintFile, String.valueOf(id));
113113
return;
114114
} catch (IOException e) {
115115
try {

0 commit comments

Comments
 (0)