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)
| 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. |
| 2039 | func (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. |
| 2054 | func (l *List) PostingFor(readTs uint64, langs []string) (p *pb.Posting, rerr error) { |
no test coverage detected