Skip to content

Commit

Permalink
Change Variable name in openMergeDB (#228)
Browse files Browse the repository at this point in the history
Change the name of the db variable to mergeDB to avoid confusion

---------

Co-authored-by: roseduan <[email protected]>
  • Loading branch information
kebukeYi and roseduan authored Jul 17, 2023
1 parent 8a7cc33 commit c78249d
Showing 1 changed file with 5 additions and 6 deletions.
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

0 comments on commit c78249d

Please sign in to comment.