Add tests on every platform and fix clippy errors

This commit is contained in:
Clémentine Urquizar 2021-03-22 19:17:18 +01:00
parent d34d7cbc37
commit f80ea24d2b
No known key found for this signature in database
GPG key ID: D8E7CC7422E77E1A
11 changed files with 73 additions and 39 deletions

View file

@ -162,7 +162,7 @@ impl Index {
);
for (_id, obkv) in self.documents(&rtxn, documents_ids)? {
let document = make_document(&all_attributes, &fields_ids_map, obkv.clone())?;
let document = make_document(&all_attributes, &fields_ids_map, obkv)?;
let formatted = compute_formatted(
&fields_ids_map,
obkv,

View file

@ -197,7 +197,7 @@ impl<S: IndexStore + Sync + Send> IndexActor<S> {
.map_err(|e| IndexError::Error(e.into()))
}
*self.processing.write().await = Some(meta.index_uuid().clone());
*self.processing.write().await = Some(*meta.index_uuid());
let result = get_result(self, meta, data).await;
*self.processing.write().await = None;

View file

@ -13,16 +13,16 @@ use uuid::Uuid;
use crate::helpers::EnvSizer;
use crate::index_controller::updates::*;
type BEU64 = heed::zerocopy::U64<heed::byteorder::BE>;
type Beu64 = heed::zerocopy::U64<heed::byteorder::BE>;
#[derive(Clone)]
pub struct UpdateStore<M, N, E> {
pub env: Env,
pending_meta: Database<OwnedType<BEU64>, SerdeJson<Enqueued<M>>>,
pending: Database<OwnedType<BEU64>, SerdeJson<PathBuf>>,
processed_meta: Database<OwnedType<BEU64>, SerdeJson<Processed<M, N>>>,
failed_meta: Database<OwnedType<BEU64>, SerdeJson<Failed<M, E>>>,
aborted_meta: Database<OwnedType<BEU64>, SerdeJson<Aborted<M>>>,
pending_meta: Database<OwnedType<Beu64>, SerdeJson<Enqueued<M>>>,
pending: Database<OwnedType<Beu64>, SerdeJson<PathBuf>>,
processed_meta: Database<OwnedType<Beu64>, SerdeJson<Processed<M, N>>>,
failed_meta: Database<OwnedType<Beu64>, SerdeJson<Failed<M, E>>>,
aborted_meta: Database<OwnedType<Beu64>, SerdeJson<Aborted<M>>>,
processing: Arc<RwLock<Option<Processing<M>>>>,
notification_sender: mpsc::Sender<()>,
/// A lock on the update loop. This is meant to prevent a snapshot to occur while an update is
@ -176,7 +176,7 @@ where
// asking for the id and registering it so other update registering
// will be forced to wait for a new write txn.
let update_id = self.new_update_id(&wtxn)?;
let update_key = BEU64::new(update_id);
let update_key = Beu64::new(update_id);
let meta = Enqueued::new(meta, update_id, index_uuid);
self.pending_meta.put(&mut wtxn, &update_key, &meta)?;
@ -295,7 +295,7 @@ where
/// Returns the update associated meta or `None` if the update doesn't exist.
pub fn meta(&self, update_id: u64) -> heed::Result<Option<UpdateStatus<M, N, E>>> {
let rtxn = self.env.read_txn()?;
let key = BEU64::new(update_id);
let key = Beu64::new(update_id);
if let Some(ref meta) = *self.processing.read() {
if meta.id() == update_id {
@ -331,7 +331,7 @@ where
#[allow(dead_code)]
pub fn abort_update(&self, update_id: u64) -> heed::Result<Option<Aborted<M>>> {
let mut wtxn = self.env.write_txn()?;
let key = BEU64::new(update_id);
let key = Beu64::new(update_id);
// We cannot abort an update that is currently being processed.
if self.pending_meta.first(&wtxn)?.map(|(key, _)| key.get()) == Some(update_id) {
@ -369,7 +369,7 @@ where
}
for (id, aborted) in &aborted_updates {
let key = BEU64::new(*id);
let key = Beu64::new(*id);
self.aborted_meta.put(&mut wtxn, &key, &aborted)?;
self.pending_meta.delete(&mut wtxn, &key)?;
self.pending.delete(&mut wtxn, &key)?;

View file

@ -1,5 +1,4 @@
use std::collections::BTreeMap;
use std::iter::FromIterator;
use actix_web::get;
use actix_web::web;
@ -33,7 +32,7 @@ impl From<IndexStats> for IndexStatsResponse {
Self {
number_of_documents: stats.number_of_documents,
is_indexing: stats.is_indexing,
fields_distribution: BTreeMap::from_iter(stats.fields_distribution.into_iter()),
fields_distribution: stats.fields_distribution.into_iter().collect(),
}
}
}