MCPcopy Index your code
hub / github.com/ByteStorage/FlyDB / loadIndexFromHintFile

Method loadIndexFromHintFile

engine/merge.go:269–299  ·  view source on GitHub ↗

Load the index from the hint file

()

Source from the content-addressed store, hash-verified

267
268// Load the index from the hint file
269func (db *DB) loadIndexFromHintFile() error {
270 // Check whether the hint file exists
271 hintFileName := filepath.Join(db.options.DirPath, data2.HintFileSuffix)
272 if _, err := os.Stat(hintFileName); os.IsNotExist(err) {
273 return nil
274 }
275
276 // Open hint file
277 hintFile, err := data2.OpenHintFile(db.options.DirPath, db.options.DataFileSize, db.options.FIOType)
278 if err != nil {
279 return err
280 }
281
282 // Read the index in the file
283 var offset int64 = 0
284 for {
285 logRecord, size, err := hintFile.ReadLogRecord(offset)
286 if err != nil {
287 if err == io.EOF {
288 break
289 }
290 return err
291 }
292
293 // Decode to get the actual index location
294 pst := data2.DecodeLogRecordPst(logRecord.Value)
295 db.index.Put(logRecord.Key, pst)
296 offset += size
297 }
298 return nil
299}

Callers 1

NewDBFunction · 0.95

Calls 2

ReadLogRecordMethod · 0.80
PutMethod · 0.65

Tested by

no test coverage detected