gocrush

package module
v0.0.0-...-befefb0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2015 License: MIT Imports: 6 Imported by: 0

README

gocrush

Implementation of the CRUSH Algorithm in Go

Documentation

Index

Constants

View Source
const (
	MAX_VALUE       = int64(0xFFFFFFFF)
	CRUSH_HASH_SEED = int64(1315423911)
)

Variables

This section is empty.

Functions

func Btoi

func Btoi(b []byte) int64

func Max64

func Max64(a int64, b int64) int64

func TestCompare

func TestCompare(n Node) bool

Types

type Comparitor

type Comparitor func(Node) bool

type CrushNode

type CrushNode struct {
	Selector Selector
}

func (CrushNode) GetSelector

func (n CrushNode) GetSelector() Selector

func (CrushNode) Select

func (n CrushNode) Select(input int64, round int64) Node

func (CrushNode) SetSelector

func (n CrushNode) SetSelector(Selector Selector)

type HashingSelector

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

func NewHashingSelector

func NewHashingSelector(n Node) *HashingSelector

func (*HashingSelector) Select

func (s *HashingSelector) Select(input int64, round int64) Node

type Node

type Node interface {
	GetChildren() []Node
	GetType() int
	GetWeight() int64
	GetId() string
	IsFailed() bool
	GetSelector() Selector
	SetSelector(Selector)
	GetParent() Node
	IsLeaf() bool
	Select(input int64, round int64) Node
}

func Select

func Select(parent Node, input int64, count int, nodeType int, c Comparitor) []Node

type Selector

type Selector interface {
	Select(input int64, round int64) Node
}

type StrawSelector

type StrawSelector struct {
	Straws map[Node]int64
}

func NewStrawSelector

func NewStrawSelector(n Node) *StrawSelector

func (*StrawSelector) Select

func (s *StrawSelector) Select(input int64, round int64) Node

type TestingNode

type TestingNode struct {
	Children []Node
	CrushNode
	Weight int64
	Parent Node
	Failed bool
	Id     string
	Type   int
}

func (TestingNode) GetChildren

func (n TestingNode) GetChildren() []Node

func (TestingNode) GetId

func (n TestingNode) GetId() string

func (TestingNode) GetParent

func (n TestingNode) GetParent() Node

func (TestingNode) GetType

func (n TestingNode) GetType() int

func (TestingNode) GetWeight

func (n TestingNode) GetWeight() int64

func (TestingNode) IsFailed

func (n TestingNode) IsFailed() bool

func (TestingNode) IsLeaf

func (n TestingNode) IsLeaf() bool

type TreeSelector

type TreeSelector struct {
	Node Node
	// contains filtered or unexported fields
}

func NewTreeSelector

func NewTreeSelector(n Node) *TreeSelector

func (*TreeSelector) Select

func (s *TreeSelector) Select(input int64, round int64) Node

type Triple

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

type UniformSelector

type UniformSelector struct {
	Node Node
	// contains filtered or unexported fields
}

func NewUniformSelector

func NewUniformSelector(n Node) *UniformSelector

func (*UniformSelector) Select

func (s *UniformSelector) Select(input int64, round int64) Node

type UnweightedHashSelector

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

func NewUnweightedHashSelector

func NewUnweightedHashSelector(n Node) *UnweightedHashSelector

func (*UnweightedHashSelector) Select

func (s *UnweightedHashSelector) Select(input int64, round int64) Node

Jump to

Keyboard shortcuts

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