-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #424 from weibocom/dev_support_fnv1_and_new_ketama
支持新hash、dist
- Loading branch information
Showing
10 changed files
with
587 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/// 按需支持fnv1系列所有相关的hash算法,目前支持fnv1a_64 | ||
#[derive(Debug, Default, Clone)] | ||
pub struct Fnv1aF64; | ||
|
||
const FNV_64_INIT: u64 = 0xcbf29ce484222325; | ||
const FNV_64_PRIME: u64 = 0x100000001b3; | ||
|
||
impl super::Hash for Fnv1aF64 { | ||
fn hash<S: crate::HashKey>(&self, key: &S) -> i64 { | ||
let mut hash = FNV_64_INIT as u32; | ||
for i in 0..key.len() { | ||
hash ^= key.at(i) as u32; | ||
hash = hash.wrapping_mul(FNV_64_PRIME as u32); | ||
} | ||
|
||
hash as i64 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.