mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 20:15:07 +08:00
fix broken benchmarks
This commit is contained in:
parent
95d1762f19
commit
c52d6d0741
@ -2,11 +2,12 @@
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate assert_matches;
|
extern crate assert_matches;
|
||||||
|
|
||||||
use std::sync::mpsc;
|
use std::error::Error;
|
||||||
use std::path::Path;
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::BufReader;
|
use std::io::BufReader;
|
||||||
use std::iter;
|
use std::iter;
|
||||||
|
use std::path::Path;
|
||||||
|
use std::sync::mpsc;
|
||||||
|
|
||||||
use meilisearch_core::{Database, DatabaseOptions};
|
use meilisearch_core::{Database, DatabaseOptions};
|
||||||
use meilisearch_core::{ProcessedUpdateResult, UpdateStatus};
|
use meilisearch_core::{ProcessedUpdateResult, UpdateStatus};
|
||||||
@ -28,9 +29,10 @@ fn prepare_database(path: &Path) -> Database {
|
|||||||
|
|
||||||
database.set_update_callback(Box::new(update_fn));
|
database.set_update_callback(Box::new(update_fn));
|
||||||
|
|
||||||
let mut writer = db.main_write_txn().unwrap();
|
db.main_write::<_, _, Box<dyn Error>>(|writer| {
|
||||||
index.main.put_schema(&mut writer, &Schema::with_primary_key("id")).unwrap();
|
index.main.put_schema(writer, &Schema::with_primary_key("id")).unwrap();
|
||||||
writer.commit().unwrap();
|
Ok(())
|
||||||
|
}).unwrap();
|
||||||
|
|
||||||
let settings_update: SettingsUpdate = {
|
let settings_update: SettingsUpdate = {
|
||||||
let path = concat!(env!("CARGO_MANIFEST_DIR"), "/../datasets/movies/settings.json");
|
let path = concat!(env!("CARGO_MANIFEST_DIR"), "/../datasets/movies/settings.json");
|
||||||
@ -40,9 +42,10 @@ fn prepare_database(path: &Path) -> Database {
|
|||||||
settings.into_update().unwrap()
|
settings.into_update().unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut update_writer = db.update_write_txn().unwrap();
|
db.update_write::<_, _, Box<dyn Error>>(|writer| {
|
||||||
let _update_id = index.settings_update(&mut update_writer, settings_update).unwrap();
|
let _update_id = index.settings_update(writer, settings_update).unwrap();
|
||||||
update_writer.commit().unwrap();
|
Ok(())
|
||||||
|
}).unwrap();
|
||||||
|
|
||||||
let mut additions = index.documents_addition();
|
let mut additions = index.documents_addition();
|
||||||
|
|
||||||
@ -58,9 +61,10 @@ fn prepare_database(path: &Path) -> Database {
|
|||||||
additions.update_document(document);
|
additions.update_document(document);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut update_writer = db.update_write_txn().unwrap();
|
let update_id = db.update_write::<_, _, Box<dyn Error>>(|writer| {
|
||||||
let update_id = additions.finalize(&mut update_writer).unwrap();
|
let update_id = additions.finalize(writer).unwrap();
|
||||||
update_writer.commit().unwrap();
|
Ok(update_id)
|
||||||
|
}).unwrap();
|
||||||
|
|
||||||
// block until the transaction is processed
|
// block until the transaction is processed
|
||||||
let _ = receiver.into_iter().find(|id| *id == update_id);
|
let _ = receiver.into_iter().find(|id| *id == update_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user