本文整理汇总了Golang中github.com/attic-labs/noms/types.Value.Chunks方法的典型用法代码示例。如果您正苦于以下问题:Golang Value.Chunks方法的具体用法?Golang Value.Chunks怎么用?Golang Value.Chunks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/attic-labs/noms/types.Value
的用法示例。
在下文中一共展示了Value.Chunks方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: WriteValue
// WriteValue takes a Value, schedules it to be written it to ds, and returns v.Ref(). v is not guaranteed to be actually written until after a successful Commit().
func (ds *dataStoreCommon) WriteValue(v types.Value) (r types.RefBase) {
if v == nil {
return
}
targetRef := v.Ref()
r = types.PrivateRefFromType(targetRef, types.MakeRefType(v.Type()))
if entry := ds.checkCache(targetRef); entry != nil && entry.Present() {
return
}
// Encoding v causes any child chunks, e.g. internal nodes if v is a meta sequence, to get written. That needs to happen before we try to validate v.
chunk := types.EncodeValue(v, ds)
for _, reachable := range v.Chunks() {
entry := ds.checkCache(reachable.TargetRef())
d.Chk.True(entry != nil && entry.Present(), "Value to write contains ref %s, which points to a non-existent Value.", reachable.TargetRef())
// BUG 1121
// It's possible that entry.Type() will be simply 'Value', but that 'reachable' is actually a properly-typed object -- that is, a Ref to some specific Type. The Chk below would fail, though it's possible that the Type is actually correct. We wouldn't be able to verify without reading it, though, so we'll dig into this later.
targetType := getTargetType(reachable)
if targetType.Equals(types.MakePrimitiveType(types.ValueKind)) {
continue
}
d.Chk.True(entry.Type().Equals(targetType), "Value to write contains ref %s, which points to a value of a different type: %+v != %+v", reachable.TargetRef(), entry.Type(), targetType)
}
ds.cs.Put(chunk) // TODO: DataStore should manage batching and backgrounding Puts.
ds.setCache(targetRef, presentChunk(v.Type()))
return
}