(dataFileIds []int64)
| 530 | } |
| 531 | |
| 532 | func (db *DB) parseDataFiles(dataFileIds []int64) (err error) { |
| 533 | var ( |
| 534 | off int64 |
| 535 | f *fileRecovery |
| 536 | fID int64 |
| 537 | dataInTx core.DataInTx |
| 538 | ) |
| 539 | |
| 540 | parseDataInTx := func() error { |
| 541 | for _, entry := range dataInTx.Es { |
| 542 | // if this bucket is not existed in bucket manager right now |
| 543 | // its because it already deleted in the feature WAL utils.GetLogger(). |
| 544 | // so we can just ignore here. |
| 545 | bucketId := entry.Meta.BucketId |
| 546 | if _, err := db.bucketMgr.GetBucketById(bucketId); errors.Is(err, ErrBucketNotExist) { |
| 547 | continue |
| 548 | } |
| 549 | |
| 550 | record := db.createRecordByModeWithFidAndOff(entry.Fid, uint64(entry.Off), &entry.Entry) |
| 551 | |
| 552 | if err = db.buildIdxes(record, &entry.Entry); err != nil { |
| 553 | return err |
| 554 | } |
| 555 | |
| 556 | db.KeyCount++ |
| 557 | |
| 558 | } |
| 559 | return nil |
| 560 | } |
| 561 | |
| 562 | readEntriesFromFile := func() error { |
| 563 | for { |
| 564 | entry, err := f.readEntry(off) |
| 565 | if err != nil { |
| 566 | // whatever which logic branch it will choose, we will release the fd. |
| 567 | _ = f.release() |
| 568 | if errors.Is(err, io.EOF) || errors.Is(err, ErrIndexOutOfBound) || errors.Is(err, io.ErrUnexpectedEOF) || errors.Is(err, ErrEntryZero) || errors.Is(err, core.ErrHeaderSizeOutOfBounds) { |
| 569 | break |
| 570 | } |
| 571 | if off >= db.opt.SegmentSize { |
| 572 | break |
| 573 | } |
| 574 | |
| 575 | return err |
| 576 | } |
| 577 | |
| 578 | if entry == nil { |
| 579 | break |
| 580 | } |
| 581 | |
| 582 | entryWhenRecovery := &core.EntryWhenRecovery{ |
| 583 | Entry: *entry, |
| 584 | Fid: fID, |
| 585 | Off: off, |
| 586 | } |
| 587 | if dataInTx.TxId == 0 { |
| 588 | dataInTx.AppendEntry(entryWhenRecovery) |
| 589 | dataInTx.TxId = entry.Meta.TxID |
no test coverage detected