taklwu commented on code in PR #8935:
URL: https://github.com/apache/hbase/pull/8935#discussion_r4773885608
##########
hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java:
##########
@@ -217,6 +218,54 @@ public static FSDataOutputStream create(Configuration
conf, FileSystem fs, Path
return create(conf, fs, path, perm, favoredNodes, true);
}
+ /**
+ * Opens a file for reading. When {@code fileStatus} is supplied and the
{@link FileSystem}
+ * supports {@code FileSystem.openFile().withFileStatus()}, that path is
used so the client can
+ * skip a redundant metadata lookup (for example {@code getFileInfo}).
+ * @param fs filesystem
+ * @param path file to open
+ * @param fileStatus status from a recent {@code listStatus} / {@code
getFileStatus}, or
+ * {@code null}
+ * @return input stream for the file
+ * @throws IOException if the file cannot be opened
+ */
+ public static FSDataInputStream openForRead(FileSystem fs, Path path,
FileStatus fileStatus)
+ throws IOException {
+ if (fileStatus != null) {
+ try {
+ CompletableFuture<FSDataInputStream> future =
+ fs.openFile(path).withFileStatus(fileStatus).build();
Review Comment:
let's have a followup JIRA for this , mainly both master and branch-3 needs
this.
--
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]