romseygeek commented on code in PR #12241:
URL: https://github.com/apache/lucene/pull/12241#discussion_r1177646123


##########
lucene/core/src/test/org/apache/lucene/codecs/lucene90/TestLucene90CompoundFormat.java:
##########
@@ -27,4 +36,58 @@ public class TestLucene90CompoundFormat extends 
BaseCompoundFormatTestCase {
   protected Codec getCodec() {
     return codec;
   }
+
+  public void testFileLengthOrdering() throws IOException {
+    Directory dir = newDirectory();
+    // Setup the test segment
+    String segment = "_123";
+    int chunk = 1024; // internal buffer size used by the stream
+    SegmentInfo si = newSegmentInfo(dir, segment);
+    byte[] segId = si.getId();
+    List<String> files = new ArrayList<>();
+    int randomFileSize = random().nextInt(0, chunk);
+    for (int i = 0; i < 10; i++) {
+      String filename = segment + "." + i;
+      createRandomFile(dir, filename, randomFileSize, segId);
+      // increase the next files size by a random amount
+      randomFileSize += random().nextInt(1, 100);
+      files.add(filename);
+    }
+    si.setFiles(files);

Review Comment:
   Can we explicitly shuffle the `files` list to make it clear that things are 
in a random order within the segment info?  And maybe add a comment to the 
point that it's held internally as a set so there's no defined ordering in any 
case?



##########
lucene/core/src/java/org/apache/lucene/codecs/lucene90/Lucene90CompoundFormat.java:
##########
@@ -102,11 +103,40 @@ public void write(Directory dir, SegmentInfo si, 
IOContext context) throws IOExc
     }
   }
 
+  private static class SizedFile {
+    String name;

Review Comment:
   Let's make these final?



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