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



##########
File path: 
hudi-common/src/main/java/org/apache/hudi/common/table/log/HoodieLogFileReader.java
##########
@@ -75,17 +76,18 @@
   public HoodieLogFileReader(FileSystem fs, HoodieLogFile logFile, Schema 
readerSchema, int bufferSize,
                              boolean readBlockLazily, boolean reverseReader) 
throws IOException {
     FSDataInputStream fsDataInputStream = fs.open(logFile.getPath(), 
bufferSize);
-    if (FSUtils.isGCSInputStream(fsDataInputStream)) {
-      this.inputStream = new TimedFSDataInputStream(logFile.getPath(), new 
FSDataInputStream(
+    boolean isGCSFileSystem = FSUtils.isGCSFileSystem(fs);
+    if (isGCSFileSystem) {

Review comment:
       I had a failure here running a job with a previous GCS detector, it 
would determine it to be GCS based on FSDataInputStream, but when it calls 
getWrappedStream().getWrappedStream() it ends up with 
GoogleHadoopFSDataInputStream that could not be cast to FSInputStream. So as a 
quick fix IF to this checking for FSInputStream first:
   ```java
       if (fsDataInputStream.getWrappedStream() instanceof FSInputStream) {
         this.inputStream = new TimedFSDataInputStream(logFile.getPath(), new 
FSDataInputStream(
             new BufferedFSInputStream((FSInputStream) 
fsDataInputStream.getWrappedStream(), bufferSize)));
       } else if (FSUtils.isGCSInputStream(fsDataInputStream)) {
         this.inputStream = new TimedFSDataInputStream(logFile.getPath(), new 
FSDataInputStream(
             new BufferedFSInputStream((FSInputStream) ((
                 (FSDataInputStream) 
fsDataInputStream.getWrappedStream()).getWrappedStream()), bufferSize)));
       } else {
         // fsDataInputStream.getWrappedStream() maybe a BufferedFSInputStream
         // need to wrap in another BufferedFSInputStream the make bufferSize 
work?
         this.inputStream = fsDataInputStream;
       }
   ```
   
   I would suggest you rearrange it here too as there is no need to do anything 
special if fsDataInputStream.getWrappedStream() is instanceof FSInputStream
   
   

##########
File path: 
hudi-common/src/main/java/org/apache/hudi/common/fs/SchemeAwareFSDataInputStream.java
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hudi.common.fs;
+
+import org.apache.hadoop.fs.FSDataInputStream;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Scheme aware FSDataInputStream so that we manipulate seeks for GS 
filesystem.
+ */
+public class SchemeAwareFSDataInputStream extends FSDataInputStream {
+
+  private final boolean isGCSFileSystem;
+
+  public SchemeAwareFSDataInputStream(InputStream in, boolean isGCSFileSystem) 
{
+    super(in);
+    this.isGCSFileSystem = isGCSFileSystem;
+  }
+
+  @Override
+  public void seek(long desired) throws IOException {
+    if (isGCSFileSystem) {

Review comment:
       This seems very weird to me from GCS behavior stand point. Is it always 
-1 difference from HDFS? Is it only applicable to the last byte position that 
is technically a length of file? I only saw a failure when it tried to jump to 
the last byte of the file. How does it behave if it wrapped by BufferedReader? 
Is it the same behavior if data is buffered?




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