@@ -424,7 +424,7 @@ func newCompaction(
424424 if mustCopy {
425425 // If the source is virtual, it's best to just rewrite the file as all
426426 // conditions in the above comment are met.
427- if ! meta .Virtual {
427+ if meta .Virtual == nil {
428428 c .kind = compactionKindCopy
429429 }
430430 } else {
@@ -966,7 +966,7 @@ func (c *compaction) newRangeDelIter(
966966 iterSet , err := newIters (context .Background (), f .TableMetadata , & opts ,
967967 internalIterOpts {
968968 compaction : true ,
969- readEnv : block.ReadEnv {BufferPool : & c .bufferPool },
969+ readEnv : sstable. ReadEnv { Block : block.ReadEnv {BufferPool : & c .bufferPool } },
970970 }, iterRangeDeletions )
971971 if err != nil {
972972 return nil , err
@@ -1310,8 +1310,8 @@ func (d *DB) runIngestFlush(c *compaction) (*manifest.VersionEdit, error) {
13101310
13111311 // This file fits perfectly within the excise span, so we can slot it at L6.
13121312 if ingestFlushable .exciseSpan .Valid () &&
1313- ingestFlushable .exciseSpan .Contains (d .cmp , file .TableMetadata . Smallest ) &&
1314- ingestFlushable .exciseSpan .Contains (d .cmp , file .TableMetadata . Largest ) {
1313+ ingestFlushable .exciseSpan .Contains (d .cmp , file .Smallest ) &&
1314+ ingestFlushable .exciseSpan .Contains (d .cmp , file .Largest ) {
13151315 level = 6
13161316 } else {
13171317 // TODO(radu): this can perform I/O; we should not do this while holding DB.mu.
@@ -1320,18 +1320,18 @@ func (d *DB) runIngestFlush(c *compaction) (*manifest.VersionEdit, error) {
13201320 return nil , err
13211321 }
13221322 level , fileToSplit , err = ingestTargetLevel (
1323- ctx , d .cmp , lsmOverlap , baseLevel , d .mu .compact .inProgress , file . TableMetadata , suggestSplit ,
1323+ ctx , d .cmp , lsmOverlap , baseLevel , d .mu .compact .inProgress , file , suggestSplit ,
13241324 )
13251325 if err != nil {
13261326 return nil , err
13271327 }
13281328 }
13291329
13301330 // Add the current flushableIngest file to the version.
1331- ve .NewTables = append (ve .NewTables , newTableEntry {Level : level , Meta : file . TableMetadata })
1331+ ve .NewTables = append (ve .NewTables , newTableEntry {Level : level , Meta : file })
13321332 if fileToSplit != nil {
13331333 ingestSplitFiles = append (ingestSplitFiles , ingestSplitFile {
1334- ingestFile : file . TableMetadata ,
1334+ ingestFile : file ,
13351335 splitFile : fileToSplit ,
13361336 level : level ,
13371337 })
@@ -2401,7 +2401,7 @@ func (d *DB) cleanupVersionEdit(ve *versionEdit) {
24012401 deletedFiles [key .FileNum ] = struct {}{}
24022402 }
24032403 for i := range ve .NewTables {
2404- if ve .NewTables [i ].Meta .Virtual {
2404+ if ve .NewTables [i ].Meta .Virtual != nil {
24052405 // We handle backing files separately.
24062406 continue
24072407 }
@@ -2561,8 +2561,8 @@ func (d *DB) runCopyCompaction(
25612561 panic ("pebble: scheduled a copy compaction that is not actually moving files to shared storage" )
25622562 }
25632563 // Note that based on logic in the compaction picker, we're guaranteed
2564- // inputMeta.Virtual is false .
2565- if inputMeta .Virtual {
2564+ // inputMeta.Virtual is nil .
2565+ if inputMeta .Virtual != nil {
25662566 panic (errors .AssertionFailedf ("cannot do a copy compaction of a virtual sstable across local/remote storage" ))
25672567 }
25682568 }
@@ -2660,12 +2660,12 @@ func (d *DB) runCopyCompaction(
26602660
26612661 // NB: external files are always virtual.
26622662 var wrote uint64
2663- err = d .fileCache .withVirtualReader (ctx , block .NoReadEnv , inputMeta .VirtualMeta (), func (r sstable.VirtualReader , _ block .ReadEnv ) error {
2663+ err = d .fileCache .withReader (ctx , block .NoReadEnv , inputMeta .VirtualMeta (), func (r * sstable.Reader , env sstable .ReadEnv ) error {
26642664 var err error
26652665 // TODO(radu): plumb a ReadEnv to CopySpan (it could use the buffer pool
26662666 // or update category stats).
26672667 wrote , err = sstable .CopySpan (ctx ,
2668- src , r . UnsafeReader () , d .opts .MakeReaderOptions (),
2668+ src , r , d .opts .MakeReaderOptions (),
26692669 w , d .opts .MakeWriterOptions (c .outputLevel .level , d .TableFormat ()),
26702670 start , end ,
26712671 )
@@ -2700,7 +2700,7 @@ func (d *DB) runCopyCompaction(
27002700 Level : c .outputLevel .level ,
27012701 Meta : newMeta ,
27022702 }}
2703- if newMeta .Virtual {
2703+ if newMeta .Virtual != nil {
27042704 ve .CreatedBackingTables = []* fileBacking {newMeta .FileBacking }
27052705 }
27062706 c .metrics [c .outputLevel .level ] = & LevelMetrics {
@@ -2904,7 +2904,7 @@ func (d *DB) runDeleteOnlyCompaction(
29042904 // NewFiles.
29052905 usedBackingFiles := make (map [base.DiskFileNum ]struct {})
29062906 for _ , e := range ve .NewTables {
2907- if e .Meta .Virtual {
2907+ if e .Meta .Virtual != nil {
29082908 usedBackingFiles [e .Meta .FileBacking .DiskFileNum ] = struct {}{}
29092909 }
29102910 }
@@ -3078,18 +3078,18 @@ func (d *DB) compactAndWrite(
30783078 // translate to 3 MiB per compaction.
30793079 c .bufferPool .Init (12 )
30803080 defer c .bufferPool .Release ()
3081- env := block.ReadEnv {
3081+ blockReadEnv := block.ReadEnv {
30823082 BufferPool : & c .bufferPool ,
30833083 Stats : & c .stats ,
30843084 IterStats : d .fileCache .SSTStatsCollector ().Accumulator (
30853085 uint64 (uintptr (unsafe .Pointer (c ))),
30863086 categoryCompaction ,
30873087 ),
30883088 }
3089- c .valueFetcher .Init (d .fileCache , env )
3089+ c .valueFetcher .Init (d .fileCache , blockReadEnv )
30903090 iiopts := internalIterOpts {
30913091 compaction : true ,
3092- readEnv : env ,
3092+ readEnv : sstable. ReadEnv { Block : blockReadEnv } ,
30933093 blobValueFetcher : & c .valueFetcher ,
30943094 }
30953095
0 commit comments