68 lines
1.2 KiB
Go
68 lines
1.2 KiB
Go
|
package mdb
|
||
|
|
||
|
/*
|
||
|
func (db *Database) openPrimary() (err error) {
|
||
|
wal, err := cwal.Open(db.walRootDir, cwal.Config{
|
||
|
SegMinCount: db.conf.WALSegMinCount,
|
||
|
SegMaxAgeSec: db.conf.WALSegMaxAgeSec,
|
||
|
})
|
||
|
|
||
|
pFile, err := pfile.Open(db.pageFilePath,
|
||
|
|
||
|
pFile, err := openPageFileAndReplayWAL(db.rootDir)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
defer pFile.Close()
|
||
|
|
||
|
pfHeader, err := pFile.ReadHeader()
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
tx := db.Snapshot()
|
||
|
tx.seqNum = pfHeader.SeqNum
|
||
|
tx.updatedAt = pfHeader.UpdatedAt
|
||
|
|
||
|
pIndex, err := pagefile.NewIndex(pFile)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
err = pFile.IterateAllocated(pIndex, func(cID, iID uint64, data []byte) error {
|
||
|
return db.loadItem(tx, cID, iID, data)
|
||
|
})
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
w, err := cwal.OpenWriter(db.walRootDir, &cwal.WriterConfig{
|
||
|
SegMinCount: db.conf.WALSegMinCount,
|
||
|
SegMaxAgeSec: db.conf.WALSegMaxAgeSec,
|
||
|
})
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
db.done.Add(1)
|
||
|
go txAggregator{
|
||
|
Stop: db.stop,
|
||
|
Done: db.done,
|
||
|
ModChan: db.modChan,
|
||
|
W: w,
|
||
|
Index: pIndex,
|
||
|
Snapshot: db.snapshot,
|
||
|
}.Run()
|
||
|
|
||
|
db.done.Add(1)
|
||
|
go (&fileWriter{
|
||
|
Stop: db.stop,
|
||
|
Done: db.done,
|
||
|
PageFilePath: db.pageFilePath,
|
||
|
WALRootDir: db.walRootDir,
|
||
|
}).Run()
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
*/
|