示例#1
0
文件: store.go 项目: jyzhe/beehive
func (s *KVStore) Map(msg bh.Msg, ctx bh.MapContext) bh.MappedCells {
	var k string
	switch data := msg.Data().(type) {
	case Put:
		k = string(data.Key)
	case Get:
		k = string(data)
	case Del:
		k = string(data)
	}
	cells := bh.MappedCells{
		{
			Dict: dict,
			Key:  strconv.FormatUint(xxhash.Checksum64([]byte(k))%s.Buckets, 16),
		},
	}
	return cells
}
示例#2
0
func BenchmarkXxhash64CgoVeryShort(b *testing.B) {
	k := []byte("Test-key-100")
	for i := 0; i < b.N; i++ {
		C.Checksum64(k)
	}
}
示例#3
0
func TestHash64CgoShort(t *testing.T) {
	r := C.Checksum64(in)
	if r != expected64 {
		t.Errorf("expected 0x%x, got 0x%x.", expected64, r)
	}
}
示例#4
0
func BenchmarkXxhash64Cgo(b *testing.B) {
	for i := 0; i < b.N; i++ {
		C.Checksum64(in)
	}
}