uschindler commented on code in PR #12841: URL: https://github.com/apache/lucene/pull/12841#discussion_r1420364348
########## lucene/test-framework/src/java/org/apache/lucene/tests/store/BaseDirectoryTestCase.java: ########## @@ -1438,4 +1440,68 @@ public void testListAllIsSorted() throws IOException { assertArrayEquals(expected, actual); } } + + public void testDataTypes() throws IOException { + final long[] values = new long[] {43, 12345, 123456, 1234567890}; + try (Directory dir = getDirectory(createTempDir("testDataTypes"))) { + IndexOutput out = dir.createOutput("test", IOContext.DEFAULT); + out.writeByte((byte) 43); + out.writeShort((short) 12345); + out.writeInt(1234567890); + out.writeGroupVInts(values, 4); + out.writeLong(1234567890123456789L); + out.close(); + + long[] restored = new long[4]; + IndexInput in = dir.openInput("test", IOContext.DEFAULT); + assertEquals(43, in.readByte()); + assertEquals(12345, in.readShort()); + assertEquals(1234567890, in.readInt()); + in.readGroupVInts(restored, 4); + assertArrayEquals(values, restored); + assertEquals(1234567890123456789L, in.readLong()); + in.close(); + } + } + + public void testGroupVInt() throws IOException { + try (Directory dir = getDirectory(createTempDir("testGroupVInt"))) { + // test fallback to default implementation of readGroupVInt + doTestGroupVInt(dir, 5, 1, 6, 8); + + // use more iterations to covers all bpv + doTestGroupVInt(dir, atLeast(100), 1, 31, 128); + + // we use BaseChunkedDirectoryTestCase#testGroupVIntMultiBlocks cover multiple blocks for + // ByteBuffersDataInput and MMapDirectory + } + } + + protected void doTestGroupVInt( + Directory dir, int iterations, int minBpv, int maxBpv, int maxNumValues) throws IOException { + long[] values = new long[maxNumValues]; + long[] restored = new long[maxNumValues]; + + for (int i = 0; i < iterations; i++) { Review Comment: I am a bit afraid that those tests kill my SSD at some point (also Jenkin's SSD). This creates files over and over. With test directories its not a problem, but with real FDDirectory ones we should reduce the iteration counts. The chunked test should clearly setup a directory with a random chunk size once and run all tests on it. Ideally write only one file with multiple variants of groupVints behind each other (so it definitely crosses borders) and then read all of them. -- 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