feat: Display the documents fields in the order they were declared

This commit is contained in:
Clément Renault 2019-07-30 15:15:47 +02:00
parent a488c00a2e
commit ebc95cb8f2
2 changed files with 6 additions and 4 deletions

View File

@ -14,6 +14,7 @@ csv = "1.0.7"
diskus = "0.5.0" diskus = "0.5.0"
env_logger = "0.6.1" env_logger = "0.6.1"
jemallocator = "0.1.9" jemallocator = "0.1.9"
linked-hash-map = "0.5.2"
meilidb-core = { path = "../meilidb-core", version = "0.1.0" } meilidb-core = { path = "../meilidb-core", version = "0.1.0" }
quickcheck = "0.8.2" quickcheck = "0.8.2"
rand = "0.6.5" rand = "0.6.5"

View File

@ -2,16 +2,17 @@
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
use std::collections::btree_map::{BTreeMap, Entry}; use std::collections::btree_map::{BTreeMap, Entry};
use std::collections::{HashMap, HashSet}; use std::collections::HashSet;
use std::error::Error; use std::error::Error;
use std::io::{self, Write}; use std::io::{self, Write};
use std::iter::FromIterator; use std::iter::FromIterator;
use std::path::PathBuf; use std::path::PathBuf;
use std::time::{Instant, Duration}; use std::time::{Instant, Duration};
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; use linked_hash_map::LinkedHashMap;
use structopt::StructOpt;
use rustyline::{Editor, Config}; use rustyline::{Editor, Config};
use structopt::StructOpt;
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
use meilidb_core::Highlight; use meilidb_core::Highlight;
use meilidb_data::Database; use meilidb_data::Database;
@ -35,7 +36,7 @@ pub struct Opt {
pub char_context: usize, pub char_context: usize,
} }
type Document = HashMap<String, String>; type Document = LinkedHashMap<String, String>;
fn display_highlights(text: &str, ranges: &[usize]) -> io::Result<()> { fn display_highlights(text: &str, ranges: &[usize]) -> io::Result<()> {
let mut stdout = StandardStream::stdout(ColorChoice::Always); let mut stdout = StandardStream::stdout(ColorChoice::Always);