1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//! GPU-accelerated hashing operations.
//!
//! Provides row-wise hashing of [`Table`]s using various algorithms.
//!
//! # Examples
//!
//! ```rust,no_run
//! use cudf::{Column, Table};
//!
//! let col = Column::from_slice(&[1i32, 2, 3]).unwrap();
//! let table = Table::new(vec![col]).unwrap();
//! let hashes = table.hash_murmur3(0).unwrap();
//! assert_eq!(hashes.len(), 3);
//! ```
use crate::column::Column;
use crate::error::{CudfError, Result};
use crate::table::Table;
impl Table {
/// Hash each row using MurmurHash3 (32-bit).
///
/// Returns a `u32` column of hash values.
pub fn hash_murmur3(&self, seed: u32) -> Result<Column> {
let raw =
cudf_cxx::hashing::ffi::hash_murmur3(&self.inner, seed).map_err(CudfError::from_cxx)?;
Ok(Column { inner: raw })
}
/// Hash each row using xxHash64.
///
/// Returns a `u64` column of hash values.
pub fn hash_xxhash64(&self, seed: u64) -> Result<Column> {
let raw = cudf_cxx::hashing::ffi::hash_xxhash64(&self.inner, seed)
.map_err(CudfError::from_cxx)?;
Ok(Column { inner: raw })
}
/// Hash each row using MD5.
///
/// Returns a string column of hex-encoded hash values.
pub fn hash_md5(&self) -> Result<Column> {
let raw = cudf_cxx::hashing::ffi::hash_md5(&self.inner).map_err(CudfError::from_cxx)?;
Ok(Column { inner: raw })
}
/// Hash each row using SHA-256.
///
/// Returns a string column of hex-encoded hash values.
pub fn hash_sha256(&self) -> Result<Column> {
let raw = cudf_cxx::hashing::ffi::hash_sha256(&self.inner).map_err(CudfError::from_cxx)?;
Ok(Column { inner: raw })
}
/// Hash each row using SHA-1.
///
/// Returns a string column of hex-encoded hash values.
pub fn hash_sha1(&self) -> Result<Column> {
let raw = cudf_cxx::hashing::ffi::hash_sha1(&self.inner).map_err(CudfError::from_cxx)?;
Ok(Column { inner: raw })
}
/// Hash each row using SHA-224.
///
/// Returns a string column of hex-encoded hash values.
pub fn hash_sha224(&self) -> Result<Column> {
let raw = cudf_cxx::hashing::ffi::hash_sha224(&self.inner).map_err(CudfError::from_cxx)?;
Ok(Column { inner: raw })
}
/// Hash each row using SHA-384.
///
/// Returns a string column of hex-encoded hash values.
pub fn hash_sha384(&self) -> Result<Column> {
let raw = cudf_cxx::hashing::ffi::hash_sha384(&self.inner).map_err(CudfError::from_cxx)?;
Ok(Column { inner: raw })
}
/// Hash each row using SHA-512.
///
/// Returns a string column of hex-encoded hash values.
pub fn hash_sha512(&self) -> Result<Column> {
let raw = cudf_cxx::hashing::ffi::hash_sha512(&self.inner).map_err(CudfError::from_cxx)?;
Ok(Column { inner: raw })
}
/// Hash each row using xxHash32.
///
/// Returns a `u32` column of hash values.
pub fn hash_xxhash32(&self, seed: u32) -> Result<Column> {
let raw = cudf_cxx::hashing::ffi::hash_xxhash32(&self.inner, seed)
.map_err(CudfError::from_cxx)?;
Ok(Column { inner: raw })
}
/// Hash each row using MurmurHash3 x64 128-bit.
///
/// Returns a 2-column table where the two columns together form
/// a 128-bit hash per row.
pub fn hash_murmurhash3_x64_128(&self, seed: u64) -> Result<Table> {
let raw = cudf_cxx::hashing::ffi::hash_murmurhash3_x64_128(&self.inner, seed)
.map_err(CudfError::from_cxx)?;
Ok(Table { inner: raw })
}
}