hash

package
v0.0.0-...-7bbaf48 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2019 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//CRC64_Table_DEFAULT = crc64.MakeTable(crc64.ISO)
	CRC64_Table_DEFAULT = crc64.MakeTable(crc64.ECMA)
)

Functions

func GenerateConsistentRing

func GenerateConsistentRing(nodeId int32, partIndex int) uint32

func Int32

func Int32(bytes []byte) int32

byte array hash int32

func Int32Of

func Int32Of(str string) int32

string hash int32

func Int64

func Int64(bytes []byte) int64

func Int64Of

func Int64Of(str string) int64

func Remainder

func Remainder(dat []byte, size int) int

dat哈希后取size的余数

func UInt32Of

func UInt32Of(str string) uint32

string hash uint32

func UInt64

func UInt64(bytes []byte) uint64

func UInt64Of

func UInt64Of(str string) uint64

func Uint32

func Uint32(bytes []byte) uint32

byte array hash uint32

Types

type Consistent

type Consistent struct {
	Nodes     map[uint32]Node
	Resources map[int32]bool

	sync.RWMutex
	// contains filtered or unexported fields
}

func NewConsistent

func NewConsistent() *Consistent

func (*Consistent) Add

func (p *Consistent) Add(node *Node) bool

func (*Consistent) Distribution

func (p *Consistent) Distribution()

func (*Consistent) Get

func (p *Consistent) Get(key string) Node

func (*Consistent) GetNodeByRing

func (p *Consistent) GetNodeByRing(ring int) Node

func (*Consistent) GetRing

func (p *Consistent) GetRing(key string) int

func (*Consistent) Next

func (p *Consistent) Next(key string, size int) []Node

func (*Consistent) NextOfRing

func (p *Consistent) NextOfRing(ring uint32) uint32

func (*Consistent) NextPartition

func (p *Consistent) NextPartition(nodeId int32, partition int, size int) []Node

func (*Consistent) NextRing

func (p *Consistent) NextRing(key string) int

func (*Consistent) Prev

func (p *Consistent) Prev(key string, size int) []Node

func (*Consistent) PrevRing

func (p *Consistent) PrevRing(key string) int

func (*Consistent) PrintMaps

func (p *Consistent) PrintMaps()

func (*Consistent) PrintRings

func (p *Consistent) PrintRings()

func (*Consistent) Remove

func (p *Consistent) Remove(node *Node)

type HashRing

type HashRing []uint32

func (HashRing) Len

func (c HashRing) Len() int

func (HashRing) Less

func (c HashRing) Less(i, j int) bool

func (HashRing) Swap

func (c HashRing) Swap(i, j int)

type Node

type Node struct {
	Id        int32
	Value     string
	Weight    float32
	Partition int
	// contains filtered or unexported fields
}

func NewNode

func NewNode(id int32, value string, weight float32, partitionSize int) *Node

func (*Node) Clone

func (p *Node) Clone() *Node

Jump to

Keyboard shortcuts

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