From 663714bb6df76fb87af41c37a883846f13b792d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Wed, 9 Oct 2019 13:48:33 +0200 Subject: [PATCH] Make the example return documents field in a consistent order --- meilidb-core/Cargo.toml | 1 + meilidb-core/examples/from_file.rs | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/meilidb-core/Cargo.toml b/meilidb-core/Cargo.toml index cec7b2b6e..0a18edb73 100644 --- a/meilidb-core/Cargo.toml +++ b/meilidb-core/Cargo.toml @@ -47,6 +47,7 @@ branch = "arc-byte-slice" [dev-dependencies] assert_matches = "1.3" csv = "1.0.7" +indexmap = { version = "1.2.0", features = ["serde-1"] } rustyline = { version = "5.0.0", default-features = false } structopt = "0.3.2" tempfile = "3.1.0" diff --git a/meilidb-core/examples/from_file.rs b/meilidb-core/examples/from_file.rs index e98cfcb78..f0fbc61be 100644 --- a/meilidb-core/examples/from_file.rs +++ b/meilidb-core/examples/from_file.rs @@ -1,5 +1,5 @@ use std::collections::btree_map::{BTreeMap, Entry}; -use std::collections::{HashMap, HashSet}; +use std::collections::HashSet; use std::error::Error; use std::io::Write; use std::iter::FromIterator; @@ -74,7 +74,7 @@ impl Command { #[derive(Serialize, Deserialize)] #[serde(transparent)] -struct Document(HashMap); +struct Document(indexmap::IndexMap); fn index_command(command: IndexCommand, database: Database) -> Result<(), Box> { let start = Instant::now(); @@ -316,7 +316,7 @@ fn search_command(command: SearchCommand, database: Database) -> Result<(), Box< println!(); } - eprintln!("document field retrieve took {:.2?}", retrieve_duration); + eprintln!("whole documents fields retrieve took {:.2?}", retrieve_duration); eprintln!("===== Found {} results in {:.2?} =====", number_of_documents, start_total.elapsed()); }, Err(err) => {