mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 20:15:07 +08:00
Simplify the IndexDocuments builder creation from the UpdateBuilder
This commit is contained in:
parent
d8ff939409
commit
0ccf4cf785
@ -194,14 +194,14 @@ pub enum UpdateFormat {
|
|||||||
pub struct IndexDocuments<'t, 'u, 'i> {
|
pub struct IndexDocuments<'t, 'u, 'i> {
|
||||||
wtxn: &'t mut heed::RwTxn<'i, 'u>,
|
wtxn: &'t mut heed::RwTxn<'i, 'u>,
|
||||||
index: &'i Index,
|
index: &'i Index,
|
||||||
log_every_n: Option<usize>,
|
pub(crate) log_every_n: Option<usize>,
|
||||||
max_nb_chunks: Option<usize>,
|
pub(crate) max_nb_chunks: Option<usize>,
|
||||||
max_memory: Option<usize>,
|
pub(crate) max_memory: Option<usize>,
|
||||||
linked_hash_map_size: Option<usize>,
|
pub(crate) linked_hash_map_size: Option<usize>,
|
||||||
chunk_compression_type: CompressionType,
|
pub(crate) chunk_compression_type: CompressionType,
|
||||||
chunk_compression_level: Option<u32>,
|
pub(crate) chunk_compression_level: Option<u32>,
|
||||||
chunk_fusing_shrink_size: Option<u64>,
|
pub(crate) chunk_fusing_shrink_size: Option<u64>,
|
||||||
indexing_jobs: Option<usize>,
|
pub(crate) indexing_jobs: Option<usize>,
|
||||||
update_method: IndexDocumentsMethod,
|
update_method: IndexDocumentsMethod,
|
||||||
update_format: UpdateFormat,
|
update_format: UpdateFormat,
|
||||||
autogenerate_docids: bool,
|
autogenerate_docids: bool,
|
||||||
@ -226,64 +226,20 @@ impl<'t, 'u, 'i> IndexDocuments<'t, 'u, 'i> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn log_every_n(&mut self, log_every_n: usize) -> &mut Self {
|
pub fn index_documents_method(&mut self, method: IndexDocumentsMethod) {
|
||||||
self.log_every_n = Some(log_every_n);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn max_nb_chunks(&mut self, max_nb_chunks: usize) -> &mut Self {
|
|
||||||
self.max_nb_chunks = Some(max_nb_chunks);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn max_memory(&mut self, max_memory: usize) -> &mut Self {
|
|
||||||
self.max_memory = Some(max_memory);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn linked_hash_map_size(&mut self, linked_hash_map_size: usize) -> &mut Self {
|
|
||||||
self.linked_hash_map_size = Some(linked_hash_map_size);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn chunk_compression_type(&mut self, chunk_compression_type: CompressionType) -> &mut Self {
|
|
||||||
self.chunk_compression_type = chunk_compression_type;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn chunk_compression_level(&mut self, chunk_compression_level: u32) -> &mut Self {
|
|
||||||
self.chunk_compression_level = Some(chunk_compression_level);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn chunk_fusing_shrink_size(&mut self, chunk_fusing_shrink_size: u64) -> &mut Self {
|
|
||||||
self.chunk_fusing_shrink_size = Some(chunk_fusing_shrink_size);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn indexing_jobs(&mut self, indexing_jobs: usize) -> &mut Self {
|
|
||||||
self.indexing_jobs = Some(indexing_jobs);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn index_documents_method(&mut self, method: IndexDocumentsMethod) -> &mut Self {
|
|
||||||
self.update_method = method;
|
self.update_method = method;
|
||||||
self
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_format(&mut self, format: UpdateFormat) -> &mut Self {
|
pub fn update_format(&mut self, format: UpdateFormat) {
|
||||||
self.update_format = format;
|
self.update_format = format;
|
||||||
self
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn enable_autogenerate_docids(&mut self) -> &mut Self {
|
pub fn enable_autogenerate_docids(&mut self) {
|
||||||
self.autogenerate_docids = true;
|
self.autogenerate_docids = true;
|
||||||
self
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn disable_autogenerate_docids(&mut self) -> &mut Self {
|
pub fn disable_autogenerate_docids(&mut self) {
|
||||||
self.autogenerate_docids = false;
|
self.autogenerate_docids = false;
|
||||||
self
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn execute<R, F>(self, reader: R, progress_callback: F) -> anyhow::Result<()>
|
pub fn execute<R, F>(self, reader: R, progress_callback: F) -> anyhow::Result<()>
|
||||||
|
@ -30,44 +30,36 @@ impl UpdateBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn log_every_n(&mut self, log_every_n: usize) -> &mut Self {
|
pub fn log_every_n(&mut self, log_every_n: usize) {
|
||||||
self.log_every_n = Some(log_every_n);
|
self.log_every_n = Some(log_every_n);
|
||||||
self
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn max_nb_chunks(&mut self, max_nb_chunks: usize) -> &mut Self {
|
pub fn max_nb_chunks(&mut self, max_nb_chunks: usize) {
|
||||||
self.max_nb_chunks = Some(max_nb_chunks);
|
self.max_nb_chunks = Some(max_nb_chunks);
|
||||||
self
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn max_memory(&mut self, max_memory: usize) -> &mut Self {
|
pub fn max_memory(&mut self, max_memory: usize) {
|
||||||
self.max_memory = Some(max_memory);
|
self.max_memory = Some(max_memory);
|
||||||
self
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn linked_hash_map_size(&mut self, linked_hash_map_size: usize) -> &mut Self {
|
pub fn linked_hash_map_size(&mut self, linked_hash_map_size: usize) {
|
||||||
self.linked_hash_map_size = Some(linked_hash_map_size);
|
self.linked_hash_map_size = Some(linked_hash_map_size);
|
||||||
self
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn chunk_compression_type(&mut self, chunk_compression_type: CompressionType) -> &mut Self {
|
pub fn chunk_compression_type(&mut self, chunk_compression_type: CompressionType) {
|
||||||
self.chunk_compression_type = chunk_compression_type;
|
self.chunk_compression_type = chunk_compression_type;
|
||||||
self
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn chunk_compression_level(&mut self, chunk_compression_level: u32) -> &mut Self {
|
pub fn chunk_compression_level(&mut self, chunk_compression_level: u32) {
|
||||||
self.chunk_compression_level = Some(chunk_compression_level);
|
self.chunk_compression_level = Some(chunk_compression_level);
|
||||||
self
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn chunk_fusing_shrink_size(&mut self, chunk_fusing_shrink_size: u64) -> &mut Self {
|
pub fn chunk_fusing_shrink_size(&mut self, chunk_fusing_shrink_size: u64) {
|
||||||
self.chunk_fusing_shrink_size = Some(chunk_fusing_shrink_size);
|
self.chunk_fusing_shrink_size = Some(chunk_fusing_shrink_size);
|
||||||
self
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn indexing_jobs(&mut self, indexing_jobs: usize) -> &mut Self {
|
pub fn indexing_jobs(&mut self, indexing_jobs: usize) {
|
||||||
self.indexing_jobs = Some(indexing_jobs);
|
self.indexing_jobs = Some(indexing_jobs);
|
||||||
self
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clear_documents<'t, 'u, 'i>(
|
pub fn clear_documents<'t, 'u, 'i>(
|
||||||
@ -96,30 +88,14 @@ impl UpdateBuilder {
|
|||||||
{
|
{
|
||||||
let mut builder = IndexDocuments::new(wtxn, index);
|
let mut builder = IndexDocuments::new(wtxn, index);
|
||||||
|
|
||||||
if let Some(log_every_n) = self.log_every_n {
|
builder.log_every_n = self.log_every_n;
|
||||||
builder.log_every_n(log_every_n);
|
builder.max_nb_chunks = self.max_nb_chunks;
|
||||||
}
|
builder.max_memory = self.max_memory;
|
||||||
if let Some(max_nb_chunks) = self.max_nb_chunks {
|
builder.linked_hash_map_size = self.linked_hash_map_size;
|
||||||
builder.max_nb_chunks(max_nb_chunks);
|
builder.chunk_compression_type = self.chunk_compression_type;
|
||||||
}
|
builder.chunk_compression_level = self.chunk_compression_level;
|
||||||
if let Some(max_memory) = self.max_memory {
|
builder.chunk_fusing_shrink_size = self.chunk_fusing_shrink_size;
|
||||||
builder.max_memory(max_memory);
|
builder.indexing_jobs = self.indexing_jobs;
|
||||||
}
|
|
||||||
if let Some(linked_hash_map_size) = self.linked_hash_map_size {
|
|
||||||
builder.linked_hash_map_size(linked_hash_map_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.chunk_compression_type(self.chunk_compression_type);
|
|
||||||
|
|
||||||
if let Some(chunk_compression_level) = self.chunk_compression_level {
|
|
||||||
builder.chunk_compression_level(chunk_compression_level);
|
|
||||||
}
|
|
||||||
if let Some(chunk_fusing_shrink_size) = self.chunk_fusing_shrink_size {
|
|
||||||
builder.chunk_fusing_shrink_size(chunk_fusing_shrink_size);
|
|
||||||
}
|
|
||||||
if let Some(indexing_jobs) = self.indexing_jobs {
|
|
||||||
builder.indexing_jobs(indexing_jobs);
|
|
||||||
}
|
|
||||||
|
|
||||||
builder
|
builder
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user