@@ -30,7 +30,6 @@ import (
3030 "github.com/cockroachdb/pebble/internal/sstableinternal"
3131 "github.com/cockroachdb/pebble/objstorage"
3232 "github.com/cockroachdb/pebble/objstorage/objstorageprovider/objiotracing"
33- "github.com/cockroachdb/pebble/objstorage/remote"
3433 "github.com/cockroachdb/pebble/sstable"
3534 "github.com/cockroachdb/pebble/sstable/blob"
3635 "github.com/cockroachdb/pebble/sstable/block"
@@ -251,7 +250,7 @@ type tableCompaction struct {
251250 // b) rewrite blob files: The compaction will write eligible values to new
252251 // blob files. This consumes more write bandwidth because all values are
253252 // rewritten. However it restores locality.
254- getValueSeparation func (JobID , * tableCompaction , sstable. TableFormat ) compact.ValueSeparation
253+ getValueSeparation func (JobID , * tableCompaction ) compact.ValueSeparation
255254
256255 // startLevel is the level that is being compacted. Inputs from startLevel
257256 // and outputLevel will be merged to produce a set of outputLevel files.
@@ -336,7 +335,6 @@ type tableCompaction struct {
336335
337336 grantHandle CompactionGrantHandle
338337
339- tableFormat sstable.TableFormat
340338 objCreateOpts objstorage.CreateOptions
341339
342340 annotations []string
@@ -544,7 +542,7 @@ func (c *tableCompaction) makeInfo(jobID JobID) CompactionInfo {
544542 return info
545543}
546544
547- type getValueSeparation func (JobID , * tableCompaction , sstable. TableFormat ) compact.ValueSeparation
545+ type getValueSeparation func (JobID , * tableCompaction ) compact.ValueSeparation
548546
549547// newCompaction constructs a compaction from the provided picked compaction.
550548//
@@ -556,7 +554,7 @@ func newCompaction(
556554 beganAt time.Time ,
557555 provider objstorage.Provider ,
558556 grantHandle CompactionGrantHandle ,
559- tableFormat sstable. TableFormat ,
557+ preferSharedStorage bool ,
560558 getValueSeparation getValueSeparation ,
561559) * tableCompaction {
562560 c := & tableCompaction {
@@ -574,7 +572,6 @@ func newCompaction(
574572 picker : pc .pickerMetrics ,
575573 },
576574 grantHandle : grantHandle ,
577- tableFormat : tableFormat ,
578575 }
579576 // Acquire a reference to the version to ensure that files and in-memory
580577 // version state necessary for reading files remain available. Ignoring
@@ -615,8 +612,6 @@ func newCompaction(
615612 )
616613 c .kind = pc .kind
617614
618- preferSharedStorage := tableFormat >= FormatMinForSharedObjects .MaxTableFormat () &&
619- remote .ShouldCreateShared (opts .Experimental .CreateOnShared , c .outputLevel .level )
620615 c .maybeSwitchToMoveOrCopy (preferSharedStorage , provider )
621616 c .objCreateOpts = objstorage.CreateOptions {
622617 PreferSharedStorage : preferSharedStorage ,
@@ -833,7 +828,7 @@ func newFlush(
833828 baseLevel int ,
834829 flushing flushableList ,
835830 beganAt time.Time ,
836- tableFormat sstable. TableFormat ,
831+ preferSharedStorage bool ,
837832 getValueSeparation getValueSeparation ,
838833) (* tableCompaction , error ) {
839834 c := & tableCompaction {
@@ -845,7 +840,6 @@ func newFlush(
845840 maxOutputFileSize : math .MaxUint64 ,
846841 maxOverlapBytes : math .MaxUint64 ,
847842 grantHandle : noopGrantHandle {},
848- tableFormat : tableFormat ,
849843 metrics : compactionMetrics {
850844 beganAt : beganAt ,
851845 },
@@ -872,8 +866,6 @@ func newFlush(
872866 }
873867 }
874868
875- preferSharedStorage := tableFormat >= FormatMinForSharedObjects .MaxTableFormat () &&
876- remote .ShouldCreateShared (opts .Experimental .CreateOnShared , c .outputLevel .level )
877869 c .objCreateOpts = objstorage.CreateOptions {
878870 PreferSharedStorage : preferSharedStorage ,
879871 WriteCategory : getDiskWriteCategoryForCompaction (opts , c .kind ),
@@ -1722,8 +1714,16 @@ func (d *DB) flush1() (bytesFlushed uint64, err error) {
17221714 }
17231715 }
17241716
1725- c , err := newFlush (d .opts , d .mu .versions .currentVersion (), d .mu .versions .latest .l0Organizer ,
1726- d .mu .versions .picker .getBaseLevel (), d .mu .mem .queue [:n ], d .timeNow (), d .TableFormat (), d .determineCompactionValueSeparation )
1717+ c , err := newFlush (
1718+ d .opts ,
1719+ d .mu .versions .currentVersion (),
1720+ d .mu .versions .latest .l0Organizer ,
1721+ d .mu .versions .picker .getBaseLevel (),
1722+ d .mu .mem .queue [:n ],
1723+ d .timeNow (),
1724+ d .shouldCreateShared (0 ),
1725+ d .determineCompactionValueSeparation ,
1726+ )
17271727 if err != nil {
17281728 return 0 , err
17291729 }
@@ -2921,12 +2921,7 @@ func (d *DB) runCopyCompaction(
29212921 }
29222922 }()
29232923
2924- w , _ , err := d .objProvider .Create (
2925- ctx , base .FileTypeTable , newMeta .TableBacking .DiskFileNum ,
2926- objstorage.CreateOptions {
2927- PreferSharedStorage : d .shouldCreateShared (c .outputLevel .level ),
2928- },
2929- )
2924+ w , _ , err := d .objProvider .Create (ctx , base .FileTypeTable , newMeta .TableBacking .DiskFileNum , c .objCreateOpts )
29302925 if err != nil {
29312926 return nil , compact.Stats {}, []compact.OutputBlob {}, err
29322927 }
@@ -2954,7 +2949,7 @@ func (d *DB) runCopyCompaction(
29542949 // or update category stats).
29552950 wrote , err = sstable .CopySpan (ctx ,
29562951 src , r , c .startLevel .level ,
2957- w , d .opts . MakeWriterOptions (c .outputLevel .level , d . TableFormat () ),
2952+ w , d .makeWriterOptions (c .outputLevel .level ),
29582953 start , end ,
29592954 )
29602955 return err
@@ -3306,9 +3301,9 @@ func (d *DB) runDefaultTableCompaction(
33063301 defer d .mu .Lock ()
33073302
33083303 // Determine whether we should separate values into blob files.
3309- valueSeparation := c .getValueSeparation (jobID , c , c . tableFormat )
3304+ valueSeparation := c .getValueSeparation (jobID , c )
33103305
3311- result := d .compactAndWrite (jobID , c , snapshots , c . tableFormat , valueSeparation )
3306+ result := d .compactAndWrite (jobID , c , snapshots , valueSeparation )
33123307 if result .Err == nil {
33133308 ve , result .Err = c .makeVersionEdit (result )
33143309 }
@@ -3352,7 +3347,6 @@ func (d *DB) compactAndWrite(
33523347 jobID JobID ,
33533348 c * tableCompaction ,
33543349 snapshots compact.Snapshots ,
3355- tableFormat sstable.TableFormat ,
33563350 valueSeparation compact.ValueSeparation ,
33573351) (result compact.Result ) {
33583352 suggestedCacheReaders := blob .SuggestedCachedReaders (len (c .inputs ))
@@ -3469,7 +3463,7 @@ func (d *DB) compactAndWrite(
34693463 spanPolicyValid = true
34703464 }
34713465
3472- writerOpts := d .opts . MakeWriterOptions (c .outputLevel .level , tableFormat )
3466+ writerOpts := d .makeWriterOptions (c .outputLevel .level )
34733467 if spanPolicy .DisableValueSeparationBySuffix {
34743468 writerOpts .DisableValueBlocks = true
34753469 }
0 commit comments