File tree 1 file changed +23
-0
lines changed
lucene/core/src/test/org/apache/lucene/store
1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,29 @@ public void testWithNormal() throws Exception {
131
131
}
132
132
}
133
133
134
+ public void testPreload () throws Exception {
135
+ final int size = 8 * 1024 ;
136
+ byte [] bytes = new byte [size ];
137
+ random ().nextBytes (bytes );
138
+
139
+ try (MMapDirectory dir = new MMapDirectory (createTempDir ("testPreload" ))) {
140
+ dir .setPreload (MMapDirectory .PRELOAD_HINT );
141
+ try (IndexOutput out =
142
+ dir .createOutput ("test" , IOContext .DEFAULT .withHints (PreloadHint .INSTANCE ))) {
143
+ out .writeBytes (bytes , 0 , bytes .length );
144
+ }
145
+
146
+ try (final IndexInput in =
147
+ dir .openInput ("test" , IOContext .DEFAULT .withHints (PreloadHint .INSTANCE ))) {
148
+ // the data should be loaded in memory
149
+ assertTrue (in .isLoaded ().orElse (false ));
150
+ final byte [] readBytes = new byte [size ];
151
+ in .readBytes (readBytes , 0 , readBytes .length );
152
+ assertArrayEquals (bytes , readBytes );
153
+ }
154
+ }
155
+ }
156
+
134
157
// Opens the input with ReadAdvice.READONCE to ensure slice and clone are appropriately confined
135
158
public void testConfined () throws Exception {
136
159
final int size = 16 ;
You can’t perform that action at this time.
0 commit comments