This commit is contained in:
marin postma 2021-06-17 14:38:52 +02:00
parent abdf642d68
commit fa573dabf0
No known key found for this signature in database
GPG Key ID: 6088B7721C3E39F9
10 changed files with 19 additions and 18 deletions

View File

@ -177,7 +177,7 @@ impl ErrorCode for MilliError<'_> {
UserError::PrimaryKeyCannotBeReset => Code::PrimaryKeyAlreadyPresent, UserError::PrimaryKeyCannotBeReset => Code::PrimaryKeyAlreadyPresent,
UserError::UnknownInternalDocumentId { .. } => Code::DocumentNotFound, UserError::UnknownInternalDocumentId { .. } => Code::DocumentNotFound,
} }
}, }
} }
} }
} }

View File

@ -20,8 +20,7 @@ pub enum IndexError {
} }
internal_error!( internal_error!(
IndexError: IndexError: std::io::Error,
std::io::Error,
heed::Error, heed::Error,
fst::Error, fst::Error,
serde_json::Error serde_json::Error

View File

@ -190,9 +190,7 @@ impl Index {
if fields.iter().all(|f| f != "*") { if fields.iter().all(|f| f != "*") {
facet_distribution.facets(fields); facet_distribution.facets(fields);
} }
let distribution = facet_distribution let distribution = facet_distribution.candidates(candidates).execute()?;
.candidates(candidates)
.execute()?;
Some(distribution) Some(distribution)
} }
@ -532,7 +530,7 @@ fn parse_filter(facets: &Value, index: &Index, txn: &RoTxn) -> Result<Option<Fil
Ok(Some(condition)) Ok(Some(condition))
} }
Value::Array(arr) => parse_filter_array(txn, index, arr), Value::Array(arr) => parse_filter_array(txn, index, arr),
v => return Err(FacetError::InvalidExpression(&["Array"], v.clone()).into()), v => Err(FacetError::InvalidExpression(&["Array"], v.clone()).into()),
} }
} }

View File

@ -219,7 +219,9 @@ impl Index {
let gzipped = false; let gzipped = false;
let addition = match content { let addition = match content {
Some(content) if gzipped => builder.execute(GzDecoder::new(content), indexing_callback)?, Some(content) if gzipped => {
builder.execute(GzDecoder::new(content), indexing_callback)?
}
Some(content) => builder.execute(content, indexing_callback)?, Some(content) => builder.execute(content, indexing_callback)?,
None => builder.execute(std::io::empty(), indexing_callback)?, None => builder.execute(std::io::empty(), indexing_callback)?,
}; };
@ -297,7 +299,9 @@ impl Index {
} }
} }
builder.execute(|indexing_step, update_id| info!("update {}: {:?}", update_id, indexing_step))?; builder.execute(|indexing_step, update_id| {
info!("update {}: {:?}", update_id, indexing_step)
})?;
Ok(UpdateResult::Other) Ok(UpdateResult::Other)
} }

View File

@ -141,9 +141,11 @@ mod test {
use super::*; use super::*;
use crate::index_controller::index_actor::MockIndexActorHandle; use crate::index_controller::index_actor::MockIndexActorHandle;
use crate::index_controller::update_actor::{ use crate::index_controller::update_actor::{
MockUpdateActorHandle, UpdateActorHandleImpl, error::UpdateActorError, error::UpdateActorError, MockUpdateActorHandle, UpdateActorHandleImpl,
};
use crate::index_controller::uuid_resolver::{
error::UuidResolverError, MockUuidResolverHandle,
}; };
use crate::index_controller::uuid_resolver::{MockUuidResolverHandle, error::UuidResolverError};
#[actix_rt::test] #[actix_rt::test]
async fn test_normal() { async fn test_normal() {

View File

@ -7,6 +7,7 @@ use crate::index_controller::index_actor::error::IndexActorError;
pub type Result<T> = std::result::Result<T, UpdateActorError>; pub type Result<T> = std::result::Result<T, UpdateActorError>;
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
#[allow(clippy::large_enum_variant)]
pub enum UpdateActorError { pub enum UpdateActorError {
#[error("Update {0} doesn't exist.")] #[error("Update {0} doesn't exist.")]
UnexistingUpdate(u64), UnexistingUpdate(u64),
@ -33,8 +34,7 @@ impl From<tokio::sync::oneshot::error::RecvError> for UpdateActorError {
} }
internal_error!( internal_error!(
UpdateActorError: UpdateActorError: heed::Error,
heed::Error,
std::io::Error, std::io::Error,
serde_json::Error, serde_json::Error,
actix_http::error::PayloadError, actix_http::error::PayloadError,

View File

@ -4,7 +4,7 @@ use log::{info, warn};
use tokio::sync::mpsc; use tokio::sync::mpsc;
use uuid::Uuid; use uuid::Uuid;
use super::{Result, UuidResolveMsg, error::UuidResolverError, UuidStore}; use super::{error::UuidResolverError, Result, UuidResolveMsg, UuidStore};
pub struct UuidResolverActor<S> { pub struct UuidResolverActor<S> {
inbox: mpsc::Receiver<UuidResolveMsg>, inbox: mpsc::Receiver<UuidResolveMsg>,

View File

@ -10,9 +10,9 @@ use std::path::PathBuf;
use uuid::Uuid; use uuid::Uuid;
use actor::UuidResolverActor; use actor::UuidResolverActor;
use error::Result;
use message::UuidResolveMsg; use message::UuidResolveMsg;
use store::UuidStore; use store::UuidStore;
use error::Result;
#[cfg(test)] #[cfg(test)]
use mockall::automock; use mockall::automock;
@ -22,7 +22,6 @@ pub use store::HeedUuidStore;
const UUID_STORE_SIZE: usize = 1_073_741_824; //1GiB const UUID_STORE_SIZE: usize = 1_073_741_824; //1GiB
#[async_trait::async_trait] #[async_trait::async_trait]
#[cfg_attr(test, automock)] #[cfg_attr(test, automock)]
pub trait UuidResolverHandle { pub trait UuidResolverHandle {

View File

@ -8,7 +8,7 @@ use heed::{CompactionOption, Database, Env, EnvOpenOptions};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use uuid::Uuid; use uuid::Uuid;
use super::{Result, error::UuidResolverError, UUID_STORE_SIZE}; use super::{error::UuidResolverError, Result, UUID_STORE_SIZE};
use crate::helpers::EnvSizer; use crate::helpers::EnvSizer;
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]

View File

@ -60,7 +60,6 @@ async fn stats() {
index.wait_update_id(0).await; index.wait_update_id(0).await;
let (response, code) = server.stats().await; let (response, code) = server.stats().await;
assert_eq!(code, 200); assert_eq!(code, 200);