File tree 1 file changed +27
-0
lines changed
lucene/misc/src/test/org/apache/lucene/misc/store
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -209,4 +209,31 @@ public void testUseDirectIODefaults() throws Exception {
209
209
OptionalLong .of (largeSize )));
210
210
}
211
211
}
212
+
213
+ // Ping-pong seeks should be really fast, since the position should be within buffer.
214
+ // The test should complete within sub-second times, not minutes.
215
+ public void testSeekSmall () throws IOException {
216
+ Path tmpDir = createTempDir ("testSeekSmall" );
217
+ int blockSize = Math .toIntExact (Files .getFileStore (tmpDir ).getBlockSize ());
218
+ try (Directory dir = getDirectory (tmpDir )) {
219
+ int len = atLeast (100 );
220
+ try (IndexOutput o = dir .createOutput ("out" , newIOContext (random ()))) {
221
+ byte [] b = new byte [len ];
222
+ for (int i = 0 ; i < len ; i ++) {
223
+ b [i ] = (byte ) i ;
224
+ }
225
+ o .writeBytes (b , 0 , len );
226
+ }
227
+ try (IndexInput in = dir .openInput ("out" , newIOContext (random ()))) {
228
+ for (int i = 0 ; i < 100_000 ; i ++) {
229
+ in .seek (2 );
230
+ assertEquals (2 , in .readByte ());
231
+ in .seek (1 );
232
+ assertEquals (1 , in .readByte ());
233
+ in .seek (0 );
234
+ assertEquals (0 , in .readByte ());
235
+ }
236
+ }
237
+ }
238
+ }
212
239
}
You can’t perform that action at this time.
0 commit comments