Skip to content

Commit

Permalink
根据评审意见,为增加区分度,修改bkdrsubh为bkdrsubhat
Browse files Browse the repository at this point in the history
  • Loading branch information
parabala committed Oct 22, 2024
1 parent f9e5b33 commit c0952a5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion sharding/src/hash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl Hasher {
HASH_PADDING => Self::Padding(Default::default()),
"bkdr" => Self::Bkdr(Default::default()),
"bkdrsub" => Self::BkdrsubDelimiter(BkdrsubDelimiter::from('_' as u8)),
"bkdrsubh" => Self::BkdrsubDelimiter(BkdrsubDelimiter::from('^' as u8)),
"bkdrsubhat" => Self::BkdrsubDelimiter(BkdrsubDelimiter::from('^' as u8)),
"bkdrabscrc32" => Self::BkdrAbsCrc32(Default::default()),
"raw" => Self::Raw(Raw::from(Default::default())),
"crc32" => Self::Crc32(Default::default()),
Expand Down
6 changes: 3 additions & 3 deletions tests/src/bkdrsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ fn bkdrsub_one() {
assert_eq!(dist_idx, 905)
}
#[test]
fn bkdrsubh_one() {
let hasher = Hasher::from("bkdrsubh");
fn bkdrsubhat_one() {
let hasher = Hasher::from("bkdrsubhat");

let key1 = "otdn#1042015:carSubBrand^e4ab74c125e9e95edad691ffe9820118";
let hash1 = hasher.hash(&key1.as_bytes());
Expand All @@ -35,7 +35,7 @@ fn bkdrsubh_one() {
let dist = Distribute::from("modrange-8640", &servers);
let dist_idx = dist.index(hash1);

println!("bkdrsubh key:{}, hash:{}, idx:{}", key1, hash1, dist_idx);
println!("bkdrsubhat key:{}, hash:{}, idx:{}", key1, hash1, dist_idx);
assert_eq!(dist_idx, 905)
}
// TODO 临时批量文件的hash、dist校验测试,按需打开
Expand Down
8 changes: 4 additions & 4 deletions tests/src/hash_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,17 @@ mod hash_test {
assert_eq!(hash2, 1108486745);
}
#[test]
fn bkdrsubh() {
let hasher = Hasher::from("bkdrsubh");
fn bkdrsubhat() {
let hasher = Hasher::from("bkdrsubhat");

let key1 = "abc#12345678901234567";
let hash1 = hasher.hash(&key1.as_bytes());
println!("bkdrsubh key:{}, hash:{}", key1, hash1);
println!("bkdrsubhat key:{}, hash:{}", key1, hash1);
assert_eq!(hash1, 1108486745);

let key2 = "abc#12345678901234567^123456";
let hash2 = hasher.hash(&key2.as_bytes());
println!("bkdrsubh key:{}, hash:{}", key2, hash2);
println!("bkdrsubhat key:{}, hash:{}", key2, hash2);
assert_eq!(hash2, 1108486745);
}

Expand Down

0 comments on commit c0952a5

Please sign in to comment.