fix most of the index module

This commit is contained in:
Tamo 2022-09-07 20:30:33 +02:00 committed by Clément Renault
parent e7b2b9306a
commit fda5ca60bd
No known key found for this signature in database
GPG key ID: 92ADA4E935E71FA4
7 changed files with 45 additions and 19 deletions

View file

@ -4,7 +4,7 @@ use meilisearch_types::error::{Code, ErrorCode};
use meilisearch_types::internal_error;
use serde_json::Value;
use crate::{error::MilliError, update_file_store};
use crate::update_file_store;
pub type Result<T> = std::result::Result<T, IndexError>;
@ -29,6 +29,7 @@ internal_error!(
milli::documents::Error
);
/*
impl ErrorCode for IndexError {
fn error_code(&self) -> Code {
match self {
@ -39,6 +40,7 @@ impl ErrorCode for IndexError {
}
}
}
*/
impl From<milli::UserError> for IndexError {
fn from(error: milli::UserError) -> IndexError {

View file

@ -12,7 +12,6 @@ use milli::{obkv_to_json, FieldDistribution, DEFAULT_VALUES_PER_FACET};
use serde::{Deserialize, Serialize};
use serde_json::{Map, Value};
use time::OffsetDateTime;
use uuid::Uuid;
use crate::index::search::DEFAULT_PAGINATION_MAX_TOTAL_HITS;
@ -298,7 +297,7 @@ impl Index {
}
pub fn size(&self) -> Result<u64> {
self.inner.on_disk_size()
Ok(self.inner.on_disk_size()?)
}
pub fn snapshot(&self, path: impl AsRef<Path>) -> Result<()> {

View file

@ -4,7 +4,7 @@ pub use search::{
};
pub use updates::{apply_settings_to_builder, Checked, Facets, Settings, Unchecked};
mod dump;
// mod dump;
pub mod error;
mod search;
pub mod updates;
@ -52,14 +52,15 @@ pub mod test {
pub fn open(
path: impl AsRef<Path>,
name: String,
size: usize,
uuid: Uuid,
update_handler: Arc<IndexerConfig>,
) -> Result<Self> {
let index = Index::open(path, size, uuid, update_handler)?;
let index = Index::open(path, name, size, update_handler)?;
Ok(Self::Real(index))
}
/*
pub fn load_dump(
src: impl AsRef<Path>,
dst: impl AsRef<Path>,
@ -68,13 +69,7 @@ pub mod test {
) -> anyhow::Result<()> {
Index::load_dump(src, dst, size, update_handler)
}
pub fn uuid(&self) -> Uuid {
match self {
MockIndex::Real(index) => index.uuid(),
MockIndex::Mock(m) => unsafe { m.get("uuid").call(()) },
}
}
*/
pub fn stats(&self) -> Result<IndexStats> {
match self {
@ -121,7 +116,7 @@ pub mod test {
}
}
pub fn size(&self) -> u64 {
pub fn size(&self) -> Result<u64> {
match self {
MockIndex::Real(index) => index.size(),
MockIndex::Mock(_) => todo!(),
@ -149,12 +144,14 @@ pub mod test {
}
}
/*
pub fn dump(&self, path: impl AsRef<Path>) -> Result<()> {
match self {
MockIndex::Real(index) => index.dump(path),
MockIndex::Mock(m) => unsafe { m.get("dump").call(path.as_ref()) },
}
}
*/
pub fn update_documents(
&self,