Skip to content

Commit

Permalink
compaction: remove the duplicated function mergeFileInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
lonng authored and jbowens committed Oct 16, 2023
1 parent bbbf3df commit 8c13366
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions compaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -3725,7 +3725,7 @@ func (d *DB) scanObsoleteFiles(list []string) {

d.mu.log.queue = merge(d.mu.log.queue, obsoleteLogs)
d.mu.versions.metrics.WAL.Files = int64(len(d.mu.log.queue))
d.mu.versions.obsoleteTables = mergeFileInfo(d.mu.versions.obsoleteTables, obsoleteTables)
d.mu.versions.obsoleteTables = merge(d.mu.versions.obsoleteTables, obsoleteTables)
d.mu.versions.updateObsoleteTableMetricsLocked()
d.mu.versions.obsoleteManifests = merge(d.mu.versions.obsoleteManifests, obsoleteManifests)
d.mu.versions.obsoleteOptions = merge(d.mu.versions.obsoleteOptions, obsoleteOptions)
Expand Down Expand Up @@ -3904,26 +3904,6 @@ func merge(a, b []fileInfo) []fileInfo {
return a[:n]
}

func mergeFileInfo(a, b []fileInfo) []fileInfo {
if len(b) == 0 {
return a
}

a = append(a, b...)
sort.Slice(a, func(i, j int) bool {
return a[i].fileNum.FileNum() < a[j].fileNum.FileNum()
})

n := 0
for i := 0; i < len(a); i++ {
if n == 0 || a[i].fileNum != a[n-1].fileNum {
a[n] = a[i]
n++
}
}
return a[:n]
}

func max[I constraints.Ordered](a, b I) I {
if b > a {
return b
Expand Down

0 comments on commit 8c13366

Please sign in to comment.