Skip to content

Latest commit

 

History

History
96 lines (50 loc) · 1.96 KB

jumphash.md

File metadata and controls

96 lines (50 loc) · 1.96 KB

jumphash

import "github.com/andy2046/gopie/pkg/jumphash"

Package jumphash provides a jump consistent hash implementation.

jumphash.go

func Hash(key uint64, buckets int) int

Hash takes a key and the number of buckets, returns an integer in the range [0, buckets). If the number of buckets is not greater than 1 then 1 is used.

func HashString(key string, buckets int) int

HashString takes string as key instead of integer and uses CRC-64 to generate key.

type Hasher struct {
    // contains filtered or unexported fields
}

Hasher represents a jump consistent Hasher using a string as key.

func New(n int) *Hasher

New returns a new instance of of Hasher.

func (*Hasher) Hash

func (h *Hasher) Hash(key string) int

Hash returns the integer hash for the given key.

func (*Hasher) N

func (h *Hasher) N() int

N returns the number of buckets the hasher can assign to.


Generated by godoc2md