the-other-tim-brown commented on code in PR #9337:
URL: https://github.com/apache/hudi/pull/9337#discussion_r1281188320
##########
hudi-common/src/main/java/org/apache/hudi/common/model/HoodieLogFile.java:
##########
@@ -47,64 +52,86 @@ public class HoodieLogFile implements Serializable {
private transient FileStatus fileStatus;
private final String pathStr;
+ private final String fileId;
+ private final String baseCommitTime;
+ private final int logVersion;
+ private final String logWriteToken;
+ private final String fileExtension;
+ private final String suffix;
+ private final Path path;
private long fileLen;
public HoodieLogFile(HoodieLogFile logFile) {
- this.fileStatus = logFile.fileStatus;
- this.pathStr = logFile.pathStr;
- this.fileLen = logFile.fileLen;
+ this(logFile.getFileStatus(), logFile.getPath(), logFile.pathStr,
logFile.getFileSize());
}
public HoodieLogFile(FileStatus fileStatus) {
- this.fileStatus = fileStatus;
- this.pathStr = fileStatus.getPath().toString();
- this.fileLen = fileStatus.getLen();
+ this(fileStatus, fileStatus.getPath(), fileStatus.getPath().toString(),
fileStatus.getLen());
}
public HoodieLogFile(Path logPath) {
- this.fileStatus = null;
- this.pathStr = logPath.toString();
- this.fileLen = -1;
+ this(null, logPath, logPath.toString(), -1);
}
- public HoodieLogFile(Path logPath, Long fileLen) {
- this.fileStatus = null;
- this.pathStr = logPath.toString();
- this.fileLen = fileLen;
+ public HoodieLogFile(Path logPath, long fileLen) {
+ this(null, logPath, logPath.toString(), fileLen);
}
public HoodieLogFile(String logPathStr) {
- this.fileStatus = null;
+ this(null, null, logPathStr, -1);
+ }
+
+ private HoodieLogFile(FileStatus fileStatus, Path logPath, String
logPathStr, long fileLen) {
+ this.fileStatus = fileStatus;
this.pathStr = logPathStr;
- this.fileLen = -1;
+ this.fileLen = fileLen;
+ if (logPath != null) {
+ if (logPath instanceof CachingPath) {
+ this.path = logPath;
+ } else {
+ this.path = new CachingPath(logPath.getParent(), logPath.getName());
+ }
+ } else {
+ this.path = new CachingPath(pathStr);
+ }
+ Matcher matcher = LOG_FILE_PATTERN.matcher(path.getName());
+ if (!matcher.find()) {
+ throw new InvalidHoodiePathException(path, "LogFile");
+ }
+ this.fileId = matcher.group(1);
+ this.baseCommitTime = matcher.group(2);
+ this.fileExtension = matcher.group(3);
+ this.logVersion = Integer.parseInt(matcher.group(4));
+ this.logWriteToken = matcher.group(6);
+ this.suffix = matcher.group(10);
}
public String getFileId() {
- return FSUtils.getFileIdFromLogPath(getPath());
Review Comment:
Previously all of these methods would construct a path object and then run a
matcher on the fileName from that path. Now we'll make a single Path object
when creating the object and we'll run the matcher once and extract all the
values.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]