@@ -143,8 +143,8 @@ func (vs *writeNewBlobFiles) Add(
143143 // between sstables and blob files, the reference index is always 0
144144 // here. Only compactions that don't rewrite blob files will produce
145145 // handles with nonzero reference indices.
146- ReferenceIndex : 0 ,
147- ValueLen : handle .ValueLen ,
146+ ReferenceID : 0 ,
147+ ValueLen : handle .ValueLen ,
148148 },
149149 HandleSuffix : blob.HandleSuffix {
150150 BlockNum : handle .BlockNum ,
@@ -166,7 +166,7 @@ func (vs *writeNewBlobFiles) FinishOutput() (compact.ValueSeparationMetadata, er
166166 }
167167 vs .writer = nil
168168 return compact.ValueSeparationMetadata {
169- BlobReferences : [] manifest.BlobReference {{
169+ BlobReferences : manifest.BlobReferences {{
170170 FileNum : vs .objMeta .DiskFileNum ,
171171 ValueSize : stats .UncompressedValueBytes ,
172172 }},
@@ -197,7 +197,7 @@ type preserveBlobReferences struct {
197197
198198 // state
199199 buf []byte
200- currReferences [] manifest.BlobReference
200+ currReferences manifest.BlobReferences
201201 // totalValueSize is the sum of the sizes of all ValueSizes in currReferences.
202202 totalValueSize uint64
203203}
@@ -250,24 +250,16 @@ func (vs *preserveBlobReferences) Add(
250250 // sstable, taking note of the reference for the table metadata.
251251 lv := kv .V .LazyValue ()
252252 fn := lv .Fetcher .BlobFileNum
253- var found bool
254- refIdx := 0
255- for refIdx = range vs .currReferences {
256- if vs .currReferences [refIdx ].FileNum == fn {
257- // This sstable contains an existing reference to this blob file.
258- // Record the reference.
259- found = true
260- break
261- }
262- }
253+
254+ refIdx , found := vs .currReferences .IDByFileNum (fn )
263255 if ! found {
264256 // This is the first time we're seeing this blob file for this sstable.
265257 // Find the blob file metadata for this file among the input metadatas.
266258 idx , found := vs .findInputBlobMetadata (fn )
267259 if ! found {
268260 return errors .AssertionFailedf ("pebble: blob file %s not found among input sstables" , fn )
269261 }
270- refIdx = len (vs .currReferences )
262+ refIdx = blob . ReferenceID ( len (vs .currReferences ) )
271263 vs .currReferences = append (vs .currReferences , manifest.BlobReference {
272264 FileNum : fn ,
273265 Metadata : vs .inputBlobMetadatas [idx ],
@@ -281,8 +273,8 @@ func (vs *preserveBlobReferences) Add(
281273 handleSuffix := blob .DecodeHandleSuffix (lv .ValueOrHandle )
282274 inlineHandle := blob.InlineHandle {
283275 InlineHandlePreface : blob.InlineHandlePreface {
284- ReferenceIndex : uint32 ( refIdx ) ,
285- ValueLen : lv .Fetcher .Attribute .ValueLen ,
276+ ReferenceID : refIdx ,
277+ ValueLen : lv .Fetcher .Attribute .ValueLen ,
286278 },
287279 HandleSuffix : handleSuffix ,
288280 }
0 commit comments