You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2020/10/07 11:26:48 UTC

[GitHub] [iceberg] lcspinter commented on a change in pull request #1559: Core: Update version-hint.txt atomically

lcspinter commented on a change in pull request #1559:
URL: https://github.com/apache/iceberg/pull/1559#discussion_r500936162



##########
File path: core/src/main/java/org/apache/iceberg/hadoop/HadoopTableOperations.java
##########
@@ -295,22 +295,19 @@ private void writeVersionHint(int versionToWrite) {
     FileSystem fs = getFileSystem(versionHintFile, conf);
 
     try {
-      if (fs.exists(versionHintFile)) {
-        Path tempVersionHintFile = metadataPath("version-hint.temp" );
-        writeFileToPath(fs, tempVersionHintFile);
-        fs.delete(versionHintFile, false);
-        fs.rename(tempVersionHintFile, versionHintFile);
-      } else {
-        writeFileToPath(fs, versionHintFile);
-      }
+      Path tempVersionHintFile = metadataPath(UUID.randomUUID().toString() + "-version-hint.temp");
+      writeVersionToPath(fs, tempVersionHintFile, versionToWrite);
+      fs.delete(versionHintFile, false);
+      fs.rename(tempVersionHintFile, versionHintFile);
     } catch (IOException e) {
       LOG.warn("Failed to update version hint", e);
     }
   }
 
-  private void writeFileToPath(FileSystem fs, Path path) throws IOException{
-    FSDataOutputStream out = fs.create(path, true /* overwrite */);
-    out.write(String.valueOf(path).getBytes(StandardCharsets.UTF_8));
+  private void writeVersionToPath(FileSystem fs, Path path, int versionToWrite) throws IOException {
+    try (FSDataOutputStream out = fs.create(path, true /* overwrite */)) {

Review comment:
       Thanks for the review. Done




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org