hashers

package
v0.0.0-...-ccaef76 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2017 License: Apache-2.0 Imports: 3 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fnv32

func Fnv32(s string) (hash uint32)

Fnv32 returns a 32-bit FNV-1 hash of a string.

func Fnv64

func Fnv64(s string) (hash uint64)

Fnv64 returns a 64-bit FNV-1 hash of a string.

func Mix32

func Mix32(h uint32) uint32

Mix32 mixes the hash to make sure the bits are spread, borrowed from xxhash.

func Mix64

func Mix64(h uint64) uint64

Mix64 mixes the hash to make sure the bits are spread, borrowed from xxhash.

func Mix64to32

func Mix64to32(h uint64) uint32

Mix64to32 is a helper to mix 64bit number down to 32.

func TypeHasher32

func TypeHasher32(v interface{}) uint32

TypeHasher32 returns a hash for the specific key for internal sharding. By default, those types are supported as keys: KeyHasher, string, uint64, int64, uint32, int32, uint16, int16, uint8, int8, uint, int, float64, float32 and fmt.Stringer. Falls back to Fnv32(reflect.ValueOf(v).String()).

func TypeHasher64

func TypeHasher64(v interface{}) uint64

TypeHasher64 returns a hash for the specific key for internal sharding. By default, those types are supported as keys: KeyHasher, string, uint64, int64, uint32, int32, uint16, int16, uint8, int8, uint, int, float64, float32 and fmt.Stringer. Falls back to Fnv64(reflect.ValueOf(v).String()).

Types

type KeyHasher

type KeyHasher interface {
	Hash() uint64
}

KeyHasher is a type that provides its own hash function.

Jump to

Keyboard shortcuts

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