MCPcopy
hub / github.com/dgraph-io/badger / getFileRLocked

Method getFileRLocked

value.go:1511–1533  ·  view source on GitHub ↗

Gets the logFile and acquires and RLock() for the mmap. You must call RUnlock on the file (if non-nil)

(vp valuePointer)

Source from the content-addressed store, hash-verified

1509// Gets the logFile and acquires and RLock() for the mmap. You must call RUnlock on the file
1510// (if non-nil)
1511func (vlog *valueLog) getFileRLocked(vp valuePointer) (*logFile, error) {
1512 vlog.filesLock.RLock()
1513 defer vlog.filesLock.RUnlock()
1514 ret, ok := vlog.filesMap[vp.Fid]
1515 if !ok {
1516 // log file has gone away, will need to retry the operation.
1517 return nil, ErrRetry
1518 }
1519
1520 // Check for valid offset if we are reading from writable log.
1521 maxFid := vlog.maxFid
1522 if vp.Fid == maxFid {
1523 currentOffset := vlog.woffset()
1524 if vp.Offset >= currentOffset {
1525 return nil, errors.Errorf(
1526 "Invalid value pointer offset: %d greater than current offset: %d",
1527 vp.Offset, currentOffset)
1528 }
1529 }
1530
1531 ret.lock.RLock()
1532 return ret, nil
1533}
1534
1535// Read reads the value log at a given location.
1536// TODO: Make this read private.

Callers 1

readValueBytesMethod · 0.95

Calls 2

woffsetMethod · 0.95
ErrorfMethod · 0.65

Tested by

no test coverage detected