本文整理汇总了Golang中hash/fnv.New32函数的典型用法代码示例。如果您正苦于以下问题:Golang New32函数的具体用法?Golang New32怎么用?Golang New32使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了New32函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: ModHash

func (g *FieldGrouping) ModHash(tuple Values) uint32 {
    h := fnv.New32()
    values := g.SourceFields.Select(g.Selector, tuple)
    for _, value := range values {
        h.Write(value.Encode())
    }
    h = fnv.New32()
    return h.Sum32() % uint32(len(g.Dests))
}

开发者ID:pfeairheller,项目名称:sif,代码行数:9,代码来源:field_grouping.go

示例2: getBucketWithBuiltInHasher

// Get bucket (or sharded map) by key in 1 cache instance with built in hash function of Golang
func (cache *Cache) getBucketWithBuiltInHasher(key string) (*ConcurrentMap, uint) {
    hasher := fnv.New32()
    hasher.Write([]byte(key))
    bucketsCount := len(cache.buckets)
    bucketIndex := uint(hasher.Sum32()) % uint(bucketsCount)
    return cache.buckets[bucketIndex], bucketIndex
}

开发者ID:minhduccm,项目名称:goconcache,代码行数:8,代码来源:concache.go

示例3: BenchmarkFnv32

func BenchmarkFnv32(b *testing.B) {
    h := fnv.New32()
    for i := 0; i < b.N; i++ {
        h.Write(in)
        h.Sum(nil)
    }
}

开发者ID:panamafrancis,项目名称:xxhash,代码行数:7,代码来源:xxhash_test.go

示例4: Key

func (self matchHash) Key(target matchHash) uint32 {
    hasher := fnv.New32()
    for k, s := range self {
        var value, mask []byte
        if bKey, ok := k.(OxmKeyBasic); !ok || oxm.Header(bKey).Class() != ofp4.OFPXMC_OPENFLOW_BASIC {
            continue
        } else {
            length, _ := ofp4.OxmOfDefs(uint32(bKey))
            value = make([]byte, length)
            mask = make([]byte, length)
        }
        if t, ok := target[k]; ok {
            a := s.(OxmValueMask)
            b := t.(OxmValueMask)
            for i, _ := range mask {
                mask[i] = 0xFF
            }
            if a.Mask != nil {
                for i, _ := range mask {
                    mask[i] &= a.Mask[i]
                }
            }
            if b.Mask != nil {
                for i, _ := range mask {
                    mask[i] &= b.Mask[i]
                }
            }
            for i, _ := range value {
                value[i] = b.Value[i] & mask[i]
            }
        }
        hasher.Write(value)
    }
    return hasher.Sum32()
}

开发者ID:hkwi,项目名称:gopenflow,代码行数:35,代码来源:match.go

示例5: computeHash

// Computes the hash of the cursor by computing the hash of every enpdoint supplied
func computeHash(endpoints []loadbalance.Endpoint) uint32 {
    h := fnv.New32()
    for _, endpoint := range endpoints {
        h.Write([]byte(endpoint.Id()))
    }
    return h.Sum32()
}

开发者ID:johntdyer,项目名称:golang-devops-stuff,代码行数:8,代码来源:cursor.go

最后编辑: kuteng  文档更新时间: 2021-08-23 19:14   作者:kuteng