@@ -50,6 +50,9 @@ mod compression_brotli;
50
50
#[ cfg( feature = "snappy-compression" ) ]
51
51
mod compression_snap;
52
52
53
+ #[ cfg( feature = "zstd-compression" ) ]
54
+ mod compression_zstd_block;
55
+
53
56
#[ cfg( test) ]
54
57
pub mod tests {
55
58
@@ -69,18 +72,21 @@ pub mod tests {
69
72
sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt \
70
73
mollit anim id est laborum.";
71
74
75
+ const BLOCK_SIZE : usize = 16_384 ;
76
+
72
77
pub fn write_lorem_ipsum_store (
73
78
writer : WritePtr ,
74
79
num_docs : usize ,
75
80
compressor : Compressor ,
81
+ blocksize : usize ,
76
82
) -> Schema {
77
83
let mut schema_builder = Schema :: builder ( ) ;
78
84
let field_body = schema_builder. add_text_field ( "body" , TextOptions :: default ( ) . set_stored ( ) ) ;
79
85
let field_title =
80
86
schema_builder. add_text_field ( "title" , TextOptions :: default ( ) . set_stored ( ) ) ;
81
87
let schema = schema_builder. build ( ) ;
82
88
{
83
- let mut store_writer = StoreWriter :: new ( writer, compressor) ;
89
+ let mut store_writer = StoreWriter :: new ( writer, compressor, blocksize ) ;
84
90
for i in 0 ..num_docs {
85
91
let mut doc = Document :: default ( ) ;
86
92
doc. add_field_value ( field_body, LOREM . to_string ( ) ) ;
@@ -103,7 +109,7 @@ pub mod tests {
103
109
let path = Path :: new ( "store" ) ;
104
110
let directory = RamDirectory :: create ( ) ;
105
111
let store_wrt = directory. open_write ( path) ?;
106
- let schema = write_lorem_ipsum_store ( store_wrt, NUM_DOCS , Compressor :: Lz4 ) ;
112
+ let schema = write_lorem_ipsum_store ( store_wrt, NUM_DOCS , Compressor :: Lz4 , BLOCK_SIZE ) ;
107
113
let field_title = schema. get_field ( "title" ) . unwrap ( ) ;
108
114
let store_file = directory. open_read ( path) ?;
109
115
let store = StoreReader :: open ( store_file) ?;
@@ -139,11 +145,11 @@ pub mod tests {
139
145
Ok ( ( ) )
140
146
}
141
147
142
- fn test_store ( compressor : Compressor ) -> crate :: Result < ( ) > {
148
+ fn test_store ( compressor : Compressor , blocksize : usize ) -> crate :: Result < ( ) > {
143
149
let path = Path :: new ( "store" ) ;
144
150
let directory = RamDirectory :: create ( ) ;
145
151
let store_wrt = directory. open_write ( path) ?;
146
- let schema = write_lorem_ipsum_store ( store_wrt, NUM_DOCS , compressor) ;
152
+ let schema = write_lorem_ipsum_store ( store_wrt, NUM_DOCS , compressor, blocksize ) ;
147
153
let field_title = schema. get_field ( "title" ) . unwrap ( ) ;
148
154
let store_file = directory. open_read ( path) ?;
149
155
let store = StoreReader :: open ( store_file) ?;
@@ -169,22 +175,28 @@ pub mod tests {
169
175
170
176
#[ test]
171
177
fn test_store_noop ( ) -> crate :: Result < ( ) > {
172
- test_store ( Compressor :: None )
178
+ test_store ( Compressor :: None , BLOCK_SIZE )
173
179
}
174
180
#[ cfg( feature = "lz4-compression" ) ]
175
181
#[ test]
176
182
fn test_store_lz4_block ( ) -> crate :: Result < ( ) > {
177
- test_store ( Compressor :: Lz4 )
183
+ test_store ( Compressor :: Lz4 , BLOCK_SIZE )
178
184
}
179
185
#[ cfg( feature = "snappy-compression" ) ]
180
186
#[ test]
181
187
fn test_store_snap ( ) -> crate :: Result < ( ) > {
182
- test_store ( Compressor :: Snappy )
188
+ test_store ( Compressor :: Snappy , BLOCK_SIZE )
183
189
}
184
190
#[ cfg( feature = "brotli-compression" ) ]
185
191
#[ test]
186
192
fn test_store_brotli ( ) -> crate :: Result < ( ) > {
187
- test_store ( Compressor :: Brotli )
193
+ test_store ( Compressor :: Brotli , BLOCK_SIZE )
194
+ }
195
+
196
+ #[ cfg( feature = "zstd-compression" ) ]
197
+ #[ test]
198
+ fn test_store_zstd ( ) -> crate :: Result < ( ) > {
199
+ test_store ( Compressor :: Zstd , BLOCK_SIZE )
188
200
}
189
201
190
202
#[ test]
@@ -348,6 +360,7 @@ mod bench {
348
360
directory. open_write ( path) . unwrap ( ) ,
349
361
1_000 ,
350
362
Compressor :: default ( ) ,
363
+ 16_384 ,
351
364
) ;
352
365
directory. delete ( path) . unwrap ( ) ;
353
366
} ) ;
@@ -361,6 +374,7 @@ mod bench {
361
374
directory. open_write ( path) . unwrap ( ) ,
362
375
1_000 ,
363
376
Compressor :: default ( ) ,
377
+ 16_384 ,
364
378
) ;
365
379
let store_file = directory. open_read ( path) . unwrap ( ) ;
366
380
let store = StoreReader :: open ( store_file) . unwrap ( ) ;
0 commit comments