Skip to content

Commit bb1474f

Browse files
committed
remove unused
1 parent 64b6cde commit bb1474f

File tree

1 file changed

+0
-21
lines changed

1 file changed

+0
-21
lines changed

src/sharding.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use sha1::{Digest, Sha1};
2-
31
// https://github.com/postgres/postgres/blob/27b77ecf9f4d5be211900eda54d8155ada50d696/src/include/catalog/partition.h#L20
42
const PARTITION_HASH_SEED: u64 = 0x7A5B22367996DCFD;
53

@@ -12,17 +10,6 @@ impl Sharder {
1210
Sharder { shards: shards }
1311
}
1412

15-
/// Use SHA1 to pick a shard for the key. The key can be anything,
16-
/// including an int or a string.
17-
pub fn _sha1(&self, key: &[u8]) -> usize {
18-
let mut hasher = Sha1::new();
19-
hasher.update(key);
20-
let result = hasher.finalize_reset();
21-
22-
let i = u32::from_le_bytes(result[result.len() - 4..result.len()].try_into().unwrap());
23-
i as usize % self.shards
24-
}
25-
2613
/// Hash function used by Postgres to determine which partition
2714
/// to put the row in when using HASH(column) partitioning.
2815
/// Source: https://github.com/postgres/postgres/blob/27b77ecf9f4d5be211900eda54d8155ada50d696/src/common/hashfn.c#L631
@@ -117,14 +104,6 @@ impl Sharder {
117104
mod test {
118105
use super::*;
119106

120-
#[test]
121-
fn test_sha1() {
122-
let sharder = Sharder::new(12);
123-
let key = b"1234";
124-
let shard = sharder.sha1(key);
125-
assert_eq!(shard, 1);
126-
}
127-
128107
// See tests/sharding/partition_hash_test_setup.sql
129108
// The output of those SELECT statements will match this test,
130109
// confirming that we implemented Postgres BIGINT hashing correctly.

0 commit comments

Comments
 (0)