package main import ( "flag" "os" "fmt" "strconv" "hash/fnv" "github.com/vmware/go-pmem-transaction/pmem" "github.com/vmware/go-pmem-transaction/transaction" ) const N int = 10 type pair struct { key [32]byte idx int } type data struct { buckets [][]pair values []int magic int } const ( // A magic number used to identify if the root object initialization // completed successfully. magic = 0x1B2E8BFF7BFBD154 ) func hash(s string) int { h := fnv.New32a() h.Write([]byte(s)) return int(h.Sum32()) } func initialize(ptr *data) { txn("undo") { ptr.buckets = pmake([][]pair, N) ptr.magic = magic } } func get(ptr *data, key string) *int { index := hash(key) % N var bytes [32]byte copy(bytes[:], key) for i:=0; i