MCPcopy
hub / github.com/dgraph-io/dgraph / ValueFor

Method ValueFor

posting/list.go:2039–2051  ·  view source on GitHub ↗

ValueFor returns a value from posting list, according to preferred language list. If list is empty, value without language is returned; if such value is not available, value with smallest UID is returned. If list consists of one or more languages, first available value is returned. If no language fr

(readTs uint64, langs []string)

Source from the content-addressed store, hash-verified

2037// If list consists of one or more languages, first available value is returned.
2038// If no language from the list matches the values, processing is the same as for empty list.
2039func (l *List) ValueFor(readTs uint64, langs []string) (rval types.Val, rerr error) {
2040 l.RLock() // All public methods should acquire locks, while private ones should assert them.
2041 defer l.RUnlock()
2042 p, err := l.postingFor(readTs, langs)
2043 switch {
2044 case err == ErrNoValue:
2045 return rval, err
2046 case err != nil:
2047 return rval, errors.Wrapf(err, "cannot retrieve value with langs %v from list with key %s",
2048 langs, hex.EncodeToString(l.key))
2049 }
2050 return valueToTypesVal(p), nil
2051}
2052
2053// PostingFor returns the posting according to the preferred language list.
2054func (l *List) PostingFor(readTs uint64, langs []string) (p *pb.Posting, rerr error) {

Callers 2

fetchValueFunction · 0.80
handleCompareFunctionMethod · 0.80

Calls 4

postingForMethod · 0.95
valueToTypesValFunction · 0.85
RLockMethod · 0.80
RUnlockMethod · 0.80

Tested by

no test coverage detected