Skip to content

Commit a50aabc

Browse files
committed
db: simplify L0 picked compaction input construction
The newPickedCompactionFromL0 function unnecessarily iterated over the provided L0CompactionFiles, constructing a []*TableMetadata slice. The L0CompactionFiles type already provides a []*TableMetadata slice. The slice is only needed to construct the B-Tree that will back the manifest.LevelSlice, so there's no need to clone it.
1 parent 27c7548 commit a50aabc

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

compaction_picker.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -291,13 +291,7 @@ func newPickedCompactionFromL0(
291291
// any overlapping L0 SSTables that need to be added, and
292292
// because compactions built by L0SSTables do not necessarily
293293
// pick contiguous sequences of files in pc.version.Levels[0].
294-
files := make([]*manifest.TableMetadata, 0, len(lcf.Files))
295-
for f := range vers.Levels[0].All() {
296-
if lcf.FilesIncluded[f.L0Index] {
297-
files = append(files, f)
298-
}
299-
}
300-
pc.startLevel.files = manifest.NewLevelSliceSeqSorted(files)
294+
pc.startLevel.files = manifest.NewLevelSliceSeqSorted(lcf.Files)
301295
return pc
302296
}
303297

0 commit comments

Comments
 (0)