File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ use serde_json::Value;
55use std:: collections:: HashMap ;
66use std:: fs;
77use std:: iter:: Peekable ;
8- use std:: path:: { Path , PathBuf } ;
8+ use std:: path:: PathBuf ;
99use uuid:: Uuid ;
1010
1111fn sanitize_filename ( name : & str ) -> String {
@@ -257,8 +257,12 @@ impl DB {
257257 self . get_collection ( collection) . update ( id, doc) ;
258258 }
259259
260- pub fn scan ( & mut self , collection : & str ) -> impl Iterator < Item = ( String , Value ) > + ' _ {
261- self . get_collection ( collection) . scan ( )
260+ pub fn scan ( & self , collection : & str ) -> Box < dyn Iterator < Item = ( String , Value ) > + ' _ > {
261+ if let Some ( col) = self . collections . get ( collection) {
262+ Box :: new ( col. scan ( ) )
263+ } else {
264+ Box :: new ( std:: iter:: empty ( ) )
265+ }
262266 }
263267}
264268
Original file line number Diff line number Diff line change @@ -113,12 +113,12 @@ impl SimpleQueryHandler for ArgusHandler {
113113
114114 match stmt {
115115 Statement :: Insert {
116- collection : _ ,
116+ collection,
117117 documents,
118118 } => {
119119 let count = documents. len ( ) ;
120120 for doc in documents {
121- db. insert ( doc) ;
121+ db. insert ( & collection , doc) ;
122122 }
123123 Ok ( vec ! [ Response :: Execution ( Tag :: new( & format!(
124124 "INSERT 0 {}" ,
Original file line number Diff line number Diff line change @@ -313,9 +313,9 @@ pub fn execute_plan<'a>(
313313 db : & ' a DB ,
314314) -> Box < dyn Iterator < Item = ( String , Value ) > + ' a > {
315315 match plan {
316- LogicalPlan :: Scan { .. } => {
317- let iter = db. scan ( ) ;
318- Box :: new ( ScanOperator :: new ( Box :: new ( iter) ) )
316+ LogicalPlan :: Scan { collection } => {
317+ let iter = db. scan ( & collection ) ;
318+ Box :: new ( ScanOperator :: new ( iter) )
319319 }
320320 LogicalPlan :: Filter { input, predicate } => {
321321 let child = execute_plan ( * input, db) ;
You can’t perform that action at this time.
0 commit comments