vburenin commented on a change in pull request #2500:
URL: https://github.com/apache/hudi/pull/2500#discussion_r590769097



##########
File path: 
hudi-common/src/main/java/org/apache/hudi/common/table/log/HoodieLogFileReader.java
##########
@@ -107,6 +96,60 @@ public HoodieLogFileReader(FileSystem fs, HoodieLogFile 
logFile, Schema readerSc
     this(fs, logFile, readerSchema, DEFAULT_BUFFER_SIZE, false, false);
   }
 
+  /**
+   * Fetch the right {@link FSDataInputStream} to be used by wrapping with 
required input streams.
+   * @param fsDataInputStream original instance of {@link FSDataInputStream}.
+   * @param fs instance of {@link FileSystem} in use.
+   * @param bufferSize buffer size to be used.
+   * @return the right {@link FSDataInputStream} as required.
+   */
+  private FSDataInputStream getFSDataInputStream(FSDataInputStream 
fsDataInputStream, FileSystem fs, int bufferSize) {

Review comment:
       I would rather rewrite it like this reducing cyclomatic complexity, but 
I am also fine with what is here originally:
   ```java
     private FSDataInputStream getFSDataInputStream(FSDataInputStream 
fsDataInputStream, FileSystem fs, int bufferSize) {
       if (FSUtils.isGCSFileSystem(fs)) {
         return new SchemeAwareFSDataInputStream(
            getFSDataInputStreamForGCSFs(fsDataInputStream, fs, bufferSize), 
true);
       }
       if (fsDataInputStream.getWrappedStream() instanceof FSInputStream) {
           return new TimedFSDataInputStream(logFile.getPath(), new 
FSDataInputStream(
               new BufferedFSInputStream((FSInputStream) 
fsDataInputStream.getWrappedStream(), bufferSize)));
       }
       return fsDataInputStream;
     }
    
      private FSDataInputStream getFSDataInputStreamForGCSFs(FSDataInputStream 
fsDataInputStream, FileSystem fs, int bufferSize) {
       if (fsDataInputStream.getWrappedStream() instanceof FSInputStream) {
         return new TimedFSDataInputStream(logFile.getPath(), new 
FSDataInputStream(
             new BufferedFSInputStream((FSInputStream) 
fsDataInputStream.getWrappedStream(), bufferSize)));
       }
       if (fsDataInputStream.getWrappedStream() instanceof FSDataInputStream
           && ((FSDataInputStream) 
fsDataInputStream.getWrappedStream()).getWrappedStream() instanceof 
FSInputStream) {
         FSInputStream inputStream = (FSInputStream)((FSDataInputStream) 
fsDataInputStream.getWrappedStream()).getWrappedStream();
         return new TimedFSDataInputStream(logFile.getPath(), new 
FSDataInputStream(
             new BufferedFSInputStream(inputStream, bufferSize)));
       }
       return fsDataInputSt
    
   ```




----------------------------------------------------------------
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:
[email protected]


Reply via email to