From a8006a3750f7dc3153302a6ce0496383f837311a Mon Sep 17 00:00:00 2001 From: ManyTheFish Date: Thu, 16 Jan 2025 18:05:29 +0100 Subject: [PATCH] Change format of update file when importing dump --- crates/index-scheduler/src/dump.rs | 13 +++++++++---- crates/meilitool/src/main.rs | 1 - 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/index-scheduler/src/dump.rs b/crates/index-scheduler/src/dump.rs index ed3bb7c12..aaf4d83e3 100644 --- a/crates/index-scheduler/src/dump.rs +++ b/crates/index-scheduler/src/dump.rs @@ -1,7 +1,9 @@ use std::collections::HashMap; +use std::io; use dump::{KindDump, TaskDump, UpdateFile}; use meilisearch_types::heed::RwTxn; +use meilisearch_types::milli; use meilisearch_types::milli::documents::DocumentsBatchBuilder; use meilisearch_types::tasks::{Kind, KindWithContent, Status, Task}; use roaring::RoaringBitmap; @@ -43,12 +45,15 @@ impl<'a> Dump<'a> { let content_uuid = match content_file { Some(content_file) if task.status == Status::Enqueued => { - let (uuid, mut file) = self.index_scheduler.queue.create_update_file(false)?; - let mut builder = DocumentsBatchBuilder::new(&mut file); + let (uuid, file) = self.index_scheduler.queue.create_update_file(false)?; + let mut writer = io::BufWriter::new(file); for doc in content_file { - builder.append_json_object(&doc?)?; + let doc = doc?; + serde_json::to_writer(&mut writer, &doc).map_err(|e| { + Error::from_milli(milli::InternalError::SerdeJson(e).into(), None) + })?; } - builder.into_inner()?; + let file = writer.into_inner().map_err(|e| e.into_error())?; file.persist()?; Some(uuid) diff --git a/crates/meilitool/src/main.rs b/crates/meilitool/src/main.rs index 053e83b96..0f7702f9d 100644 --- a/crates/meilitool/src/main.rs +++ b/crates/meilitool/src/main.rs @@ -9,7 +9,6 @@ use file_store::FileStore; use meilisearch_auth::AuthController; use meilisearch_types::heed::types::{SerdeJson, Str}; use meilisearch_types::heed::{Database, Env, EnvOpenOptions, RoTxn, RwTxn, Unspecified}; -use meilisearch_types::milli::documents::{obkv_to_object, DocumentsBatchReader}; use meilisearch_types::milli::{obkv_to_json, BEU32}; use meilisearch_types::tasks::{Status, Task}; use meilisearch_types::versioning::{get_version, parse_version};