fix: Update the DatabaseView to retrieve the index at creation

remove this computation from the QueryBuilder
This commit is contained in:
Clément Renault 2018-12-07 16:20:12 +01:00
parent 7c98771068
commit bec463a61a
No known key found for this signature in database
GPG key ID: 0151CDAB43460DAE
2 changed files with 13 additions and 9 deletions

View file

@ -5,7 +5,9 @@ use rocksdb::rocksdb::{DB, DBVector, Snapshot, SeekKey};
use rocksdb::rocksdb_options::ReadOptions;
use serde::de::DeserializeOwned;
use crate::database::{retrieve_data_schema, DocumentKey, DocumentKeyAttr};
use crate::database::{DocumentKey, DocumentKeyAttr};
use crate::database::{retrieve_data_schema, retrieve_data_index};
use crate::database::blob::positive::PositiveBlob;
use crate::database::deserializer::Deserializer;
use crate::rank::criterion::Criterion;
use crate::database::schema::Schema;
@ -14,19 +16,25 @@ use crate::DocumentId;
pub struct DatabaseView<'a> {
snapshot: Snapshot<&'a DB>,
blob: PositiveBlob,
schema: Schema,
}
impl<'a> DatabaseView<'a> {
pub fn new(snapshot: Snapshot<&'a DB>) -> Result<DatabaseView, Box<Error>> {
let schema = retrieve_data_schema(&snapshot)?;
Ok(DatabaseView { snapshot, schema })
let blob = retrieve_data_index(&snapshot)?;
Ok(DatabaseView { snapshot, blob, schema })
}
pub fn schema(&self) -> &Schema {
&self.schema
}
pub fn blob(&self) -> &PositiveBlob {
&self.blob
}
pub fn into_snapshot(self) -> Snapshot<&'a DB> {
self.snapshot
}