architecture rework

This commit is contained in:
mpostma
2021-01-28 14:12:34 +01:00
parent 6a3f625e11
commit 74410d8c6b
14 changed files with 1065 additions and 310 deletions

View File

@ -1,15 +1,12 @@
use std::ops::Deref;
use milli::update::{IndexDocumentsMethod, UpdateFormat};
//use milli::update_store::UpdateStatus;
use async_compression::tokio_02::write::GzipEncoder;
use futures_util::stream::StreamExt;
use tokio::io::AsyncWriteExt;
use super::Data;
use crate::index_controller::IndexController;
use crate::index_controller::{UpdateStatusResponse, Settings};
use crate::index_controller::{IndexController, UpdateStatusResponse, Settings};
impl Data {
pub async fn add_documents<B, E, S>(
@ -39,8 +36,8 @@ impl Data {
let file = file.into_std().await;
let mmap = unsafe { memmap::Mmap::map(&file)? };
let indexes = self.indexes.clone();
let update = tokio::task::spawn_blocking(move ||indexes.add_documents(index, method, format, &mmap[..])).await??;
let index_controller = self.index_controller.clone();
let update = tokio::task::spawn_blocking(move ||index_controller.add_documents(index, method, format, &mmap[..])).await??;
Ok(update.into())
}
@ -49,7 +46,7 @@ impl Data {
index: S,
settings: Settings
) -> anyhow::Result<UpdateStatusResponse> {
let indexes = self.indexes.clone();
let indexes = self.index_controller.clone();
let update = tokio::task::spawn_blocking(move || indexes.update_settings(index, settings)).await??;
Ok(update.into())
}