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

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

示例1: CheckECC

func CheckECC(data []byte) uint32 {
    if len(data) > 200 {
        tmpdata := append(data[:100], data[len(data)-100:]...)
        return adler32.Checksum(tmpdata)
    } else {
        return adler32.Checksum(data)
    }
}

开发者ID:whiskerman,项目名称:gotcp,代码行数:8,代码来源:streamUtils.go

示例2: Encode

// FIXME: find better way of writing this
func Encode(msg *RpcMessage) ([]byte, error) {
    payload, err := proto.Marshal(msg)
    if err != nil {
        return nil, err
    }

    wire := make([]byte, 12+len(payload))

    // size
    binary.BigEndian.PutUint32(wire, uint32(8+len(payload)))

    // marker
    if copy(wire[4:], "RPC0") != 4 {
        panic("What the hell")
    }

    // payload
    if copy(wire[8:], payload) != len(payload) {
        panic("What the hell")
    }

    // checksum
    checksum := adler32.Checksum(wire[4 : 8+len(payload)])
    binary.BigEndian.PutUint32(wire[8+len(payload):], checksum)

    return wire, nil
}

开发者ID:KerwinMa,项目名称:muduo-protorpc,代码行数:28,代码来源:codec.go

示例3: BenchmarkAdler32

func BenchmarkAdler32(b *testing.B) {
    var bv uint32
    for i := 0; i < b.N; i++ {
        bv = adler32.Checksum(in)
    }
    benchVal32 = bv
}

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

示例4: PickPeer

func (this *StandardPeerSelector) PickPeer(key string) (peerAddr string) {
    // adler32 is almost same as crc32, but much 3 times faster
    checksum := adler32.Checksum([]byte(key))
    index := int(checksum) % len(this.peerAddrs)

    return this.peerAddrs[index]
}

开发者ID:lucmichalski,项目名称:fae,代码行数:7,代码来源:selector_standard.go

示例5: performReducing

// performReducing runs the reducing goroutines.
func performReducing(mr MapReducer, mapEmitChan, reduceEmitChan KeyValueChan) {
    // Start a closer for the reduce emit chan.
    size := runtime.NumCPU()
    signals := newCloserChan(reduceEmitChan, size)

    // Start reduce goroutines.
    reduceChans := make([]KeyValueChan, size)
    for i := 0; i < size; i++ {
        reduceChans[i] = make(KeyValueChan)
        go func(in KeyValueChan) {
            mr.Reduce(in, reduceEmitChan)
            signals <- struct{}{}
        }(reduceChans[i])
    }

    // Read map emitted data.
    for kv := range mapEmitChan {
        hash := adler32.Checksum([]byte(kv.Key()))
        idx := hash % uint32(size)
        reduceChans[idx] <- kv
    }

    // Close reduce channels.
    for _, reduceChan := range reduceChans {
        reduceChan.Close()
    }
}

开发者ID:kung-foo,项目名称:golib,代码行数:28,代码来源:mapreduce.go

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