Merge pull request #162 from meilisearch/trustful-hash

Prefer using a reliable SipHash to compute document ids
This commit is contained in:
Clément Renault 2019-06-22 11:51:52 +02:00 committed by GitHub
commit 71c039db09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -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]

View File

@ -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: Hash>(t: &T) -> u64 {
let mut s = DefaultHasher::new();
let mut s = SipHasher::new();
t.hash(&mut s);
s.finish()
}