예제 #1
0
파일: pull.go 프로젝트: arv/noms-old
func (trs *teeDataSource) ReadValue(ref ref.Ref) types.Value {
	c := trs.source.Get(ref)
	if c.IsEmpty() {
		return nil
	}

	trs.sink.Put(c)
	return types.DecodeChunk(c, trs)
}
예제 #2
0
// ReadValue reads and decodes a value from ds. It is not considered an error for the requested chunk to be empty; in this case, the function simply returns nil.
func (ds *dataStoreCommon) ReadValue(r ref.Ref) types.Value {
	v := types.DecodeChunk(ds.cs.Get(r), ds)
	checkAndSet := func(reachable ref.Ref, entry chunkCacheEntry) {
		if ds.checkCache(reachable) == nil {
			ds.setCache(reachable, entry)
		}
	}

	var entry chunkCacheEntry = absentChunk{}
	if v != nil {
		entry = presentChunk(v.Type())
		for _, reachable := range v.Chunks() {
			checkAndSet(reachable.TargetRef(), presentChunk(getTargetType(reachable)))
		}
	}
	checkAndSet(r, entry)
	return v
}