mikemccand commented on code in PR #14103:
URL: https://github.com/apache/lucene/pull/14103#discussion_r1904581374


##########
lucene/misc/src/java/org/apache/lucene/misc/store/DirectIODirectory.java:
##########
@@ -428,19 +441,110 @@ public void readBytes(byte[] dst, int offset, int len) 
throws IOException {
       }
     }
 
+    @Override
+    public short readShort() throws IOException {
+      if (buffer.remaining() >= Short.BYTES) {
+        return buffer.getShort();
+      } else {
+        return super.readShort();
+      }
+    }
+
+    @Override
+    public int readInt() throws IOException {
+      if (buffer.remaining() >= Integer.BYTES) {
+        return buffer.getInt();
+      } else {
+        return super.readInt();
+      }
+    }
+
+    @Override
+    public long readLong() throws IOException {
+      if (buffer.remaining() >= Long.BYTES) {
+        return buffer.getLong();
+      } else {
+        return super.readLong();
+      }
+    }
+
+    @Override
+    public void readInts(int[] dst, int offset, int len) throws IOException {
+      int remainingDst = len;
+      while (remainingDst > 0) {
+        int cnt = Math.min(buffer.remaining() / Integer.BYTES, remainingDst);
+        buffer.asIntBuffer().get(dst, offset + len - remainingDst, cnt);
+        buffer.position(buffer.position() + Integer.BYTES * cnt);
+        remainingDst -= cnt;
+        if (remainingDst > 0) {
+          if (buffer.hasRemaining()) {
+            dst[offset + len - remainingDst] = readInt();
+            --remainingDst;
+          } else {
+            refill(remainingDst * Integer.BYTES);
+          }
+        }
+      }
+    }
+
+    @Override
+    public void readFloats(float[] dst, int offset, int len) throws 
IOException {
+      int remainingDst = len;
+      while (remainingDst > 0) {
+        int cnt = Math.min(buffer.remaining() / Float.BYTES, remainingDst);
+        buffer.asFloatBuffer().get(dst, offset + len - remainingDst, cnt);
+        buffer.position(buffer.position() + Float.BYTES * cnt);
+        remainingDst -= cnt;
+        if (remainingDst > 0) {
+          if (buffer.hasRemaining()) {
+            dst[offset + len - remainingDst] = Float.intBitsToFloat(readInt());
+            --remainingDst;
+          } else {
+            refill(remainingDst * Float.BYTES);
+          }
+        }
+      }
+    }
+
+    @Override
+    public void readLongs(long[] dst, int offset, int len) throws IOException {
+      int remainingDst = len;
+      while (remainingDst > 0) {
+        int cnt = Math.min(buffer.remaining() / Long.BYTES, remainingDst);
+        buffer.asLongBuffer().get(dst, offset + len - remainingDst, cnt);
+        buffer.position(buffer.position() + Long.BYTES * cnt);
+        remainingDst -= cnt;
+        if (remainingDst > 0) {
+          if (buffer.hasRemaining()) {
+            dst[offset + len - remainingDst] = readLong();
+            --remainingDst;
+          } else {
+            refill(remainingDst * Long.BYTES);
+          }
+        }
+      }
+    }
+
     @Override
     public DirectIOIndexInput clone() {
       try {
-        return new DirectIOIndexInput(this);
+        var clone = new DirectIOIndexInput("clone:" + this, this, offset, 
length);
+        clone.seek(getFilePointer());
+        return clone;
       } catch (IOException ioe) {
         throw new UncheckedIOException(ioe);
       }
     }
 
     @Override
-    public IndexInput slice(String sliceDescription, long offset, long length) 
{
-      // TODO: is this the right thing to do?

Review Comment:
   HA!  Love it :)  Thank you for removing this long-ago-written comment ...



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