mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-27 07:14:26 +01:00
Move the IndexDocuments update into its own module
This commit is contained in:
parent
8f76ec97c0
commit
5c62fbb6a8
33
src/update/index_documents/mod.rs
Normal file
33
src/update/index_documents/mod.rs
Normal file
@ -0,0 +1,33 @@
|
||||
use crate::Index;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub enum IndexDocumentsMethod {
|
||||
/// Replace the previous document with the new one,
|
||||
/// removing all the already known attributes.
|
||||
ReplaceDocuments,
|
||||
|
||||
/// Merge the previous version of the document with the new version,
|
||||
/// replacing old attributes values with the new ones and add the new attributes.
|
||||
UpdateDocuments,
|
||||
}
|
||||
|
||||
pub struct IndexDocuments<'t, 'u, 'i> {
|
||||
wtxn: &'t mut heed::RwTxn<'u>,
|
||||
index: &'i Index,
|
||||
update_method: IndexDocumentsMethod,
|
||||
}
|
||||
|
||||
impl<'t, 'u, 'i> IndexDocuments<'t, 'u, 'i> {
|
||||
pub fn new(wtxn: &'t mut heed::RwTxn<'u>, index: &'i Index) -> IndexDocuments<'t, 'u, 'i> {
|
||||
IndexDocuments { wtxn, index, update_method: IndexDocumentsMethod::ReplaceDocuments }
|
||||
}
|
||||
|
||||
pub fn index_documents_method(&mut self, method: IndexDocumentsMethod) -> &mut Self {
|
||||
self.update_method = method;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn execute(self) -> anyhow::Result<()> {
|
||||
todo!()
|
||||
}
|
||||
}
|
@ -1,11 +1,13 @@
|
||||
mod available_documents_ids;
|
||||
mod clear_documents;
|
||||
mod delete_documents;
|
||||
mod index_documents;
|
||||
mod update_builder;
|
||||
mod update_store;
|
||||
|
||||
pub use self::available_documents_ids::AvailableDocumentsIds;
|
||||
pub use self::clear_documents::ClearDocuments;
|
||||
pub use self::delete_documents::DeleteDocuments;
|
||||
pub use self::index_documents::{IndexDocuments, IndexDocumentsMethod};
|
||||
pub use self::update_builder::UpdateBuilder;
|
||||
pub use self::update_store::UpdateStore;
|
||||
|
@ -9,6 +9,7 @@ use roaring::RoaringBitmap;
|
||||
use crate::{Index, BEU32};
|
||||
use super::clear_documents::ClearDocuments;
|
||||
use super::delete_documents::DeleteDocuments;
|
||||
use super::index_documents::IndexDocuments;
|
||||
|
||||
pub struct UpdateBuilder {
|
||||
log_every_n: usize,
|
||||
@ -99,34 +100,3 @@ impl UpdateBuilder {
|
||||
IndexDocuments::new(wtxn, index)
|
||||
}
|
||||
}
|
||||
|
||||
pub enum IndexDocumentsMethod {
|
||||
/// Replace the previous document with the new one,
|
||||
/// removing all the already known attributes.
|
||||
ReplaceDocuments,
|
||||
|
||||
/// Merge the previous version of the document with the new version,
|
||||
/// replacing old attributes values with the new ones and add the new attributes.
|
||||
UpdateDocuments,
|
||||
}
|
||||
|
||||
pub struct IndexDocuments<'t, 'u, 'i> {
|
||||
wtxn: &'t mut heed::RwTxn<'u>,
|
||||
index: &'i Index,
|
||||
update_method: IndexDocumentsMethod,
|
||||
}
|
||||
|
||||
impl<'t, 'u, 'i> IndexDocuments<'t, 'u, 'i> {
|
||||
fn new(wtxn: &'t mut heed::RwTxn<'u>, index: &'i Index) -> IndexDocuments<'t, 'u, 'i> {
|
||||
IndexDocuments { wtxn, index, update_method: IndexDocumentsMethod::ReplaceDocuments }
|
||||
}
|
||||
|
||||
pub fn index_documents_method(&mut self, method: IndexDocumentsMethod) -> &mut Self {
|
||||
self.update_method = method;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn execute(self) -> anyhow::Result<()> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user