Skip to content

Commit 5f0f0a7

Browse files
committed
Fix compilation errors and warnings (DB::scan, imports)
1 parent 8732955 commit 5f0f0a7

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

src/db.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use serde_json::Value;
55
use std::collections::HashMap;
66
use std::fs;
77
use std::iter::Peekable;
8-
use std::path::{Path, PathBuf};
8+
use std::path::PathBuf;
99
use uuid::Uuid;
1010

1111
fn 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

src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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 {}",

src/query.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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);

0 commit comments

Comments
 (0)