From 15646c258bb80476d67158cc790dc4a6ea35103b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Sat, 22 Jun 2019 11:22:21 +0200 Subject: [PATCH] fix: Prefer using a reliable SipHash to compute document ids --- meilidb-data/Cargo.toml | 5 +++-- meilidb-data/src/serde/extract_document_id.rs | 7 +++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/meilidb-data/Cargo.toml b/meilidb-data/Cargo.toml index 414cec7c7..d50605ef7 100644 --- a/meilidb-data/Cargo.toml +++ b/meilidb-data/Cargo.toml @@ -10,12 +10,13 @@ bincode = "1.1.2" deunicode = "1.0.0" hashbrown = { version = "0.2.2", features = ["serde"] } meilidb-core = { path = "../meilidb-core", version = "0.1.0" } -meilidb-tokenizer = { path = "../meilidb-tokenizer", version = "0.1.0" } meilidb-schema = { path = "../meilidb-schema", version = "0.1.0" } +meilidb-tokenizer = { path = "../meilidb-tokenizer", version = "0.1.0" } ordered-float = { version = "1.0.2", features = ["serde"] } +rocksdb = { version = "0.12.2", default-features = false } sdset = "0.3.2" serde = { version = "1.0.91", features = ["derive"] } -rocksdb = { version = "0.12.2", default-features = false } +siphasher = "0.3.0" zerocopy = "0.2.2" [dependencies.rmp-serde] diff --git a/meilidb-data/src/serde/extract_document_id.rs b/meilidb-data/src/serde/extract_document_id.rs index a67ee1441..990094104 100644 --- a/meilidb-data/src/serde/extract_document_id.rs +++ b/meilidb-data/src/serde/extract_document_id.rs @@ -1,9 +1,8 @@ -use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; use meilidb_core::DocumentId; -use serde::Serialize; -use serde::ser; +use serde::{ser, Serialize}; +use siphasher::sip::SipHasher; use super::{SerializerError, ConvertToString}; @@ -18,7 +17,7 @@ where D: serde::Serialize, } fn calculate_hash(t: &T) -> u64 { - let mut s = DefaultHasher::new(); + let mut s = SipHasher::new(); t.hash(&mut s); s.finish() }