@@ -135,7 +135,7 @@ func (d *DB) exciseTable(
135135 // TODO(bilal): Some of this work can happen without grabbing the manifest
136136 // lock; we could grab one currentVersion, release the lock, calculate excised
137137 // files, then grab the lock again and recalculate for just the files that
138- // have changed since our previous calculation. Do this optimiaztino as part of
138+ // have changed since our previous calculation. Do this optimization as part of
139139 // https://github.com/cockroachdb/pebble/issues/2112 .
140140 if d .cmp (m .Smallest ().UserKey , exciseBounds .Start ) < 0 {
141141 leftTable = & tableMetadata {
@@ -147,6 +147,7 @@ func (d *DB) exciseTable(
147147 LargestSeqNum : m .LargestSeqNum ,
148148 LargestSeqNumAbsolute : m .LargestSeqNumAbsolute ,
149149 SyntheticPrefixAndSuffix : m .SyntheticPrefixAndSuffix ,
150+ BlobReferenceDepth : m .BlobReferenceDepth ,
150151 }
151152 if looseBounds {
152153 looseLeftTableBounds (d .cmp , m , leftTable , exciseBounds .Start )
@@ -159,6 +160,7 @@ func (d *DB) exciseTable(
159160 if err := determineExcisedTableSize (d .fileCache , m , leftTable ); err != nil {
160161 return nil , nil , err
161162 }
163+ determineExcisedTableBlobReferences (m .BlobReferences , m .Size , leftTable )
162164 if err := leftTable .Validate (d .cmp , d .opts .Comparer .FormatKey ); err != nil {
163165 return nil , nil , err
164166 }
@@ -182,6 +184,7 @@ func (d *DB) exciseTable(
182184 LargestSeqNum : m .LargestSeqNum ,
183185 LargestSeqNumAbsolute : m .LargestSeqNumAbsolute ,
184186 SyntheticPrefixAndSuffix : m .SyntheticPrefixAndSuffix ,
187+ BlobReferenceDepth : m .BlobReferenceDepth ,
185188 }
186189 if looseBounds {
187190 // We already checked that the end bound is exclusive.
@@ -194,6 +197,7 @@ func (d *DB) exciseTable(
194197 if err := determineExcisedTableSize (d .fileCache , m , rightTable ); err != nil {
195198 return nil , nil , err
196199 }
200+ determineExcisedTableBlobReferences (m .BlobReferences , m .Size , rightTable )
197201 if err := rightTable .Validate (d .cmp , d .opts .Comparer .FormatKey ); err != nil {
198202 return nil , nil , err
199203 }
@@ -434,6 +438,21 @@ func determineExcisedTableSize(
434438 return nil
435439}
436440
441+ // determineExcisedTableBlobReferences copies blob references from the original
442+ // table to the excised table, scaling each blob reference's value size
443+ // proportionally based on the ratio of the excised table's size to the original
444+ // table's size.
445+ func determineExcisedTableBlobReferences (
446+ originalBlobReferences manifest.BlobReferences , originalSize uint64 , excisedTable * tableMetadata ,
447+ ) {
448+ newBlobReferences := make (manifest.BlobReferences , len (originalBlobReferences ))
449+ for i , bf := range originalBlobReferences {
450+ bf .ValueSize = bf .ValueSize * excisedTable .Size / originalSize
451+ newBlobReferences [i ] = bf
452+ }
453+ excisedTable .BlobReferences = newBlobReferences
454+ }
455+
437456// applyExciseToVersionEdit updates ve with a table deletion for the original
438457// table and table additions for the left and/or right table.
439458//
0 commit comments