Skip to content

Commit d26c655

Browse files
committed
db: remove version,versionEdit,versionList aliases
1 parent 09df085 commit d26c655

26 files changed

+114
-101
lines changed

checkpoint.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ func (d *DB) writeCheckpointManifest(
515515

516516
if len(excludedTables) > 0 || len(excludedBlobFiles) > 0 {
517517
// Write out an additional VersionEdit that deletes the excluded SST files.
518-
ve := versionEdit{
518+
ve := manifest.VersionEdit{
519519
DeletedTables: excludedTables,
520520
RemovedBackingTables: removeBackingTables,
521521
DeletedBlobFiles: excludedBlobFiles,

compaction.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ type compaction struct {
203203
comparer *base.Comparer
204204
formatKey base.FormatKey
205205
logger Logger
206-
version *version
206+
version *manifest.Version
207207
stats base.InternalIteratorStats
208208
beganAt time.Time
209209
// versionEditApplied is set to true when a compaction has completed and the
@@ -499,7 +499,7 @@ func (c *compaction) maybeSwitchToMoveOrCopy(
499499

500500
func newDeleteOnlyCompaction(
501501
opts *Options,
502-
cur *version,
502+
cur *manifest.Version,
503503
inputs []compactionLevel,
504504
beganAt time.Time,
505505
hints []deleteCompactionHint,
@@ -598,7 +598,7 @@ func adjustGrandparentOverlapBytesForFlush(c *compaction, flushingBytes uint64)
598598

599599
func newFlush(
600600
opts *Options,
601-
cur *version,
601+
cur *manifest.Version,
602602
l0Organizer *manifest.L0Organizer,
603603
baseLevel int,
604604
flushing flushableList,
@@ -739,7 +739,7 @@ func (c *compaction) hasExtraLevelData() bool {
739739
// errorOnUserKeyOverlap returns an error if the last two written sstables in
740740
// this compaction have revisions of the same user key present in both sstables,
741741
// when it shouldn't (eg. when splitting flushes).
742-
func (c *compaction) errorOnUserKeyOverlap(ve *versionEdit) error {
742+
func (c *compaction) errorOnUserKeyOverlap(ve *manifest.VersionEdit) error {
743743
if n := len(ve.NewTables); n > 1 {
744744
meta := ve.NewTables[n-1].Meta
745745
prevMeta := ve.NewTables[n-2].Meta
@@ -1336,7 +1336,7 @@ func (d *DB) runIngestFlush(c *compaction) (*manifest.VersionEdit, error) {
13361336
c.version = d.mu.versions.currentVersion()
13371337

13381338
baseLevel := d.mu.versions.picker.getBaseLevel()
1339-
ve := &versionEdit{}
1339+
ve := &manifest.VersionEdit{}
13401340
var ingestSplitFiles []ingestSplitFile
13411341
ingestFlushable := c.flushing[0].flushable.(*ingestedFlushable)
13421342

@@ -2245,7 +2245,7 @@ func (h *deleteCompactionHint) canDeleteOrExcise(
22452245
// The files that the resolved hints apply to, are returned as compactionLevels.
22462246
func checkDeleteCompactionHints(
22472247
cmp Compare,
2248-
v *version,
2248+
v *manifest.Version,
22492249
hints []deleteCompactionHint,
22502250
snapshots compact.Snapshots,
22512251
exciseEnabled bool,
@@ -2475,7 +2475,7 @@ func (d *DB) handleCompactFailure(c *compaction, err error) {
24752475
// for the application of a versionEdit that is no longer going to be applied.
24762476
//
24772477
// d.mu must be held when calling this method.
2478-
func (d *DB) cleanupVersionEdit(ve *versionEdit) {
2478+
func (d *DB) cleanupVersionEdit(ve *manifest.VersionEdit) {
24792479
obsoleteFiles := manifest.ObsoleteFiles{
24802480
TableBackings: make([]*manifest.TableBacking, 0, len(ve.NewTables)),
24812481
BlobFiles: make([]*manifest.BlobFileMetadata, 0, len(ve.NewBlobFiles)),
@@ -2619,7 +2619,7 @@ func (d *DB) compact1(c *compaction, errChannel chan error) (err error) {
26192619
// doing IO.
26202620
func (d *DB) runCopyCompaction(
26212621
jobID JobID, c *compaction,
2622-
) (ve *versionEdit, stats compact.Stats, _ error) {
2622+
) (ve *manifest.VersionEdit, stats compact.Stats, _ error) {
26232623
if c.cancel.Load() {
26242624
return nil, compact.Stats{}, ErrCancelledCompaction
26252625
}
@@ -2634,7 +2634,7 @@ func (d *DB) runCopyCompaction(
26342634
inputMeta.TableNum, inputMeta.BlobReferenceDepth, len(inputMeta.BlobReferences),
26352635
)
26362636
}
2637-
ve = &versionEdit{
2637+
ve = &manifest.VersionEdit{
26382638
DeletedTables: map[manifest.DeletedTableEntry]*manifest.TableMetadata{
26392639
{Level: c.startLevel.level, FileNum: inputMeta.TableNum}: inputMeta,
26402640
},
@@ -2808,7 +2808,7 @@ func (d *DB) applyHintOnFile(
28082808
f *manifest.TableMetadata,
28092809
level int,
28102810
levelMetrics *LevelMetrics,
2811-
ve *versionEdit,
2811+
ve *manifest.VersionEdit,
28122812
hintOverlap deletionHintOverlap,
28132813
) (newFiles []manifest.NewTableEntry, err error) {
28142814
if hintOverlap == hintDoesNotApply {
@@ -2844,7 +2844,7 @@ func (d *DB) applyHintOnFile(
28442844
func (d *DB) runDeleteOnlyCompactionForLevel(
28452845
cl compactionLevel,
28462846
levelMetrics *LevelMetrics,
2847-
ve *versionEdit,
2847+
ve *manifest.VersionEdit,
28482848
snapshots compact.Snapshots,
28492849
fragments []deleteCompactionHintFragment,
28502850
exciseEnabled bool,
@@ -2962,9 +2962,9 @@ func fragmentDeleteCompactionHints(
29622962
// d.mu must *not* be held when calling this.
29632963
func (d *DB) runDeleteOnlyCompaction(
29642964
jobID JobID, c *compaction, snapshots compact.Snapshots,
2965-
) (ve *versionEdit, stats compact.Stats, retErr error) {
2965+
) (ve *manifest.VersionEdit, stats compact.Stats, retErr error) {
29662966
fragments := fragmentDeleteCompactionHints(d.cmp, c.deletionHints)
2967-
ve = &versionEdit{
2967+
ve = &manifest.VersionEdit{
29682968
DeletedTables: map[manifest.DeletedTableEntry]*manifest.TableMetadata{},
29692969
}
29702970
for _, cl := range c.inputs {
@@ -3003,7 +3003,7 @@ func (d *DB) runDeleteOnlyCompaction(
30033003

30043004
func (d *DB) runMoveCompaction(
30053005
jobID JobID, c *compaction,
3006-
) (ve *versionEdit, stats compact.Stats, _ error) {
3006+
) (ve *manifest.VersionEdit, stats compact.Stats, _ error) {
30073007
iter := c.startLevel.files.Iter()
30083008
meta := iter.First()
30093009
if iter.Next() != nil {
@@ -3016,7 +3016,7 @@ func (d *DB) runMoveCompaction(
30163016
TableBytesMoved: meta.Size,
30173017
TablesMoved: 1,
30183018
}
3019-
ve = &versionEdit{
3019+
ve = &manifest.VersionEdit{
30203020
DeletedTables: map[manifest.DeletedTableEntry]*manifest.TableMetadata{
30213021
{Level: c.startLevel.level, FileNum: meta.TableNum}: meta,
30223022
},
@@ -3037,7 +3037,7 @@ func (d *DB) runMoveCompaction(
30373037
// re-acquired during the course of this method.
30383038
func (d *DB) runCompaction(
30393039
jobID JobID, c *compaction,
3040-
) (ve *versionEdit, stats compact.Stats, retErr error) {
3040+
) (ve *manifest.VersionEdit, stats compact.Stats, retErr error) {
30413041
if c.cancel.Load() {
30423042
return ve, stats, ErrCancelledCompaction
30433043
}
@@ -3278,8 +3278,8 @@ func (d *DB) compactAndWrite(
32783278

32793279
// makeVersionEdit creates the version edit for a compaction, based on the
32803280
// tables in compact.Result.
3281-
func (c *compaction) makeVersionEdit(result compact.Result) (*versionEdit, error) {
3282-
ve := &versionEdit{
3281+
func (c *compaction) makeVersionEdit(result compact.Result) (*manifest.VersionEdit, error) {
3282+
ve := &manifest.VersionEdit{
32833283
DeletedTables: map[manifest.DeletedTableEntry]*manifest.TableMetadata{},
32843284
}
32853285
for _, cl := range c.inputs {
@@ -3482,7 +3482,7 @@ func (d *DB) newCompactionOutputObj(
34823482
// validateVersionEdit validates that start and end keys across new and deleted
34833483
// files in a versionEdit pass the given validation function.
34843484
func validateVersionEdit(
3485-
ve *versionEdit, vk base.ValidateKey, format base.FormatKey, logger Logger,
3485+
ve *manifest.VersionEdit, vk base.ValidateKey, format base.FormatKey, logger Logger,
34863486
) {
34873487
validateKey := func(f *manifest.TableMetadata, key []byte) {
34883488
if err := vk.Validate(key); err != nil {

compaction_picker.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ type pickedCompaction struct {
204204
// The boundaries of the input data.
205205
smallest InternalKey
206206
largest InternalKey
207-
version *version
207+
version *manifest.Version
208208
l0Organizer *manifest.L0Organizer
209209
pickerMetrics pickedCompactionMetrics
210210
}
@@ -226,7 +226,7 @@ func defaultOutputLevel(startLevel, baseLevel int) int {
226226

227227
func newPickedCompaction(
228228
opts *Options,
229-
cur *version,
229+
cur *manifest.Version,
230230
l0Organizer *manifest.L0Organizer,
231231
startLevel, outputLevel, baseLevel int,
232232
) *pickedCompaction {
@@ -268,7 +268,7 @@ func adjustedOutputLevel(outputLevel int, baseLevel int) int {
268268
func newPickedCompactionFromL0(
269269
lcf *manifest.L0CompactionFiles,
270270
opts *Options,
271-
vers *version,
271+
vers *manifest.Version,
272272
l0Organizer *manifest.L0Organizer,
273273
baseLevel int,
274274
isBase bool,
@@ -579,7 +579,7 @@ func canCompactTables(
579579
// the newest version. The picker is used under logLock (until a new version is
580580
// installed).
581581
func newCompactionPickerByScore(
582-
v *version,
582+
v *manifest.Version,
583583
l0Organizer *manifest.L0Organizer,
584584
virtualBackings *manifest.VirtualBackings,
585585
opts *Options,
@@ -674,7 +674,7 @@ func totalCompensatedSize(iter iter.Seq[*manifest.TableMetadata]) uint64 {
674674
// picker is created and initialized every time a new version is installed.
675675
type compactionPickerByScore struct {
676676
opts *Options
677-
vers *version
677+
vers *manifest.Version
678678
// Unlike vers, which is immutable and the latest version when this picker is
679679
// created, l0Organizer represents the mutable L0 state of the latest version.
680680
// This means that at some point in the future a compactionPickerByScore
@@ -1024,7 +1024,7 @@ func (p *compactionPickerByScore) calculateLevelScores(
10241024
// L0 is special in that files within L0 may overlap one another, so a different
10251025
// set of heuristics that take into account read amplification apply.
10261026
func calculateL0FillFactor(
1027-
vers *version,
1027+
vers *manifest.Version,
10281028
l0Organizer *manifest.L0Organizer,
10291029
opts *Options,
10301030
inProgressCompactions []compactionInfo,
@@ -1063,7 +1063,7 @@ func calculateL0FillFactor(
10631063
// function is linear with respect to the number of files in `level` and
10641064
// `outputLevel`.
10651065
func pickCompactionSeedFile(
1066-
vers *version,
1066+
vers *manifest.Version,
10671067
virtualBackings *manifest.VirtualBackings,
10681068
opts *Options,
10691069
level, outputLevel int,
@@ -1683,7 +1683,7 @@ func (p *compactionPickerByScore) pickTombstoneDensityCompaction(
16831683
func pickAutoLPositive(
16841684
env compactionEnv,
16851685
opts *Options,
1686-
vers *version,
1686+
vers *manifest.Version,
16871687
l0Organizer *manifest.L0Organizer,
16881688
cInfo candidateLevelInfo,
16891689
baseLevel int,
@@ -1839,7 +1839,11 @@ func (wa WriteAmpHeuristic) String() string {
18391839
// Helper method to pick compactions originating from L0. Uses information about
18401840
// sublevels to generate a compaction.
18411841
func pickL0(
1842-
env compactionEnv, opts *Options, vers *version, l0Organizer *manifest.L0Organizer, baseLevel int,
1842+
env compactionEnv,
1843+
opts *Options,
1844+
vers *manifest.Version,
1845+
l0Organizer *manifest.L0Organizer,
1846+
baseLevel int,
18431847
) *pickedCompaction {
18441848
// It is important to pass information about Lbase files to L0Sublevels
18451849
// so it can pick a compaction that does not conflict with an Lbase => Lbase+1
@@ -1886,7 +1890,7 @@ func pickL0(
18861890
}
18871891

18881892
func newPickedManualCompaction(
1889-
vers *version,
1893+
vers *manifest.Version,
18901894
l0Organizer *manifest.L0Organizer,
18911895
opts *Options,
18921896
env compactionEnv,
@@ -1949,7 +1953,7 @@ func newPickedManualCompaction(
19491953
// which could be specified as being performed either by a copy compaction of
19501954
// the backing file or a rewrite compaction.
19511955
func pickDownloadCompaction(
1952-
vers *version,
1956+
vers *manifest.Version,
19531957
l0Organizer *manifest.L0Organizer,
19541958
opts *Options,
19551959
env compactionEnv,

compaction_picker_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030

3131
func loadVersion(
3232
t *testing.T, d *datadriven.TestData,
33-
) (*version, *manifest.L0Organizer, *Options, string) {
33+
) (*manifest.Version, *manifest.L0Organizer, *Options, string) {
3434
var sizes [numLevels]int64
3535
opts := &Options{}
3636
opts.testingRandomized(t)
@@ -146,7 +146,7 @@ func TestCompactionPickerByScoreLevelMaxBytes(t *testing.T) {
146146
}
147147

148148
func TestCompactionPickerTargetLevel(t *testing.T) {
149-
var vers *version
149+
var vers *manifest.Version
150150
var l0Organizer *manifest.L0Organizer
151151
var opts *Options
152152
var pickerByScore *compactionPickerByScore

compaction_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ import (
4343
"github.com/stretchr/testify/require"
4444
)
4545

46-
func newVersion(opts *Options, files [numLevels][]*manifest.TableMetadata) *version {
46+
func newVersion(opts *Options, files [numLevels][]*manifest.TableMetadata) *manifest.Version {
4747
v, _ := newVersionAndL0Organizer(opts, files)
4848
return v
4949
}
5050

5151
func newVersionAndL0Organizer(
5252
opts *Options, files [numLevels][]*manifest.TableMetadata,
53-
) (*version, *manifest.L0Organizer) {
53+
) (*manifest.Version, *manifest.L0Organizer) {
5454
l0Organizer := manifest.NewL0Organizer(opts.Comparer, opts.FlushSplitBytes)
5555
v := manifest.NewVersionForTesting(
5656
opts.Comparer,
@@ -702,13 +702,13 @@ func TestValidateVersionEdit(t *testing.T) {
702702

703703
testCases := []struct {
704704
desc string
705-
ve *versionEdit
705+
ve *manifest.VersionEdit
706706
vFunc func([]byte) error
707707
wantErr error
708708
}{
709709
{
710710
desc: "single new file; start key",
711-
ve: &versionEdit{
711+
ve: &manifest.VersionEdit{
712712
NewTables: []manifest.NewTableEntry{
713713
{
714714
Meta: newFileMeta(
@@ -723,7 +723,7 @@ func TestValidateVersionEdit(t *testing.T) {
723723
},
724724
{
725725
desc: "single new file; end key",
726-
ve: &versionEdit{
726+
ve: &manifest.VersionEdit{
727727
NewTables: []manifest.NewTableEntry{
728728
{
729729
Meta: newFileMeta(
@@ -738,7 +738,7 @@ func TestValidateVersionEdit(t *testing.T) {
738738
},
739739
{
740740
desc: "multiple new files",
741-
ve: &versionEdit{
741+
ve: &manifest.VersionEdit{
742742
NewTables: []manifest.NewTableEntry{
743743
{
744744
Meta: newFileMeta(
@@ -759,7 +759,7 @@ func TestValidateVersionEdit(t *testing.T) {
759759
},
760760
{
761761
desc: "single deleted file; start key",
762-
ve: &versionEdit{
762+
ve: &manifest.VersionEdit{
763763
DeletedTables: map[manifest.DeletedTableEntry]*manifest.TableMetadata{
764764
{Level: 0, FileNum: 0}: newFileMeta(
765765
manifest.InternalKey{UserKey: []byte(badKey)},
@@ -772,7 +772,7 @@ func TestValidateVersionEdit(t *testing.T) {
772772
},
773773
{
774774
desc: "single deleted file; end key",
775-
ve: &versionEdit{
775+
ve: &manifest.VersionEdit{
776776
DeletedTables: map[manifest.DeletedTableEntry]*manifest.TableMetadata{
777777
{Level: 0, FileNum: 0}: newFileMeta(
778778
manifest.InternalKey{UserKey: []byte("a")},
@@ -785,7 +785,7 @@ func TestValidateVersionEdit(t *testing.T) {
785785
},
786786
{
787787
desc: "multiple deleted files",
788-
ve: &versionEdit{
788+
ve: &manifest.VersionEdit{
789789
DeletedTables: map[manifest.DeletedTableEntry]*manifest.TableMetadata{
790790
{Level: 0, FileNum: 0}: newFileMeta(
791791
manifest.InternalKey{UserKey: []byte("a")},
@@ -802,7 +802,7 @@ func TestValidateVersionEdit(t *testing.T) {
802802
},
803803
{
804804
desc: "no errors",
805-
ve: &versionEdit{
805+
ve: &manifest.VersionEdit{
806806
NewTables: []manifest.NewTableEntry{
807807
{
808808
Level: 0,
@@ -2185,7 +2185,7 @@ func TestCompactionErrorOnUserKeyOverlap(t *testing.T) {
21852185
}
21862186

21872187
result := "OK"
2188-
ve := &versionEdit{
2188+
ve := &manifest.VersionEdit{
21892189
NewTables: files,
21902190
}
21912191
if err := c.errorOnUserKeyOverlap(ve); err != nil {
@@ -3163,7 +3163,7 @@ func TestCompactionCorruption(t *testing.T) {
31633163
}
31643164

31653165
func hasExternalFiles(d *DB) bool {
3166-
v := func() *version {
3166+
v := func() *manifest.Version {
31673167
d.mu.Lock()
31683168
defer d.mu.Unlock()
31693169

0 commit comments

Comments
 (0)