Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-core/src/hashing/identity.rs
6940 views
1
use super::*;
2
3
#[derive(Default)]
4
pub struct IdHasher {
5
hash: u64,
6
}
7
8
impl Hasher for IdHasher {
9
fn finish(&self) -> u64 {
10
self.hash
11
}
12
13
fn write(&mut self, _bytes: &[u8]) {
14
unreachable!("IdHasher should only be used for integer keys <= 64 bit precision")
15
}
16
17
fn write_u32(&mut self, i: u32) {
18
self.hash = i as u64;
19
}
20
21
#[inline]
22
fn write_u64(&mut self, i: u64) {
23
self.hash = i;
24
}
25
26
fn write_i32(&mut self, i: i32) {
27
self.hash = i as u64;
28
}
29
30
fn write_i64(&mut self, i: i64) {
31
self.hash = i as u64;
32
}
33
}
34
35
pub type IdBuildHasher = BuildHasherDefault<IdHasher>;
36
37