From 87f0d8cf3cecd45f36244344d39621163bb81468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Sun, 3 Feb 2019 12:22:50 +0100 Subject: [PATCH] feat: Remove the hashbrown dependency for library users --- examples/create-database.rs | 2 +- examples/http-server.rs | 16 ++++++---------- src/database/mod.rs | 10 ++++++---- src/database/serde/indexer_serializer.rs | 9 +++++---- src/database/serde/serializer.rs | 3 ++- src/database/update/builder.rs | 2 +- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/examples/create-database.rs b/examples/create-database.rs index 66b488c95..4ba16a2a6 100644 --- a/examples/create-database.rs +++ b/examples/create-database.rs @@ -1,13 +1,13 @@ #[global_allocator] static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; +use std::collections::{HashMap, HashSet}; use std::io::{self, BufRead, BufReader}; use std::path::{Path, PathBuf}; use std::error::Error; use std::borrow::Cow; use std::fs::File; -use hashbrown::{HashMap, HashSet}; use serde_derive::{Serialize, Deserialize}; use structopt::StructOpt; diff --git a/examples/http-server.rs b/examples/http-server.rs index 61859a5dc..315c813ac 100644 --- a/examples/http-server.rs +++ b/examples/http-server.rs @@ -1,7 +1,7 @@ #[global_allocator] static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; -use log::{error, info}; +use std::collections::{HashMap, HashSet}; use std::error::Error; use std::ffi::OsStr; use std::fmt; @@ -12,19 +12,15 @@ use std::path::{PathBuf, Path}; use std::sync::Arc; use std::time::SystemTime; -use hashbrown::{HashMap, HashSet}; -use chashmap::CHashMap; -use chashmap::ReadGuard; +use chashmap::{CHashMap, ReadGuard}; use elapsed::measure_time; -use meilidb::database::Database; -use meilidb::database::UpdateBuilder; -use meilidb::database::schema::Schema; -use meilidb::database::schema::SchemaBuilder; +use meilidb::database::{Database, UpdateBuilder}; +use meilidb::database::schema::{Schema, SchemaBuilder}; use meilidb::tokenizer::DefaultBuilder; -use serde_derive::Deserialize; -use serde_derive::Serialize; +use serde_derive::{Serialize, Deserialize}; use structopt::StructOpt; use warp::{Rejection, Filter}; +use log::{error, info}; #[derive(Debug, StructOpt)] pub struct Opt { diff --git a/src/database/mod.rs b/src/database/mod.rs index e9b567171..4bfaeaa4a 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -189,17 +189,18 @@ impl Database { #[cfg(test)] mod tests { - use super::*; + use std::collections::HashSet; use std::error::Error; use serde_derive::{Serialize, Deserialize}; - use hashbrown::HashSet; use tempfile::tempdir; use crate::database::schema::{SchemaBuilder, STORED, INDEXED}; use crate::database::update::UpdateBuilder; use crate::tokenizer::DefaultBuilder; + use super::*; + #[test] fn ingest_one_update_file() -> Result<(), Box> { let dir = tempdir()?; @@ -367,7 +368,7 @@ mod tests { mod bench { extern crate test; - use super::*; + use std::collections::HashSet; use std::error::Error; use std::iter::repeat_with; use self::test::Bencher; @@ -377,12 +378,13 @@ mod bench { use rand::{Rng, SeedableRng}; use serde_derive::Serialize; use rand::seq::SliceRandom; - use hashbrown::HashSet; use crate::tokenizer::DefaultBuilder; use crate::database::update::UpdateBuilder; use crate::database::schema::*; + use super::*; + fn random_sentences(number: usize, rng: &mut R) -> String { let mut words = String::new(); diff --git a/src/database/serde/indexer_serializer.rs b/src/database/serde/indexer_serializer.rs index 63bb016d8..8055d7856 100644 --- a/src/database/serde/indexer_serializer.rs +++ b/src/database/serde/indexer_serializer.rs @@ -1,3 +1,8 @@ +use std::collections::HashSet; + +use serde::Serialize; +use serde::ser; + use crate::database::update::DocumentUpdate; use crate::database::serde::SerializerError; use crate::database::schema::SchemaAttr; @@ -5,10 +10,6 @@ use crate::tokenizer::TokenizerBuilder; use crate::tokenizer::Token; use crate::{DocumentId, DocIndex}; -use hashbrown::HashSet; -use serde::Serialize; -use serde::ser; - pub struct IndexerSerializer<'a, B> { pub tokenizer_builder: &'a B, pub update: &'a mut DocumentUpdate, diff --git a/src/database/serde/serializer.rs b/src/database/serde/serializer.rs index 0019f4497..79b1d47e1 100644 --- a/src/database/serde/serializer.rs +++ b/src/database/serde/serializer.rs @@ -1,4 +1,5 @@ -use hashbrown::HashSet; +use std::collections::HashSet; + use serde::Serialize; use serde::ser; diff --git a/src/database/update/builder.rs b/src/database/update/builder.rs index bd7f8a567..931d6c56d 100644 --- a/src/database/update/builder.rs +++ b/src/database/update/builder.rs @@ -1,7 +1,7 @@ +use std::collections::HashSet; use std::path::PathBuf; use std::error::Error; -use hashbrown::HashSet; use serde::Serialize; use crate::database::serde::serializer::Serializer;