@@ -43,6 +43,7 @@ pub use self::decompressors::Decompressor;
43
43
pub ( crate ) use self :: reader:: DOCSTORE_CACHE_CAPACITY ;
44
44
pub use self :: reader:: { CacheStats , StoreReader } ;
45
45
pub use self :: writer:: StoreWriter ;
46
+ mod store_compressor;
46
47
47
48
#[ cfg( feature = "lz4-compression" ) ]
48
49
mod compression_lz4_block;
@@ -82,14 +83,16 @@ pub mod tests {
82
83
num_docs : usize ,
83
84
compressor : Compressor ,
84
85
blocksize : usize ,
86
+ separate_thread : bool ,
85
87
) -> Schema {
86
88
let mut schema_builder = Schema :: builder ( ) ;
87
89
let field_body = schema_builder. add_text_field ( "body" , TextOptions :: default ( ) . set_stored ( ) ) ;
88
90
let field_title =
89
91
schema_builder. add_text_field ( "title" , TextOptions :: default ( ) . set_stored ( ) ) ;
90
92
let schema = schema_builder. build ( ) ;
91
93
{
92
- let mut store_writer = StoreWriter :: new ( writer, compressor, blocksize) . unwrap ( ) ;
94
+ let mut store_writer =
95
+ StoreWriter :: new ( writer, compressor, blocksize, separate_thread) . unwrap ( ) ;
93
96
for i in 0 ..num_docs {
94
97
let mut doc = Document :: default ( ) ;
95
98
doc. add_field_value ( field_body, LOREM . to_string ( ) ) ;
@@ -112,7 +115,8 @@ pub mod tests {
112
115
let path = Path :: new ( "store" ) ;
113
116
let directory = RamDirectory :: create ( ) ;
114
117
let store_wrt = directory. open_write ( path) ?;
115
- let schema = write_lorem_ipsum_store ( store_wrt, NUM_DOCS , Compressor :: Lz4 , BLOCK_SIZE ) ;
118
+ let schema =
119
+ write_lorem_ipsum_store ( store_wrt, NUM_DOCS , Compressor :: Lz4 , BLOCK_SIZE , true ) ;
116
120
let field_title = schema. get_field ( "title" ) . unwrap ( ) ;
117
121
let store_file = directory. open_read ( path) ?;
118
122
let store = StoreReader :: open ( store_file, 10 ) ?;
@@ -148,11 +152,16 @@ pub mod tests {
148
152
Ok ( ( ) )
149
153
}
150
154
151
- fn test_store ( compressor : Compressor , blocksize : usize ) -> crate :: Result < ( ) > {
155
+ fn test_store (
156
+ compressor : Compressor ,
157
+ blocksize : usize ,
158
+ separate_thread : bool ,
159
+ ) -> crate :: Result < ( ) > {
152
160
let path = Path :: new ( "store" ) ;
153
161
let directory = RamDirectory :: create ( ) ;
154
162
let store_wrt = directory. open_write ( path) ?;
155
- let schema = write_lorem_ipsum_store ( store_wrt, NUM_DOCS , compressor, blocksize) ;
163
+ let schema =
164
+ write_lorem_ipsum_store ( store_wrt, NUM_DOCS , compressor, blocksize, separate_thread) ;
156
165
let field_title = schema. get_field ( "title" ) . unwrap ( ) ;
157
166
let store_file = directory. open_read ( path) ?;
158
167
let store = StoreReader :: open ( store_file, 10 ) ?;
@@ -177,29 +186,39 @@ pub mod tests {
177
186
}
178
187
179
188
#[ test]
180
- fn test_store_noop ( ) -> crate :: Result < ( ) > {
181
- test_store ( Compressor :: None , BLOCK_SIZE )
189
+ fn test_store_no_compression_same_thread ( ) -> crate :: Result < ( ) > {
190
+ test_store ( Compressor :: None , BLOCK_SIZE , false )
191
+ }
192
+
193
+ #[ test]
194
+ fn test_store_no_compression ( ) -> crate :: Result < ( ) > {
195
+ test_store ( Compressor :: None , BLOCK_SIZE , true )
182
196
}
197
+
183
198
#[ cfg( feature = "lz4-compression" ) ]
184
199
#[ test]
185
200
fn test_store_lz4_block ( ) -> crate :: Result < ( ) > {
186
- test_store ( Compressor :: Lz4 , BLOCK_SIZE )
201
+ test_store ( Compressor :: Lz4 , BLOCK_SIZE , true )
187
202
}
188
203
#[ cfg( feature = "snappy-compression" ) ]
189
204
#[ test]
190
205
fn test_store_snap ( ) -> crate :: Result < ( ) > {
191
- test_store ( Compressor :: Snappy , BLOCK_SIZE )
206
+ test_store ( Compressor :: Snappy , BLOCK_SIZE , true )
192
207
}
193
208
#[ cfg( feature = "brotli-compression" ) ]
194
209
#[ test]
195
210
fn test_store_brotli ( ) -> crate :: Result < ( ) > {
196
- test_store ( Compressor :: Brotli , BLOCK_SIZE )
211
+ test_store ( Compressor :: Brotli , BLOCK_SIZE , true )
197
212
}
198
213
199
214
#[ cfg( feature = "zstd-compression" ) ]
200
215
#[ test]
201
216
fn test_store_zstd ( ) -> crate :: Result < ( ) > {
202
- test_store ( Compressor :: Zstd ( ZstdCompressor :: default ( ) ) , BLOCK_SIZE )
217
+ test_store (
218
+ Compressor :: Zstd ( ZstdCompressor :: default ( ) ) ,
219
+ BLOCK_SIZE ,
220
+ true ,
221
+ )
203
222
}
204
223
205
224
#[ test]
@@ -364,6 +383,7 @@ mod bench {
364
383
1_000 ,
365
384
Compressor :: default ( ) ,
366
385
16_384 ,
386
+ true ,
367
387
) ;
368
388
directory. delete ( path) . unwrap ( ) ;
369
389
} ) ;
@@ -378,6 +398,7 @@ mod bench {
378
398
1_000 ,
379
399
Compressor :: default ( ) ,
380
400
16_384 ,
401
+ true ,
381
402
) ;
382
403
let store_file = directory. open_read ( path) . unwrap ( ) ;
383
404
let store = StoreReader :: open ( store_file, 10 ) . unwrap ( ) ;
0 commit comments