Samrat002 commented on code in PR #28112:
URL: https://github.com/apache/flink/pull/28112#discussion_r3201408323


##########
flink-filesystems/flink-s3-fs-native/src/main/java/org/apache/flink/fs/s3native/NativeS3InputStream.java:
##########
@@ -98,39 +110,60 @@ public NativeS3InputStream(
                 this.readBufferSize / 1024);
     }
 
+    /** Reconciles {@link #nextReadPos} and {@link #streamPos} before reading 
bytes. */
     @GuardedBy("lock")
-    private void lazyInitialize() throws IOException {
-        assert lock.isHeldByCurrentThread() : "lazyInitialize() requires lock 
to be held";
-        if (currentStream == null && !closed) {
-            openStreamAtCurrentPosition();
-        }
-    }
+    private void lazySeek() throws IOException {
+        assert lock.isHeldByCurrentThread() : "lazySeek() requires lock to be 
held";
+        long targetPos = nextReadPos;
 
-    /** At EOF, release instead of reopening: {@code bytes=contentLength-} 
returns S3 416. */
-    @GuardedBy("lock")
-    private void repositionOpenStream() throws IOException {
-        assert lock.isHeldByCurrentThread() : "repositionOpenStream() requires 
lock to be held";
         if (currentStream == null) {
+            streamPos = targetPos;
             return;
         }
-        if (position >= contentLength) {
+
+        if (targetPos == streamPos) {
+            return;
+        }
+
+        long diff = targetPos - streamPos;
+        streamPos = targetPos;
+
+        if (targetPos >= contentLength) {
             releaseStreams();
-        } else {
+            return;
+        }
+
+        if (diff > 0 && diff <= (long) readBufferSize) {

Review Comment:
   added now . sorry for the miss 😄 



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