本文整理汇总了Golang中github.com/attic-labs/noms/ref.Ref.DigestSlice方法的典型用法代码示例。如果您正苦于以下问题:Golang Ref.DigestSlice方法的具体用法?Golang Ref.DigestSlice怎么用?Golang Ref.DigestSlice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/attic-labs/noms/ref.Ref
的用法示例。
在下文中一共展示了Ref.DigestSlice方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: UpdateRoot
func (s *DynamoStore) UpdateRoot(current, last ref.Ref) 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
}
示例2: makeNamespacedKey
func (s *DynamoStore) makeNamespacedKey(r ref.Ref) []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.
refSlice := r.DigestSlice()
key := make([]byte, s.namespaceLen+len(refSlice))
copy(key, s.namespace)
copy(key[s.namespaceLen:], refSlice)
return key
}
示例3: toChunkKey
func (l *LevelDBStore) toChunkKey(r ref.Ref) []byte {
digest := r.DigestSlice()
out := make([]byte, len(l.chunkPrefix), len(l.chunkPrefix)+len(digest))
copy(out, l.chunkPrefix)
return append(out, digest...)
}