1
0

[HUDI-1723] Fix path selector listing files with the same mod date (#2845)

This commit is contained in:
Raymond Xu
2021-05-25 07:19:10 -07:00
committed by GitHub
parent e7020748b5
commit afa6bc0b10
4 changed files with 184 additions and 10 deletions

View File

@@ -45,6 +45,8 @@ import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.FileTime;
import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
@@ -224,6 +226,11 @@ public class FileCreateUtils {
public static void createBaseFile(String basePath, String partitionPath, String instantTime, String fileId, long length)
throws Exception {
createBaseFile(basePath, partitionPath, instantTime, fileId, length, Instant.now().toEpochMilli());
}
public static void createBaseFile(String basePath, String partitionPath, String instantTime, String fileId, long length, long lastModificationTimeMilli)
throws Exception {
Path parentPath = Paths.get(basePath, partitionPath);
Files.createDirectories(parentPath);
Path baseFilePath = parentPath.resolve(baseFileName(instantTime, fileId));
@@ -231,6 +238,7 @@ public class FileCreateUtils {
Files.createFile(baseFilePath);
}
new RandomAccessFile(baseFilePath.toFile(), "rw").setLength(length);
Files.setLastModifiedTime(baseFilePath, FileTime.fromMillis(lastModificationTimeMilli));
}
public static void createLogFile(String basePath, String partitionPath, String instantTime, String fileId, int version)