Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

更改变量名称 #228

Merged
merged 2 commits into from
Jul 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const (
// So it is recommended to perform this operation when the database is idle.
func (db *DB) Merge() error {
db.mu.Lock()
// check if the daabase is closed
// check if the database is closed
if db.closed {
db.mu.Unlock()
return ErrDBClosed
Expand Down Expand Up @@ -129,13 +129,12 @@ func (db *DB) openMergeDB() (*DB, error) {
if err := os.RemoveAll(mergePath); err != nil {
return nil, err
}

options := db.options
// we don't need to use the original sync policy,
// because we can sync the data file manually after the merge operation is completed.
options.Sync, options.BytesPerSync = false, 0
options.DirPath = mergePath
db, err := Open(options)
mergeDB, err := Open(options)
if err != nil {
return nil, err
}
Expand All @@ -153,9 +152,8 @@ func (db *DB) openMergeDB() (*DB, error) {
if err != nil {
return nil, err
}

db.hintFile = hintFile
return db, nil
mergeDB.hintFile = hintFile
return mergeDB, nil
}

func mergeDirPath(dirPath string) string {
Expand Down Expand Up @@ -339,6 +337,7 @@ func (db *DB) loadIndexFromHintFile() error {
}
return err
}

key, position := decodeHintRecord(chunk)
// All the hint records are valid because it is generated by the merge operation.
// So just put them into the index without checking.
Expand Down