bilaharith commented on a change in pull request #2464:
URL: https://github.com/apache/hadoop/pull/2464#discussion_r538340690



##########
File path: 
hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/AbfsInputStream.java
##########
@@ -211,6 +235,59 @@ private int readOneBlock(final byte[] b, final int off, 
final int len) throws IO
     return bytesToRead;
   }
 
+  private boolean shouldReadFully() {
+    return this.firstRead && this.context.readSmallFilesCompletely()
+        && this.contentLength <= this.bufferSize;
+  }
+
+  private boolean shouldReadLastBlock(int len) {
+    return this.firstRead && this.context.optimizeFooterRead()
+        && len == FOOTER_SIZE
+        && this.fCursor == this.contentLength - FOOTER_SIZE;
+  }
+
+  private int readFileCompletely(final byte[] b, final int off, final int len) 
throws IOException {
+    int validation = validate(b, off, len);
+    if (validation < 1) {
+      return validation;
+    }
+
+    buffer = new byte[bufferSize];
+    bCursor = (int) fCursor;
+    int bytesRead = readInternal(0, buffer, 0, (int) contentLength, true);
+    firstRead = false;
+    if (bytesRead == -1) {
+      return -1;
+    }
+    fCursorAfterLastRead = fCursor;
+    limit = bytesRead;
+    fCursor = bytesRead;
+    return copyToUserBuffer(b, off, len);
+  }
+
+  private int readLastBlock(final byte[] b, final int off, final int len) 
throws IOException {
+    int validation = validate(b, off, len);
+    if (validation < 1) {
+      return validation;
+    }
+
+    buffer = new byte[bufferSize];
+    bCursor = (int) (((contentLength < bufferSize) ? contentLength : 
bufferSize)
+        - FOOTER_SIZE);
+    long lastBlockStartPos = (contentLength < bufferSize)
+        ? 0
+        : contentLength - bufferSize;
+    int bytesRead = readInternal(lastBlockStartPos, buffer, 0, bufferSize,
+        true);
+    firstRead = false;
+    if (bytesRead == -1) {
+      return -1;
+    }
+    fCursorAfterLastRead = fCursor;
+    limit = bytesRead;
+    fCursor = lastBlockStartPos + bytesRead;

Review comment:
       fCursor is moved after the read is complete and the current fCursor is 
set to fCursorAfterLastRead. SO this is correct.




----------------------------------------------------------------
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:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org

Reply via email to