@@ -32,10 +32,10 @@ use crate::optimizer::rule::normalization::NormalizationRuleImpl;
3232use crate :: parser:: parse_sql;
3333use crate :: planner:: operator:: Operator ;
3434use crate :: planner:: LogicalPlan ;
35- #[ cfg( not( target_arch = "wasm32" ) ) ]
35+ #[ cfg( all ( not( target_arch = "wasm32" ) , feature = "lmdb ") ) ]
3636use crate :: storage:: lmdb:: { LmdbConfig , LmdbStorage } ;
3737use crate :: storage:: memory:: MemoryStorage ;
38- #[ cfg( not( target_arch = "wasm32" ) ) ]
38+ #[ cfg( all ( not( target_arch = "wasm32" ) , feature = "rocksdb ") ) ]
3939use crate :: storage:: rocksdb:: { OptimisticRocksStorage , RocksStorage , StorageConfig } ;
4040use crate :: storage:: { StatisticsMetaCache , Storage , TableCache , Transaction , ViewCache } ;
4141use crate :: types:: tuple:: { SchemaRef , Tuple } ;
@@ -117,9 +117,9 @@ pub struct DataBaseBuilder {
117117 scala_functions : ScalaFunctions ,
118118 table_functions : TableFunctions ,
119119 histogram_buckets : Option < usize > ,
120- #[ cfg( not( target_arch = "wasm32" ) ) ]
120+ #[ cfg( all ( not( target_arch = "wasm32" ) , feature = "rocksdb ") ) ]
121121 storage_config : StorageConfig ,
122- #[ cfg( not( target_arch = "wasm32" ) ) ]
122+ #[ cfg( all ( not( target_arch = "wasm32" ) , feature = "lmdb ") ) ]
123123 lmdb_config : LmdbConfig ,
124124}
125125
@@ -134,9 +134,9 @@ impl DataBaseBuilder {
134134 scala_functions : Default :: default ( ) ,
135135 table_functions : Default :: default ( ) ,
136136 histogram_buckets : None ,
137- #[ cfg( not( target_arch = "wasm32" ) ) ]
137+ #[ cfg( all ( not( target_arch = "wasm32" ) , feature = "rocksdb ") ) ]
138138 storage_config : Default :: default ( ) ,
139- #[ cfg( not( target_arch = "wasm32" ) ) ]
139+ #[ cfg( all ( not( target_arch = "wasm32" ) , feature = "lmdb ") ) ]
140140 lmdb_config : Default :: default ( ) ,
141141 } ;
142142 builder = builder. register_scala_function ( CharLength :: new ( "char_length" . to_lowercase ( ) ) ) ;
@@ -174,29 +174,38 @@ impl DataBaseBuilder {
174174 }
175175
176176 /// Enables or disables RocksDB statistics collection.
177- #[ cfg( not( target_arch = "wasm32" ) ) ]
177+ #[ cfg( all(
178+ not( target_arch = "wasm32" ) ,
179+ any( feature = "rocksdb" , feature = "lmdb" )
180+ ) ) ]
178181 pub fn storage_statistics ( mut self , enable : bool ) -> Self {
179- self . storage_config . enable_statistics = enable;
180- self . lmdb_config . enable_statistics = enable;
182+ #[ cfg( feature = "rocksdb" ) ]
183+ {
184+ self . storage_config . enable_statistics = enable;
185+ }
186+ #[ cfg( feature = "lmdb" ) ]
187+ {
188+ self . lmdb_config . enable_statistics = enable;
189+ }
181190 self
182191 }
183192
184193 /// Sets the LMDB map size in bytes.
185- #[ cfg( not( target_arch = "wasm32" ) ) ]
194+ #[ cfg( all ( not( target_arch = "wasm32" ) , feature = "lmdb ") ) ]
186195 pub fn lmdb_map_size ( mut self , map_size : usize ) -> Self {
187196 self . lmdb_config . map_size = map_size;
188197 self
189198 }
190199
191200 /// Sets the LMDB environment flags.
192- #[ cfg( not( target_arch = "wasm32" ) ) ]
201+ #[ cfg( all ( not( target_arch = "wasm32" ) , feature = "lmdb ") ) ]
193202 pub fn lmdb_flags ( mut self , flags : lmdb:: EnvironmentFlags ) -> Self {
194203 self . lmdb_config . flags = flags;
195204 self
196205 }
197206
198207 /// Enables or disables LMDB `NO_SYNC`.
199- #[ cfg( not( target_arch = "wasm32" ) ) ]
208+ #[ cfg( all ( not( target_arch = "wasm32" ) , feature = "lmdb ") ) ]
200209 pub fn lmdb_no_sync ( mut self , enable : bool ) -> Self {
201210 self . lmdb_config
202211 . flags
@@ -205,14 +214,14 @@ impl DataBaseBuilder {
205214 }
206215
207216 /// Sets the maximum number of LMDB readers.
208- #[ cfg( not( target_arch = "wasm32" ) ) ]
217+ #[ cfg( all ( not( target_arch = "wasm32" ) , feature = "lmdb ") ) ]
209218 pub fn lmdb_max_readers ( mut self , max_readers : u32 ) -> Self {
210219 self . lmdb_config . max_readers = Some ( max_readers) ;
211220 self
212221 }
213222
214223 /// Sets the maximum number of LMDB named databases.
215- #[ cfg( not( target_arch = "wasm32" ) ) ]
224+ #[ cfg( all ( not( target_arch = "wasm32" ) , feature = "lmdb ") ) ]
216225 pub fn lmdb_max_dbs ( mut self , max_dbs : u32 ) -> Self {
217226 self . lmdb_config . max_dbs = Some ( max_dbs) ;
218227 self
@@ -242,7 +251,7 @@ impl DataBaseBuilder {
242251 }
243252
244253 /// Builds a RocksDB-backed database.
245- #[ cfg( not( target_arch = "wasm32" ) ) ]
254+ #[ cfg( all ( not( target_arch = "wasm32" ) , feature = "rocksdb ") ) ]
246255 pub fn build_rocksdb ( self ) -> Result < Database < RocksStorage > , DatabaseError > {
247256 let storage = RocksStorage :: with_config ( self . path , self . storage_config ) ?;
248257
@@ -269,7 +278,7 @@ impl DataBaseBuilder {
269278 }
270279
271280 /// Builds a LMDB-backed database.
272- #[ cfg( not( target_arch = "wasm32" ) ) ]
281+ #[ cfg( all ( not( target_arch = "wasm32" ) , feature = "lmdb ") ) ]
273282 pub fn build_lmdb ( self ) -> Result < Database < LmdbStorage > , DatabaseError > {
274283 let storage = LmdbStorage :: with_config ( self . path , self . lmdb_config ) ?;
275284
@@ -281,9 +290,9 @@ impl DataBaseBuilder {
281290 )
282291 }
283292
284- #[ cfg( not( target_arch = "wasm32" ) ) ]
293+ #[ cfg( all ( not( target_arch = "wasm32" ) , feature = "rocksdb ") ) ]
285294 /// Builds a RocksDB-backed database that uses optimistic transactions.
286- #[ cfg( not( target_arch = "wasm32" ) ) ]
295+ #[ cfg( all ( not( target_arch = "wasm32" ) , feature = "rocksdb ") ) ]
287296 pub fn build_optimistic ( self ) -> Result < Database < OptimisticRocksStorage > , DatabaseError > {
288297 let storage = OptimisticRocksStorage :: with_config ( self . path , self . storage_config ) ?;
289298
0 commit comments