ignite_rs/utils.rs
1/// Converts string into Java-like hash code
2pub fn string_to_java_hashcode(value: &str) -> i32 {
3 let mut hash: i32 = 0;
4 for char in value.chars().into_iter() {
5 hash = 31i32.overflowing_mul(hash).0 + char as i32;
6 }
7 hash
8}
9
10pub fn bytes_to_java_hashcode(bytes: &[u8]) -> i32 {
11 let mut hash: i32 = 0;
12 for byte in bytes.iter() {
13 hash = 31i32.overflowing_mul(hash).0 + *byte as i32;
14 }
15 hash
16}