original-brownbear commented on code in PR #12453: URL: https://github.com/apache/lucene/pull/12453#discussion_r1272006226
########## lucene/core/src/test/org/apache/lucene/store/TestBufferedIndexInput.java: ########## @@ -209,6 +209,103 @@ public void testBackwardsLongReads() throws IOException { "Expected 4 or 3, got " + input.readCount, input.readCount == 4 || input.readCount == 3); } + public void testReadFloats() throws IOException { + final int length = 1024 * 8; + MyBufferedIndexInput input = new MyBufferedIndexInput(length); + ByteBuffer bb = ByteBuffer.allocate(Float.BYTES).order(ByteOrder.LITTLE_ENDIAN); + final int bufferLength = 128; + float[] floatBuffer = new float[bufferLength]; + + for (int alignment = 0; alignment < Float.BYTES; alignment++) { + input.seek(0); + for (int i = 0; i < alignment; i++) { + input.readByte(); + } + final int bulkReads = length / (bufferLength * Float.BYTES) - 1; + for (int i = 0; i < bulkReads; i++) { + int pos = alignment + i * bufferLength * Float.BYTES; + final int floatOffset = random().nextInt(3); + input.skipBytes(floatOffset * Float.BYTES); + input.readFloats(floatBuffer, floatOffset, bufferLength - floatOffset); + for (int idx = floatOffset; idx < bufferLength; idx++) { + final int offset = pos + idx * Float.BYTES; + bb.position(0) + .put(byten(offset)) + .put(byten(offset + 1)) + .put(byten(offset + 2)) + .put(byten(offset + 3)); + assertEquals(bb.getFloat(0), floatBuffer[idx], 0f); Review Comment: Right that's technically more exact I think :) Adjusted that and added changes.txt entry -- 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