MCPcopy Create free account
hub / github.com/nutsdb/nutsdb / rotateActiveFile

Method rotateActiveFile

tx.go:482–505  ·  view source on GitHub ↗

rotateActiveFile rotates log file when active file is not enough space to store the entry.

()

Source from the content-addressed store, hash-verified

480
481// rotateActiveFile rotates log file when active file is not enough space to store the entry.
482func (tx *Tx) rotateActiveFile() error {
483 var err error
484 tx.db.MaxFileID++
485
486 if !tx.db.opt.SyncEnable && tx.db.opt.RWMode == MMap {
487 if err := tx.db.ActiveFile.rwManager.Sync(); err != nil {
488 return err
489 }
490 }
491
492 if err := tx.db.ActiveFile.rwManager.Release(); err != nil {
493 return err
494 }
495
496 // reset ActiveFile
497 path := getDataPath(tx.db.MaxFileID, tx.db.opt.Dir)
498 tx.db.ActiveFile, err = tx.db.fm.GetDataFile(path, tx.db.opt.SegmentSize)
499 if err != nil {
500 return err
501 }
502
503 tx.db.ActiveFile.fileID = tx.db.MaxFileID
504 return nil
505}
506
507func (tx *Tx) writeData(data []byte) (n int, err error) {
508 if len(data) == 0 {

Callers 1

CommitMethod · 0.95

Calls 4

getDataPathFunction · 0.85
GetDataFileMethod · 0.80
SyncMethod · 0.65
ReleaseMethod · 0.65

Tested by

no test coverage detected