@@ -171,22 +171,22 @@ impl InstanceEnv {
171
171
col_id : ColId ,
172
172
value : & [ u8 ] ,
173
173
) -> Result < u32 , NodesError > {
174
- let stdb = & * self . dbic . db_engine ;
174
+ let db_engine = & * self . dbic . db_engine ;
175
175
let tx = & mut * self . get_tx ( ) ?;
176
176
177
177
// Interpret the `value` using the schema of the column.
178
- let eq_value = & stdb . decode_column ( tx, table_id, col_id, value) ?;
178
+ let eq_value = & db_engine . decode_column ( tx, table_id, col_id, value) ?;
179
179
180
180
// Find all rows in the table where the column data equates to `value`.
181
- let rows_to_delete = stdb
181
+ let rows_to_delete = db_engine
182
182
. iter_by_col_eq_mut ( ctx, tx, table_id, col_id, eq_value) ?
183
183
. map ( |row_ref| row_ref. pointer ( ) )
184
184
// `delete_by_field` only cares about 1 element,
185
185
// so optimize for that.
186
186
. collect :: < SmallVec < [ _ ; 1 ] > > ( ) ;
187
187
188
188
// Delete them and count how many we deleted.
189
- Ok ( stdb . delete ( tx, table_id, rows_to_delete) )
189
+ Ok ( db_engine . delete ( tx, table_id, rows_to_delete) )
190
190
}
191
191
192
192
/// Deletes all rows in the table identified by `table_id`
@@ -196,29 +196,29 @@ impl InstanceEnv {
196
196
/// Returns an error if no rows were deleted.
197
197
#[ tracing:: instrument( skip( self , relation) ) ]
198
198
pub fn delete_by_rel ( & self , table_id : TableId , relation : & [ u8 ] ) -> Result < u32 , NodesError > {
199
- let stdb = & * self . dbic . db_engine ;
199
+ let db_engine = & * self . dbic . db_engine ;
200
200
let tx = & mut * self . get_tx ( ) ?;
201
201
202
202
// Find the row schema using it to decode a vector of product values.
203
- let row_ty = stdb . row_schema_for_table ( tx, table_id) ?;
203
+ let row_ty = db_engine . row_schema_for_table ( tx, table_id) ?;
204
204
// `TableType::delete` cares about a single element
205
205
// so in that case we can avoid the allocation by using `smallvec`.
206
206
let relation = ProductValue :: decode_smallvec ( & row_ty, & mut & * relation) . map_err ( NodesError :: DecodeRow ) ?;
207
207
208
208
// Delete them and return how many we deleted.
209
- Ok ( stdb . delete_by_rel ( tx, table_id, relation) )
209
+ Ok ( db_engine . delete_by_rel ( tx, table_id, relation) )
210
210
}
211
211
212
212
/// Returns the `table_id` associated with the given `table_name`.
213
213
///
214
214
/// Errors with `TableNotFound` if the table does not exist.
215
215
#[ tracing:: instrument( skip_all) ]
216
216
pub fn get_table_id ( & self , table_name : & str ) -> Result < TableId , NodesError > {
217
- let stdb = & * self . dbic . db_engine ;
217
+ let db_engine = & * self . dbic . db_engine ;
218
218
let tx = & mut * self . get_tx ( ) ?;
219
219
220
220
// Query the table id from the name.
221
- let table_id = stdb
221
+ let table_id = db_engine
222
222
. table_id_from_name_mut ( tx, table_name) ?
223
223
. ok_or ( NodesError :: TableNotFound ) ?;
224
224
@@ -244,7 +244,7 @@ impl InstanceEnv {
244
244
index_type : u8 ,
245
245
col_ids : Vec < u8 > ,
246
246
) -> Result < ( ) , NodesError > {
247
- let stdb = & * self . dbic . db_engine ;
247
+ let db_engine = & * self . dbic . db_engine ;
248
248
let tx = & mut * self . get_tx ( ) ?;
249
249
250
250
// TODO(george) This check should probably move towards src/db/index, but right
@@ -264,7 +264,7 @@ impl InstanceEnv {
264
264
. build ( )
265
265
. expect ( "Attempt to create an index with zero columns" ) ;
266
266
267
- let is_unique = stdb . column_constraints ( tx, table_id, & columns) ?. has_unique ( ) ;
267
+ let is_unique = db_engine . column_constraints ( tx, table_id, & columns) ?. has_unique ( ) ;
268
268
269
269
let index = IndexDef {
270
270
columns,
@@ -273,7 +273,7 @@ impl InstanceEnv {
273
273
index_type,
274
274
} ;
275
275
276
- stdb . create_index ( tx, table_id, index) ?;
276
+ db_engine . create_index ( tx, table_id, index) ?;
277
277
278
278
Ok ( ( ) )
279
279
}
@@ -292,23 +292,23 @@ impl InstanceEnv {
292
292
col_id : ColId ,
293
293
value : & [ u8 ] ,
294
294
) -> Result < Vec < Box < [ u8 ] > > , NodesError > {
295
- let stdb = & * self . dbic . db_engine ;
295
+ let db_engine = & * self . dbic . db_engine ;
296
296
let tx = & mut * self . get_tx ( ) ?;
297
297
298
298
// Interpret the `value` using the schema of the column.
299
- let value = & stdb . decode_column ( tx, table_id, col_id, value) ?;
299
+ let value = & db_engine . decode_column ( tx, table_id, col_id, value) ?;
300
300
301
301
// Find all rows in the table where the column data matches `value`.
302
- let chunks = ChunkedWriter :: collect_iter ( stdb . iter_by_col_eq_mut ( ctx, tx, table_id, col_id, value) ?) ;
302
+ let chunks = ChunkedWriter :: collect_iter ( db_engine . iter_by_col_eq_mut ( ctx, tx, table_id, col_id, value) ?) ;
303
303
Ok ( chunks)
304
304
}
305
305
306
306
#[ tracing:: instrument( skip_all) ]
307
307
pub fn iter_chunks ( & self , ctx : & ExecutionContext , table_id : TableId ) -> Result < Vec < Box < [ u8 ] > > , NodesError > {
308
- let stdb = & * self . dbic . db_engine ;
308
+ let db_engine = & * self . dbic . db_engine ;
309
309
let tx = & mut * self . tx . get ( ) ?;
310
310
311
- let chunks = ChunkedWriter :: collect_iter ( stdb . iter_mut ( ctx, tx, table_id) ?) ;
311
+ let chunks = ChunkedWriter :: collect_iter ( db_engine . iter_mut ( ctx, tx, table_id) ?) ;
312
312
Ok ( chunks)
313
313
}
314
314
@@ -345,10 +345,10 @@ impl InstanceEnv {
345
345
}
346
346
}
347
347
348
- let stdb = & self . dbic . db_engine ;
348
+ let db_engine = & self . dbic . db_engine ;
349
349
let tx = & mut * self . tx . get ( ) ?;
350
350
351
- let schema = stdb . schema_for_table_mut ( tx, table_id) ?;
351
+ let schema = db_engine . schema_for_table_mut ( tx, table_id) ?;
352
352
let row_type = schema. get_row_type ( ) ;
353
353
354
354
let filter = filter:: Expr :: from_bytes (
@@ -364,14 +364,14 @@ impl InstanceEnv {
364
364
// TODO(Centril): consider caching from `filter: &[u8] -> query: QueryExpr`.
365
365
let query = QueryExpr :: new ( schema. as_ref ( ) )
366
366
. with_select ( filter_to_column_op ( table_id, filter) )
367
- . optimize ( & |table_id, table_name| stdb . row_count ( table_id, table_name) ) ;
367
+ . optimize ( & |table_id, table_name| db_engine . row_count ( table_id, table_name) ) ;
368
368
369
369
// TODO(Centril): Conditionally dump the `query` to a file and compare against integration test.
370
370
// Invent a system where we can make these kinds of "optimization path tests".
371
371
372
372
let tx: TxMode = tx. into ( ) ;
373
373
// SQL queries can never reference `MemTable`s, so pass in an empty set.
374
- let mut query = build_query ( ctx, stdb , & tx, & query, & mut NoInMemUsed ) ?;
374
+ let mut query = build_query ( ctx, db_engine , & tx, & query, & mut NoInMemUsed ) ?;
375
375
376
376
// write all rows and flush at row boundaries.
377
377
let query_iter = std:: iter:: from_fn ( || query. next ( ) . transpose ( ) ) ;
0 commit comments