hashutil

package
v1.0.0-rc.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2026 License: Apache-2.0, Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package hashutil provides shared hash mixing constants and functions for probabilistic data structures (Count-Min Sketch, HyperLogLog, MinHash).

All functions use the splitmix64 finalizer by Vigna (2014) which provides full-avalanche mixing across all 64 bits.

Index

Constants

View Source
const (
	// BaseSeed is the starting seed for deterministic seed generation.
	BaseSeed = 0x517cc1b727220a95

	// MixShift1 is the first right-shift in the splitmix64 finalizer.
	MixShift1 = 30

	// MixMul1 is the first multiplier in the splitmix64 finalizer.
	MixMul1 = 0xbf58476d1ce4e5b9

	// MixShift2 is the second right-shift in the splitmix64 finalizer.
	MixShift2 = 27

	// MixMul2 is the second multiplier in the splitmix64 finalizer.
	MixMul2 = 0x94d049bb133111eb

	// MixShift3 is the third right-shift in the splitmix64 finalizer.
	MixShift3 = 31
)

Splitmix64 constants from the splitmix64 finalizer by Vigna (2014).

Variables

This section is empty.

Functions

func FNV64a

func FNV64a(data []byte) uint64

FNV64a computes a 64-bit FNV-1a hash of the given data.

func GenerateSeeds

func GenerateSeeds(n int, advance func(uint64) uint64) []uint64

GenerateSeeds creates n deterministic seeds using the given advance function. Use Mix64 for CMS-style seeds or Splitmix64 for MinHash-style seeds.

func Mix64

func Mix64(v uint64) uint64

Mix64 applies the splitmix64 finalizer for full-avalanche mixing. This is a pure output function — it does NOT advance any state.

func MixHash

func MixHash(base, seed uint64) uint64

MixHash combines a base hash with a seed using XOR and the splitmix64 finalizer. This produces a deterministic hash variation for a given (base, seed) pair.

func Splitmix64

func Splitmix64(state uint64) uint64

Splitmix64 advances the state by the golden-ratio increment and applies the mix64 finalizer. This is a full PRNG step that both advances state and produces output.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL