Skip to content

Commit

Permalink
Fix the check for an empty compaction
Browse files Browse the repository at this point in the history
This shouldn't every happen, but the check should be correct at least.
  • Loading branch information
petermattis committed Aug 3, 2019
1 parent 98e02fa commit 594aeda
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions compaction_picker.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ func (p *compactionPicker) estimatedCompactionDebt(l0ExtraSize uint64) uint64 {
compactionDebt += (levelSize * bytesAddedToNextLevel) / estimatedL0CompactionSize

var nextLevelSize uint64
for level := p.baseLevel; level < numLevels - 1; level++ {
for level := p.baseLevel; level < numLevels-1; level++ {
levelSize += bytesAddedToNextLevel
bytesAddedToNextLevel = 0
nextLevelSize = totalSize(p.vers.files[level + 1])
nextLevelSize = totalSize(p.vers.files[level+1])
if levelSize > uint64(p.levelMaxBytes[level]) {
bytesAddedToNextLevel = levelSize - uint64(p.levelMaxBytes[level])
levelRatio := float64(nextLevelSize)/float64(levelSize)
levelRatio := float64(nextLevelSize) / float64(levelSize)
compactionDebt += uint64(float64(bytesAddedToNextLevel) * (levelRatio + 1))
}
levelSize = nextLevelSize
Expand Down Expand Up @@ -153,7 +153,7 @@ func (p *compactionPicker) initLevelMaxBytes(v *version, opts *Options) {
p.smoothedLevelMultiplier = 1.0
}

p.estimatedMaxWAmp = float64(numLevels - p.baseLevel) * (p.smoothedLevelMultiplier + 1)
p.estimatedMaxWAmp = float64(numLevels-p.baseLevel) * (p.smoothedLevelMultiplier + 1)

levelSize := float64(baseBytesMax)
for level := p.baseLevel; level < numLevels; level++ {
Expand Down Expand Up @@ -265,7 +265,7 @@ func (p *compactionPicker) pickAuto(opts *Options) (c *compaction) {
cmp := opts.Comparer.Compare
smallest, largest := ikeyRange(cmp, c.inputs[0], nil)
c.inputs[0] = vers.overlaps(0, cmp, smallest.UserKey, largest.UserKey)
if len(c.inputs) == 0 {
if len(c.inputs[0]) == 0 {
panic("pebble: empty compaction")
}
}
Expand Down

0 comments on commit 594aeda

Please sign in to comment.