Documentation
¶
Index ¶
- type ConsistHash
- func (c *ConsistHash) Index(key string) uint64
- func (c *ConsistHash) IndexHash(key uint64) uint64
- func (c *ConsistHash) NextNode(index uint64) string
- func (c *ConsistHash) Node(key string) string
- func (c *ConsistHash) NodeHash(index uint64) string
- func (c *ConsistHash) Nodes(key string) [2]string
- func (c *ConsistHash) NodesHash(key uint64) [2]string
- type HashTable
- type JumpConsistentHash
- type KetamaConsistentHash
- type Option
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConsistHash ¶
type ConsistHash struct {
// contains filtered or unexported fields
}
ConsistHash support virtual count
func NewConsistHash ¶
func NewConsistHash(virtualCount uint32, nodes []string, opts ...Option) *ConsistHash
NewConsistHash new ConsistHash
func (*ConsistHash) Index ¶
func (c *ConsistHash) Index(key string) uint64
NodeHash 根据 key计算 hash value
func (*ConsistHash) IndexHash ¶
func (c *ConsistHash) IndexHash(key uint64) uint64
func (*ConsistHash) NextNode ¶
func (c *ConsistHash) NextNode(index uint64) string
NextNode get next node info
func (*ConsistHash) Node ¶
func (c *ConsistHash) Node(key string) string
func (*ConsistHash) NodeHash ¶
func (c *ConsistHash) NodeHash(index uint64) string
NodeHash get node info with hash value
func (*ConsistHash) Nodes ¶
func (c *ConsistHash) Nodes(key string) [2]string
func (*ConsistHash) NodesHash ¶
func (c *ConsistHash) NodesHash(key uint64) [2]string
NodesHash return node and next node info
type JumpConsistentHash ¶
type JumpConsistentHash struct{}
func NewJumpConsistentHash ¶
func NewJumpConsistentHash() *JumpConsistentHash
NewJumpConsistentHash new JumpConsistentHash
func (*JumpConsistentHash) Generate ¶
func (h *JumpConsistentHash) Generate(cnt uint32, nodes []string) map[uint64]string
func (*JumpConsistentHash) Index ¶
func (h *JumpConsistentHash) Index(key uint64, numBucket int32) uint64
http://arxiv.org/ftp/arxiv/papers/1406/1406.2294.pdf
int32_t JumpConsistentHash(uint64_t key, int32_t num_buckets) { int64_t b = -1, j = 0; while (j < num_buckets) { b = j; key = key * 2862933555777941757ULL + 1; j = (b + 1) * (double(1LL << 31) / double((key >> 33) + 1)); } return b; }
type KetamaConsistentHash ¶
type KetamaConsistentHash struct {
// contains filtered or unexported fields
}
KetamaConsistentHash ketama consist hash
func NewKetamaConsistentHash ¶
func NewKetamaConsistentHash(hf hash.Hash64) *KetamaConsistentHash
func (*KetamaConsistentHash) Generate ¶
func (h *KetamaConsistentHash) Generate(cnt uint32, nodes []string) map[uint64]string
Click to show internal directories.
Click to hide internal directories.