john-mlika commented on code in PR #16619:
URL: https://github.com/apache/lucene/pull/16619#discussion_r3916843627


##########
lucene/misc/src/test/org/apache/lucene/misc/store/TestDirectIODirectory.java:
##########
@@ -218,6 +219,245 @@ public void testUseDirectIODefaults() throws Exception {
     }
   }
 
+  private static byte[] writeRandomFile(Directory dir, String name, int size) 
throws IOException {
+    byte[] bytes = new byte[size];
+    random().nextBytes(bytes);
+    try (IndexOutput o = dir.createOutput(name, IOContext.DEFAULT)) {
+      o.writeBytes(bytes, 0, size);
+    }
+    return bytes;
+  }
+
+  public void testSliceDefersIOAtEveryOffset() throws Exception {
+    Path path = createTempDir("testSliceDefersIOAtEveryOffset");
+    final int blockSize = 
Math.toIntExact(Files.getFileStore(path).getBlockSize());
+    final int fileSize = 4 * blockSize;
+    try (Directory dir = getDirectory(path)) {
+      byte[] bytes = writeRandomFile(dir, "out", fileSize);
+      final long[] offsets = {
+        0, 1, 7, 96, blockSize, blockSize + 188, 2L * blockSize, 3L * 
blockSize - 4

Review Comment:
   partly, yes. i wanted a few offsets guaranteed every run: 0, some unaligned 
ones inside the first block (codec header), two block starts and one unaligned 
offset after a block start, and the last bytes of the file. i kept those and 
added a few random offsets on top



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to