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

Method init

value.go:1211–1228  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1209}
1210
1211func (lf *logFile) init() error {
1212 fstat, err := lf.fd.Stat()
1213 if err != nil {
1214 return errors.Wrapf(err, "Unable to check stat for %q", lf.path)
1215 }
1216 sz := fstat.Size()
1217 if sz == 0 {
1218 // File is empty. We don't need to mmap it. Return.
1219 return nil
1220 }
1221 y.AssertTrue(sz <= math.MaxUint32)
1222 lf.size = uint32(sz)
1223 if err = lf.mmap(sz); err != nil {
1224 _ = lf.fd.Close()
1225 return errors.Wrapf(err, "Unable to map file: %q", fstat.Name())
1226 }
1227 return nil
1228}
1229
1230func (vlog *valueLog) Close() error {
1231 if vlog == nil || vlog.db == nil || vlog.db.opt.InMemory {

Callers 4

doneWritingMethod · 0.95
openMethod · 0.45
OpenFunction · 0.45

Calls 4

mmapMethod · 0.95
AssertTrueFunction · 0.92
CloseMethod · 0.65
SizeMethod · 0.45

Tested by 1