feat: Return the database view for each update

This commit is contained in:
Clément Renault 2018-12-29 21:07:01 +01:00
parent f4b04dfb72
commit 36ef9581aa
No known key found for this signature in database
GPG Key ID: 0151CDAB43460DAE

View File

@ -74,7 +74,7 @@ impl Database {
Ok(Database { db: Mutex::new(db), view }) Ok(Database { db: Mutex::new(db), view })
} }
pub fn ingest_update_file(&self, update: Update) -> Result<(), Box<Error>> { pub fn ingest_update_file(&self, update: Update) -> Result<Arc<DatabaseView<Arc<DB>>>, Box<Error>> {
let snapshot = { let snapshot = {
// We must have a mutex here to ensure that update ingestions and compactions // We must have a mutex here to ensure that update ingestions and compactions
// are done atomatically and in the right order. // are done atomatically and in the right order.
@ -103,9 +103,9 @@ impl Database {
}; };
let view = Arc::new(DatabaseView::new(snapshot)?); let view = Arc::new(DatabaseView::new(snapshot)?);
self.view.set(view); self.view.set(view.clone());
Ok(()) Ok(view)
} }
pub fn get(&self, key: &[u8]) -> Result<Option<DBVector>, Box<Error>> { pub fn get(&self, key: &[u8]) -> Result<Option<DBVector>, Box<Error>> {