Crate jamhash

Crate jamhash 

Source
Expand description

§jamhash

A fast, non-cryptographic hash function designed for genomics and general-purpose hashing.

§Features

  • jamhash_u64: Specialized hash function for single u64 values, optimized for genomic k-mers
  • JamHasher: Streaming hasher implementing std::hash::Hasher trait
  • Dual-path accumulation for strong avalanche properties
  • Predictable: hash(0) == 0
  • Tested for low collision rates with canonical k-mers up to k=21

§Use Cases

§Genomics and Bioinformatics

The jamhash_u64 function is particularly well-suited for:

  • MinHash sketching of genomic sequences
  • K-mer counting and indexing
  • Sequence similarity estimation
use jamhash::jamhash_u64;

// Hash a k-mer encoded as u64 (e.g., 2-bit encoding)
let kmer: u64 = 0x1234567890abcdef;
let hash = jamhash_u64(kmer);

§General Purpose

use jamhash::{jamhash_bytes, JamHasher};
use std::hash::Hasher;

// Hash arbitrary bytes
let hash = jamhash_bytes(b"hello world");

// Use the streaming hasher
let mut hasher = JamHasher::new();
hasher.write(b"hello ");
hasher.write(b"world");
let hash = hasher.finish();

Structs§

JamHasher
Streaming hasher for arbitrary byte sequences.

Functions§

jamhash_bytes
Hash arbitrary bytes using jamhash.
jamhash_u64
Specialized hash function for single u64 values.