fix: Prefer using a reliable SipHash to compute document ids

This commit is contained in:
Clément Renault 2019-06-22 11:22:21 +02:00
parent 25a5605b35
commit 15646c258b
No known key found for this signature in database
GPG Key ID: 0151CDAB43460DAE
2 changed files with 6 additions and 6 deletions

View File

@ -10,12 +10,13 @@ bincode = "1.1.2"
deunicode = "1.0.0" deunicode = "1.0.0"
hashbrown = { version = "0.2.2", features = ["serde"] } hashbrown = { version = "0.2.2", features = ["serde"] }
meilidb-core = { path = "../meilidb-core", version = "0.1.0" } 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-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"] } ordered-float = { version = "1.0.2", features = ["serde"] }
rocksdb = { version = "0.12.2", default-features = false }
sdset = "0.3.2" sdset = "0.3.2"
serde = { version = "1.0.91", features = ["derive"] } serde = { version = "1.0.91", features = ["derive"] }
rocksdb = { version = "0.12.2", default-features = false } siphasher = "0.3.0"
zerocopy = "0.2.2" zerocopy = "0.2.2"
[dependencies.rmp-serde] [dependencies.rmp-serde]

View File

@ -1,9 +1,8 @@
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher}; use std::hash::{Hash, Hasher};
use meilidb_core::DocumentId; use meilidb_core::DocumentId;
use serde::Serialize; use serde::{ser, Serialize};
use serde::ser; use siphasher::sip::SipHasher;
use super::{SerializerError, ConvertToString}; use super::{SerializerError, ConvertToString};
@ -18,7 +17,7 @@ where D: serde::Serialize,
} }
fn calculate_hash<T: Hash>(t: &T) -> u64 { fn calculate_hash<T: Hash>(t: &T) -> u64 {
let mut s = DefaultHasher::new(); let mut s = SipHasher::new();
t.hash(&mut s); t.hash(&mut s);
s.finish() s.finish()
} }