Skip to content

Commit f715521

Browse files
committed
manifest: maintain pointers to *TableMetadata for blob references
Previously the CurrentBlobFileSet maintained just the TableNum of referencing tables. Blob file rewrites will require reading the referencing tables, which requires the *TableMetadata.
1 parent bb0e2d1 commit f715521

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

internal/manifest/blob_metadata.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ type currentBlobFile struct {
490490
// referencing table number. This would likely be more memory efficient,
491491
// reduce overall number of pointers to chase and suffer fewer allocations
492492
// (and we can pool the B-Tree nodes to further reduce allocs)
493-
references map[base.TableNum]struct{}
493+
references map[*TableMetadata]struct{}
494494
// referencedValueSize is the sum of the length of uncompressed values in
495495
// this blob file that are still live.
496496
referencedValueSize uint64
@@ -576,7 +576,7 @@ func (s *CurrentBlobFileSet) Init(bve *BulkVersionEdit, h BlobRewriteHeuristic)
576576
for blobFileID, pbf := range bve.BlobFiles.Added {
577577
s.files[blobFileID] = &currentBlobFile{
578578
metadata: BlobFileMetadata{FileID: blobFileID, Physical: pbf},
579-
references: make(map[base.TableNum]struct{}),
579+
references: make(map[*TableMetadata]struct{}),
580580
}
581581
s.stats.Count++
582582
s.stats.PhysicalSize += pbf.Size
@@ -591,7 +591,7 @@ func (s *CurrentBlobFileSet) Init(bve *BulkVersionEdit, h BlobRewriteHeuristic)
591591
if !ok {
592592
panic(errors.AssertionFailedf("pebble: referenced blob file %d not found", ref.FileID))
593593
}
594-
cbf.references[table.TableNum] = struct{}{}
594+
cbf.references[table] = struct{}{}
595595
cbf.referencedValueSize += ref.ValueSize
596596
s.stats.ReferencedValueSize += ref.ValueSize
597597
s.stats.ReferencesCount++
@@ -724,7 +724,7 @@ func (s *CurrentBlobFileSet) ApplyAndUpdateVersionEdit(ve *VersionEdit) error {
724724
}
725725

726726
blobFileID := m.FileID
727-
cbf := &currentBlobFile{references: make(map[base.TableNum]struct{})}
727+
cbf := &currentBlobFile{references: make(map[*TableMetadata]struct{})}
728728
cbf.metadata = BlobFileMetadata{FileID: blobFileID, Physical: m.Physical}
729729
s.files[blobFileID] = cbf
730730
s.stats.Count++
@@ -742,7 +742,7 @@ func (s *CurrentBlobFileSet) ApplyAndUpdateVersionEdit(ve *VersionEdit) error {
742742
if !ok {
743743
return errors.AssertionFailedf("pebble: referenced blob file %d not found", ref.FileID)
744744
}
745-
cbf.references[e.Meta.TableNum] = struct{}{}
745+
cbf.references[e.Meta] = struct{}{}
746746
cbf.referencedValueSize += ref.ValueSize
747747
s.stats.ReferencedValueSize += ref.ValueSize
748748
s.stats.ReferencesCount++
@@ -765,7 +765,7 @@ func (s *CurrentBlobFileSet) ApplyAndUpdateVersionEdit(ve *VersionEdit) error {
765765
return errors.AssertionFailedf("pebble: referenced value size %d for blob file %s is greater than the referenced value size %d",
766766
ref.ValueSize, cbf.metadata.FileID, cbf.referencedValueSize)
767767
}
768-
if _, ok := cbf.references[meta.TableNum]; !ok {
768+
if _, ok := cbf.references[meta]; !ok {
769769
return errors.AssertionFailedf("pebble: deleted table %s's reference to blob file %s not known",
770770
meta.TableNum, ref.FileID)
771771
}
@@ -786,7 +786,7 @@ func (s *CurrentBlobFileSet) ApplyAndUpdateVersionEdit(ve *VersionEdit) error {
786786
continue
787787
}
788788
// Remove the reference of this table to this blob file.
789-
delete(cbf.references, meta.TableNum)
789+
delete(cbf.references, meta)
790790

791791
// If there are no more references to the blob file, remove it from
792792
// the set and add the removal of the blob file to the version edit.

0 commit comments

Comments
 (0)