Copilot commented on code in PR #8935:
URL: https://github.com/apache/hbase/pull/8935#discussion_r4753309850


##########
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:
   For existing `hbase.fs.wrapper` implementations that override only 
`open(Path, int)`, this silently bypasses their stream decoration or read-time 
checks on initial, no-checksum, and fallback opens. 
`FilterFileSystem.openFile()` delegates directly to the underlying filesystem 
([Hadoop default-branch 
source](https://github.com/apache/hadoop/blob/055a70d3b4ec0918ab7a066cae30ae09e1317cba/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFileSystem.java#L709-L728)),
 so no unsupported-operation exception triggers the legacy fallback. Preserve 
legacy opens for wrappers without explicit builder support and add a regression 
test using an open-only wrapper.



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

Reply via email to