Ejemplo n.º 1
0
Archivo: pull.go Proyecto: 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)
}
Ejemplo n.º 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
}