rmuir commented on code in PR #14320:
URL: https://github.com/apache/lucene/pull/14320#discussion_r1976613907


##########
lucene/misc/src/java/org/apache/lucene/misc/store/DirectIODirectory.java:
##########
@@ -373,7 +373,13 @@ public long getFilePointer() {
     @Override
     public void seek(long pos) throws IOException {
       if (pos != getFilePointer()) {
-        seekInternal(pos);
+        final long absolutePos = pos + offset;
+        if (absolutePos >= filePos && absolutePos <= filePos + buffer.limit()) 
{
+          // the new position is within the existing buffer
+          buffer.position(Math.toIntExact(absolutePos - filePos));

Review Comment:
   ```suggestion
             buffer.position(Math.subtractExact(absolutePos, filePos));
   ```



-- 
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: issues-unsubscr...@lucene.apache.org

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


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

Reply via email to