当前位置: 首页>>代码示例>>Golang>>正文


Golang hash.Hash类代码示例

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


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

示例1: makeNamespacedKey

func (s *DynamoStore) makeNamespacedKey(h hash.Hash) []byte {
	// This is semantically `return append(s.namespace, r.DigestSlice()...)`, but it seemed like we'd be doing this a LOT, and we know how much space we're going to need anyway. So, pre-allocate a slice and then copy into it.
	hashSlice := h.DigestSlice()
	key := make([]byte, s.namespaceLen+len(hashSlice))
	copy(key, s.namespace)
	copy(key[s.namespaceLen:], hashSlice)
	return key
}
开发者ID:willhite,项目名称:noms-old,代码行数:8,代码来源:dynamo_store.go

示例2: updateRootByKey

func (l *internalLevelDBStore) updateRootByKey(key []byte, current, last hash.Hash) bool {
	l.mu.Lock()
	defer l.mu.Unlock()
	if last != l.rootByKey(key) {
		return false
	}

	// Sync: true write option should fsync memtable data to disk
	err := l.db.Put(key, []byte(current.String()), &opt.WriteOptions{Sync: true})
	d.Chk.NoError(err)
	return true
}
开发者ID:willhite,项目名称:noms-old,代码行数:12,代码来源:leveldb_store.go

示例3: toDbKey

// toDbKey takes a refHeight and a hash and returns a binary key suitable for use with LevelDB. The default sort order used by LevelDB ensures that these keys (and their associated values) will be iterated in ref-height order.
func toDbKey(refHeight uint64, hash hash.Hash) []byte {
	digest := hash.DigestSlice()
	buf := bytes.NewBuffer(make([]byte, 0, uint64Size+binary.Size(digest)))
	err := binary.Write(buf, binary.BigEndian, refHeight)
	d.Chk.NoError(err)
	err = binary.Write(buf, binary.BigEndian, digest)
	d.Chk.NoError(err)
	return buf.Bytes()
}
开发者ID:Richardphp,项目名称:noms,代码行数:10,代码来源:put_cache.go

示例4: UpdateRoot

func (s *DynamoStore) UpdateRoot(current, last hash.Hash) bool {
	s.requestWg.Wait()

	putArgs := dynamodb.PutItemInput{
		TableName: aws.String(s.table),
		Item: map[string]*dynamodb.AttributeValue{
			refAttr:   {B: s.rootKey},
			chunkAttr: {B: current.DigestSlice()},
			compAttr:  {S: aws.String(noneValue)},
		},
	}

	if last.IsEmpty() {
		putArgs.ConditionExpression = aws.String(valueNotExistsExpression)
	} else {
		putArgs.ConditionExpression = aws.String(valueEqualsExpression)
		putArgs.ExpressionAttributeValues = map[string]*dynamodb.AttributeValue{
			":prev": {B: last.DigestSlice()},
		}
	}

	_, err := s.ddbsvc.PutItem(&putArgs)
	if err != nil {
		if awsErr, ok := err.(awserr.Error); ok {
			if awsErr.Code() == "ConditionalCheckFailedException" {
				return false
			}
			d.Chk.NoError(awsErr)
		} else {
			d.Chk.NoError(err)
		}
	}

	return true
}
开发者ID:willhite,项目名称:noms-old,代码行数:35,代码来源:dynamo_store.go

示例5: requestRoot

func (bhcs *httpBatchStore) requestRoot(method string, current, last hash.Hash) *http.Response {
	u := *bhcs.host
	u.Path = httprouter.CleanPath(bhcs.host.Path + constants.RootPath)
	if method == "POST" {
		d.Exp.False(current.IsEmpty())
		params := u.Query()
		params.Add("last", last.String())
		params.Add("current", current.String())
		u.RawQuery = params.Encode()
	}

	req := newRequest(method, bhcs.auth, u.String(), nil, nil)

	res, err := bhcs.httpClient.Do(req)
	d.Chk.NoError(err)

	return res
}
开发者ID:willhite,项目名称:noms-old,代码行数:18,代码来源:http_batch_store.go

示例6: EnsureHash

func EnsureHash(h *hash.Hash, v Value) hash.Hash {
	if h.IsEmpty() {
		*h = getHash(v)
	}
	return *h
}
开发者ID:Richardphp,项目名称:noms,代码行数:6,代码来源:get_hash.go

示例7: toChunkKey

func (l *LevelDBStore) toChunkKey(r hash.Hash) []byte {
	digest := r.DigestSlice()
	out := make([]byte, len(l.chunkPrefix), len(l.chunkPrefix)+len(digest))
	copy(out, l.chunkPrefix)
	return append(out, digest...)
}
开发者ID:willhite,项目名称:noms-old,代码行数:6,代码来源:leveldb_store.go

示例8: writeHash

func (rv *rollingValueHasher) writeHash(h hash.Hash) {
	digest := h.Digest()
	for _, b := range digest[:] {
		rv.HashByte(b)
	}
}
开发者ID:kalman,项目名称:noms-pre-release,代码行数:6,代码来源:rolling_value_hasher.go

示例9: writeHash

func (w *nomsTestWriter) writeHash(h hash.Hash) {
	w.writeString(h.String())
}
开发者ID:Richardphp,项目名称:noms,代码行数:3,代码来源:encoding_test.go

示例10: assertInputNotInStore

func assertInputNotInStore(input string, h hash.Hash, s ChunkStore, assert *assert.Assertions) {
	data := s.Get(h)
	assert.Nil(data, "Shouldn't have gotten data for %s", h.String())
}
开发者ID:willhite,项目名称:noms-old,代码行数:4,代码来源:test_utils.go

示例11: assertInputInStore

func assertInputInStore(input string, h hash.Hash, s ChunkStore, assert *assert.Assertions) {
	chunk := s.Get(h)
	assert.False(chunk.IsEmpty(), "Shouldn't get empty chunk for %s", h.String())
	assert.Equal(input, string(chunk.Data()))
}
开发者ID:willhite,项目名称:noms-old,代码行数:5,代码来源:test_utils.go

示例12: writeHash

func (b *binaryNomsWriter) writeHash(h hash.Hash) {
	b.ensureCapacity(sha1.Size)
	digest := h.Digest()
	copy(b.buff[b.offset:], digest[:])
	b.offset += sha1.Size
}
开发者ID:willhite,项目名称:noms-old,代码行数:6,代码来源:codec.go

示例13: CreateHashSpecString

func CreateHashSpecString(protocol, path string, h hash.Hash) string {
	return fmt.Sprintf("%s:%s::#%s", protocol, path, h.String())
}
开发者ID:Richardphp,项目名称:noms,代码行数:3,代码来源:dataspec.go

示例14: serializeHash

func serializeHash(w io.Writer, h hash.Hash) {
	digest := h.Digest()
	n, err := io.Copy(w, bytes.NewReader(digest[:]))
	d.Chk.NoError(err)
	d.Chk.True(int64(hash.ByteLen) == n)
}
开发者ID:Richardphp,项目名称:noms,代码行数:6,代码来源:serialize_hints.go

示例15: writeHash

func (b *binaryNomsWriter) writeHash(h hash.Hash) {
	b.ensureCapacity(hash.ByteLen)
	digest := h.Digest()
	copy(b.buff[b.offset:], digest[:])
	b.offset += hash.ByteLen
}
开发者ID:Richardphp,项目名称:noms,代码行数:6,代码来源:codec.go


注:本文中的github.com/attic-labs/noms/go/hash.Hash类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。