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

Method getInternal

posting/lists.go:258–299  ·  view source on GitHub ↗
(key []byte, readFromDisk, readUids bool)

Source from the content-addressed store, hash-verified

256}
257
258func (lc *LocalCache) getInternal(key []byte, readFromDisk, readUids bool) (*List, error) {
259 skey := string(key)
260 getNewPlistNil := func() (*List, error) {
261 lc.RLock()
262 defer lc.RUnlock()
263 if lc.plists == nil {
264 return getNew(key, pstore, lc.startTs, readUids)
265 }
266 if l, ok := lc.plists[skey]; ok {
267 return l, nil
268 }
269 return nil, nil
270 }
271
272 if l, err := getNewPlistNil(); l != nil || err != nil {
273 return l, err
274 }
275
276 var pl *List
277 if readFromDisk {
278 var err error
279 pl, err = getNew(key, pstore, lc.startTs, readUids)
280 if err != nil {
281 return nil, err
282 }
283 } else {
284 pl = &List{
285 key: key,
286 plist: new(pb.PostingList),
287 mutationMap: newMutableLayer(),
288 }
289 }
290
291 // If we just brought this posting list into memory and we already have a delta for it, let's
292 // apply it before returning the list.
293 lc.RLock()
294 if delta, ok := lc.deltas[skey]; ok && len(delta) > 0 {
295 pl.setMutation(lc.startTs, delta)
296 }
297 lc.RUnlock()
298 return lc.SetIfAbsent(skey, pl), nil
299}
300
301func (lc *LocalCache) readPostingListAt(key []byte) (*pb.PostingList, error) {
302 if EnableDetailedMetrics {

Callers 3

GetMethod · 0.95
GetUidsMethod · 0.95
GetFromDeltaMethod · 0.95

Calls 6

setMutationMethod · 0.95
SetIfAbsentMethod · 0.95
getNewFunction · 0.85
newMutableLayerFunction · 0.85
RLockMethod · 0.80
RUnlockMethod · 0.80

Tested by

no test coverage detected