update
parent
c0561abb32
commit
b3659f6a64
10
hashes.go
10
hashes.go
|
@ -6,11 +6,9 @@ import (
|
||||||
"hash/fnv"
|
"hash/fnv"
|
||||||
)
|
)
|
||||||
|
|
||||||
// For a specific hashing function to be (re)defined.
|
type Hash64 func(buckets []int) uint64
|
||||||
type Hash func(buckets []int) uint64
|
|
||||||
|
|
||||||
// Fnva64 is a specific hash implementation, which returns
|
// Fnva64 returns a FVN-1a hash for a slice of bucket numbers.
|
||||||
// a FVN-1a hash for a slice of bucket numbers.
|
|
||||||
func Fnva64(buckets []int) uint64 {
|
func Fnva64(buckets []int) uint64 {
|
||||||
var b bytes.Buffer
|
var b bytes.Buffer
|
||||||
gob.NewEncoder(&b).Encode(buckets)
|
gob.NewEncoder(&b).Encode(buckets)
|
||||||
|
@ -19,8 +17,8 @@ func Fnva64(buckets []int) uint64 {
|
||||||
return hash.Sum64()
|
return hash.Sum64()
|
||||||
}
|
}
|
||||||
|
|
||||||
// HashSet returns a slice of hashes for a tree of bucket ids.
|
// Hashes64 returns a set of hashes for a tree of bucket ids.
|
||||||
func HashSet(tree [][]int, hash Hash) (hs []uint64) {
|
func Hashes64(tree [][]int, hash Hash64) (hs []uint64) {
|
||||||
for i := 0; i < len(tree); i++ {
|
for i := 0; i < len(tree); i++ {
|
||||||
hs = append(hs, hash(tree[i]))
|
hs = append(hs, hash(tree[i]))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue