diff --git a/Cargo.lock b/Cargo.lock index cc4de32ab7..3d359683c1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -792,6 +792,7 @@ dependencies = [ "ordered-float 2.8.0", "percent-encoding", "regex", + "siphasher", "snafu", "test_helpers", "time 0.1.0", @@ -3974,6 +3975,12 @@ dependencies = [ "num-traits", ] +[[package]] +name = "siphasher" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "533494a8f9b724d33625ab53c6c4800f7cc445895924a8ef649222dcb76e938b" + [[package]] name = "slab" version = "0.4.5" diff --git a/data_types/Cargo.toml b/data_types/Cargo.toml index 484b3ad795..7e6426312f 100644 --- a/data_types/Cargo.toml +++ b/data_types/Cargo.toml @@ -13,6 +13,7 @@ observability_deps = { path = "../observability_deps" } ordered-float = "2" percent-encoding = "2.1.0" regex = "1.4" +siphasher = "0.3" snafu = "0.6" time = { path = "../time" } uuid = { version = "0.8", features = ["v4"] } diff --git a/data_types/src/consistent_hasher.rs b/data_types/src/consistent_hasher.rs index cd2d9ddfe4..30830b34bf 100644 --- a/data_types/src/consistent_hasher.rs +++ b/data_types/src/consistent_hasher.rs @@ -1,6 +1,7 @@ -use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; +use siphasher::sip::SipHasher13; + /// A ConsistentHasher implements a simple consistent hashing mechanism /// that maps a point to the nearest "node" N. /// @@ -47,7 +48,7 @@ where } fn hash(h: H) -> u64 { - let mut hasher = DefaultHasher::new(); + let mut hasher = SipHasher13::new(); h.hash(&mut hasher); hasher.finish() } @@ -86,9 +87,6 @@ where mod tests { use super::*; - #[test] - fn test_roundtrip() {} - #[test] fn test_consistent_hasher() { let ch = ConsistentHasher::new(&[10, 20, 30, 40]);