github.com/sandwich-go/boost@v1.3.29/xcontainer/smap/map.go (about)

     1  package smap
     2  
     3  import "github.com/sandwich-go/boost/z"
     4  
     5  // KeyToHashAny smap只是利用KeyToHash来确定单次运行过程中shared计算,并不在意hash冲突,如需持久化固定的hash则选择其他算法
     6  var KeyToHashAny = z.KeyToHash
     7  var KeyToHashBytes = z.MemHash
     8  var KeyToHashString = z.MemHashString
     9  
    10  func KeyToHashInt(k int) uint64     { return uint64(k) }
    11  func KeyToHashInt32(k int32) uint64 { return uint64(k) }
    12  func KeyToHashInt64(k int64) uint64 { return uint64(k) }
    13  
    14  var _ = KeyToHashAny
    15  var _ = KeyToHashBytes
    16  var _ = KeyToHashString
    17  
    18  // go get github.com/ncw/gotemplate/...
    19  //go:generate gotemplate -outfmt gen_%v "../templates/smap" "IntInt(int,int,KeyToHashInt)"
    20  //go:generate gotemplate -outfmt gen_%v "../templates/smap" "IntString(int,string,KeyToHashInt)"
    21  //go:generate gotemplate -outfmt gen_%v "../templates/smap" "IntAny(int,interface{},KeyToHashInt)"
    22  
    23  //go:generate gotemplate -outfmt gen_%v "../templates/smap" "StringString(string,string,KeyToHashString)"
    24  //go:generate gotemplate -outfmt gen_%v "../templates/smap" "StringInt64(string,int64,KeyToHashString)"
    25  //go:generate gotemplate -outfmt gen_%v "../templates/smap" "StringAny(string,interface{},KeyToHashString)"
    26  
    27  //go:generate gotemplate -outfmt gen_%v "../templates/smap" "Int32String(int32,string,KeyToHashInt32)"
    28  //go:generate gotemplate -outfmt gen_%v "../templates/smap" "Int64String(int64,string,KeyToHashInt64)"