Skip to content

Commit 9b5d34b

Browse files
committed
manifest: minor cleanup of init backing methods
1 parent 2f8f1c8 commit 9b5d34b

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

compaction.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2593,7 +2593,7 @@ func (d *DB) runCopyCompaction(
25932593
if objMeta.IsExternal() {
25942594
// external -> local/shared copy. File must be virtual.
25952595
// We will update this size later after we produce the new backing file.
2596-
newMeta.InitProviderBacking(base.DiskFileNum(newMeta.FileNum), inputMeta.FileBacking.Size)
2596+
newMeta.InitVirtualBacking(base.DiskFileNum(newMeta.FileNum), inputMeta.FileBacking.Size)
25972597
} else {
25982598
// local -> shared copy. New file is guaranteed to not be virtual.
25992599
newMeta.InitPhysicalBacking()

ingest.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func ingestSynthesizeShared(
129129
// This ensures that we don't over-prioritize this sstable for compaction just
130130
// yet, as we do not have a clear sense of what parts of this sstable are
131131
// referenced by other nodes.
132-
meta.InitProviderBacking(base.DiskFileNum(fileNum), sm.Size)
132+
meta.InitVirtualBacking(base.DiskFileNum(fileNum), sm.Size)
133133

134134
if sm.LargestPointKey.Valid() && sm.LargestPointKey.UserKey != nil {
135135
// Initialize meta.{HasPointKeys,Smallest,Largest}, etc.
@@ -768,7 +768,7 @@ func (d *DB) ingestAttachRemote(jobID JobID, lr ingestLoadResult) error {
768768
// We have to attach the remote object (and assign it a DiskFileNum). For
769769
// simplicity, we use the same number for both the FileNum and the
770770
// DiskFileNum (even though this is a virtual sstable).
771-
meta.InitProviderBacking(base.DiskFileNum(meta.FileNum), lr.external[i].external.Size)
771+
meta.InitVirtualBacking(base.DiskFileNum(meta.FileNum), lr.external[i].external.Size)
772772

773773
// Set the underlying FileBacking's size to the same size as the virtualized
774774
// view of the sstable. This ensures that we don't over-prioritize this

internal/manifest/version.go

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -525,24 +525,27 @@ func (m *TableMetadata) InitPhysicalBacking() {
525525
if m.Virtual != nil {
526526
panic("pebble: virtual sstables should use a pre-existing FileBacking")
527527
}
528-
if m.FileBacking == nil {
529-
m.FileBacking = &FileBacking{
530-
DiskFileNum: base.PhysicalTableDiskFileNum(m.FileNum),
531-
Size: m.Size,
532-
}
528+
if m.FileBacking != nil {
529+
panic("backing already initialized")
530+
}
531+
m.FileBacking = &FileBacking{
532+
DiskFileNum: base.PhysicalTableDiskFileNum(m.FileNum),
533+
Size: m.Size,
533534
}
534535
}
535536

536-
// InitProviderBacking creates a new FileBacking for a file backed by
537-
// an objstorage.Provider.
538-
func (m *TableMetadata) InitProviderBacking(fileNum base.DiskFileNum, size uint64) {
537+
// InitVirtualBacking creates a new FileBacking for a virtual table.
538+
func (m *TableMetadata) InitVirtualBacking(fileNum base.DiskFileNum, size uint64) {
539539
if m.Virtual == nil {
540540
panic("pebble: provider-backed sstables must be virtual")
541541
}
542-
if m.FileBacking == nil {
543-
m.FileBacking = &FileBacking{DiskFileNum: fileNum}
542+
if m.FileBacking != nil {
543+
panic("backing already initialized")
544+
}
545+
m.FileBacking = &FileBacking{
546+
DiskFileNum: fileNum,
547+
Size: size,
544548
}
545-
m.FileBacking.Size = size
546549
}
547550

548551
// ValidateVirtual should be called once the TableMetadata for a virtual sstable
@@ -927,7 +930,7 @@ func ParseTableMetadataDebug(s string) (_ *TableMetadata, err error) {
927930
m.InitPhysicalBacking()
928931
} else {
929932
m.Virtual = &virtual.VirtualReaderParams{}
930-
m.InitProviderBacking(backingNum, 0 /* size */)
933+
m.InitVirtualBacking(backingNum, 0 /* size */)
931934
}
932935
return m, nil
933936
}

0 commit comments

Comments
 (0)