You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "LuciferYang (via GitHub)" <gi...@apache.org> on 2024/02/09 11:32:41 UTC

Re: [PR] [SPARK-47006][CORE] Refactor `refill()` method to `isExhausted()` in `NioBufferedFileInputStream` [spark]

LuciferYang commented on code in PR #45068:
URL: https://github.com/apache/spark/pull/45068#discussion_r1484198113


##########
core/src/main/java/org/apache/spark/io/NioBufferedFileInputStream.java:
##########
@@ -66,32 +66,30 @@ private boolean refill() throws IOException {
         nRead = fileChannel.read(byteBuffer);
       }
       byteBuffer.flip();
-      if (nRead < 0) {
-        return false;
-      }
+      return nRead >= 0;
     }
     return true;
   }
 
   @Override
   public synchronized int read() throws IOException {
-    if (!refill()) {
-      return -1;
+    if (refill()) {

Review Comment:
   @mridulm I agree with your viewpoint. Currently, I have transformed the code from checking `!refill()` to checking `refill()`, and adjusted the corresponding handling logic (I have not yet updated the PR description). Do you consider this to be acceptable? If not, I will close this PR.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org