-
Notifications
You must be signed in to change notification settings - Fork 479
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Rust]fix hash value to spark_murmur3 (#385)
* fix hash value to spark_murmur3 Signed-off-by: zenghua <[email protected]> * fix clippy Signed-off-by: zenghua <[email protected]> --------- Signed-off-by: zenghua <[email protected]> Co-authored-by: zenghua <[email protected]>
- Loading branch information
Showing
10 changed files
with
739 additions
and
10 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,57 @@ | ||
// SPDX-FileCopyrightText: 2023 LakeSoul Contributors | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
mod hash_tests { | ||
use lakesoul_io::hash_utils::{HashValue, HASH_SEED}; | ||
|
||
#[test] | ||
fn hash_value_test() { | ||
|
||
// let hash = "321".hash_one(HASH_SEED) as i32; | ||
// dbg!(hash); | ||
assert_eq!(1.hash_one(HASH_SEED) as i32, -559580957); | ||
assert_eq!(2.hash_one(HASH_SEED) as i32, 1765031574); | ||
assert_eq!(3.hash_one(HASH_SEED) as i32, -1823081949); | ||
assert_eq!(4.hash_one(HASH_SEED) as i32, -397064898); | ||
|
||
assert_eq!(1u64.hash_one(HASH_SEED) as i32, -1712319331); | ||
assert_eq!(2u64.hash_one(HASH_SEED) as i32, -797927272); | ||
assert_eq!(3u64.hash_one(HASH_SEED) as i32, 519220707); | ||
assert_eq!(4u64.hash_one(HASH_SEED) as i32, 1344313940); | ||
|
||
|
||
assert_eq!(1.0f32.hash_one(HASH_SEED) as i32, -466301895); | ||
assert_eq!(2.0f32.hash_one(HASH_SEED) as i32, 1199227445); | ||
assert_eq!(3.0f32.hash_one(HASH_SEED) as i32, 1710391653); | ||
assert_eq!(4.0f32.hash_one(HASH_SEED) as i32, -1959694433); | ||
|
||
assert_eq!(1.0.hash_one(HASH_SEED) as i32, -460888942); | ||
assert_eq!(2.0.hash_one(HASH_SEED) as i32, -2030303457); | ||
assert_eq!(3.0.hash_one(HASH_SEED) as i32, 1075969934); | ||
assert_eq!(4.0.hash_one(HASH_SEED) as i32, 1290556682); | ||
|
||
assert_eq!("1".hash_one(HASH_SEED) as i32, 1625004744); | ||
assert_eq!("2".hash_one(HASH_SEED) as i32, 870267989); | ||
assert_eq!("3".hash_one(HASH_SEED) as i32, -1756013582); | ||
assert_eq!("4".hash_one(HASH_SEED) as i32, -2142269034); | ||
|
||
assert_eq!("321".hash_one("321".hash_one(HASH_SEED)) as i32, -218318595); | ||
|
||
assert_eq!("12".hash_one("1".hash_one(HASH_SEED)) as i32, 891492135); | ||
|
||
assert_eq!("22".hash_one("2".hash_one(HASH_SEED)) as i32, 1475972200); | ||
|
||
assert_eq!(0.0f32.hash_one(HASH_SEED) as i32, 933211791); | ||
assert_eq!((-0.0f32).hash_one(HASH_SEED) as i32, 933211791); | ||
assert_eq!(0.0.hash_one(HASH_SEED) as i32, -1670924195); | ||
assert_eq!((-0.0).hash_one(HASH_SEED) as i32, -1670924195); | ||
assert_eq!(49u8.hash_one(HASH_SEED) as i32, 766678906); | ||
assert_eq!(49.hash_one(HASH_SEED) as i32, 766678906); | ||
assert_eq!(false.hash_one(HASH_SEED) as i32, 933211791); | ||
|
||
assert_eq!(1065353216.hash_one(HASH_SEED) as i32, -466301895); | ||
|
||
} | ||
|
||
} |
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
Oops, something went wrong.