danmuzi commented on a change in pull request #1338: LUCENE-9271: Move BufferedIndexInput to the ByteBuffer API URL: https://github.com/apache/lucene-solr/pull/1338#discussion_r391152040
########## File path: lucene/core/src/java/org/apache/lucene/store/BufferedIndexInput.java ########## @@ -154,65 +146,60 @@ public final void readBytes(byte[] b, int offset, int len, boolean useBuffer) th // this function, there is no need to do a seek // here, because there's no need to reread what we // had in the buffer. - long after = bufferStart+bufferPosition+len; + long after = bufferStart+buffer.position()+len; if(after > length()) throw new EOFException("read past EOF: " + this); - readInternal(b, offset, len); + readInternal(ByteBuffer.wrap(b, offset, len)); bufferStart = after; - bufferPosition = 0; - bufferLength = 0; // trigger refill() on read + buffer.position(0); Review comment: I think if there is `buffer.limit(0)` on the next line, `buffer.position(0)` doesn't look necessary. Because there is a code of initializing position value within `buffer.limit(0)`. ```java // ByteBuffer.java public abstract class ByteBuffer extends Buffer implements Comparable<ByteBuffer> { ... ByteBuffer limit(int newLimit) { super.limit(newLimit); return this; } ... } // Buffer.java public abstract class Buffer { ... public Buffer limit(int newLimit) { if (newLimit > capacity | newLimit < 0) throw createLimitException(newLimit); limit = newLimit; if (position > limit) position = limit; // position will be 0. if (mark > limit) mark = -1; return this; } ... } ``` ---------------------------------------------------------------- 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 With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org