hash

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: May 9, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package hash implements a consistent hasher described as described in http://arxiv.org/pdf/1406.2294v1.pdf

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Jump

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

Jump is a consistent hasher.

func New

func New(h hash.Hash64) *Jump

New creates a new consitent jump hasher.

func (*Jump) Hash

func (j *Jump) Hash(key uint64, buckets int) int

Hash takes a 64 bit key and the number of buckets. It outputs a bucket number in the range [0, buckets). If the number of buckets is less than or equal to 0 then one 1 is used.

func (*Jump) HashString

func (j *Jump) HashString(key string, buckets int) int

HashString takes string as key instead of an int. It uses the configured hash.Hash64 hasher to create an integer from the string key.

Jump to

Keyboard shortcuts

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