@@ -15,7 +15,6 @@ import (
1515
1616 "github.com/cockroachdb/errors"
1717 "github.com/cockroachdb/pebble/internal/base"
18- "github.com/cockroachdb/pebble/internal/manifest"
1918 "github.com/cockroachdb/pebble/internal/strparse"
2019 "github.com/cockroachdb/pebble/internal/testutils"
2120 "github.com/cockroachdb/pebble/objstorage"
@@ -204,21 +203,20 @@ func (bv *Values) ParseInlineHandle(
204203}
205204
206205// WriteFiles writes all the blob files referenced by Values, using
207- // newBlobObject to construct new objects. Additionally, it updates the
208- // BlobFileMetadatas contained within metas with the resulting physical and
209- // logical sizes of the blob files.
210- func WriteFiles (
211- bv * Values ,
206+ // newBlobObject to construct new objects.
207+ //
208+ // Return the FileWriterStats for the written blob files.
209+ func (bv * Values ) WriteFiles (
212210 newBlobObject func (fileNum base.DiskFileNum ) (objstorage.Writable , error ),
213211 writerOpts blob.FileWriterOptions ,
214- metas map [base.DiskFileNum ]* manifest.BlobFileMetadata ,
215- ) error {
212+ ) (map [base.DiskFileNum ]blob.FileWriterStats , error ) {
216213 // Organize the handles by file number.
217214 files := make (map [base.DiskFileNum ][]blob.Handle )
218215 for handle := range bv .trackedHandles {
219216 files [handle .FileNum ] = append (files [handle .FileNum ], handle )
220217 }
221218
219+ stats := make (map [base.DiskFileNum ]blob.FileWriterStats )
222220 for fileNum , handles := range files {
223221 slices .SortFunc (handles , func (a , b blob.Handle ) int {
224222 if v := cmp .Compare (a .BlockNum , b .BlockNum ); v != 0 {
@@ -228,7 +226,7 @@ func WriteFiles(
228226 })
229227 writable , err := newBlobObject (fileNum )
230228 if err != nil {
231- return err
229+ return nil , err
232230 }
233231 writer := blob .NewFileWriter (fileNum , writable , writerOpts )
234232 for i , handle := range handles {
@@ -241,14 +239,13 @@ func WriteFiles(
241239 writer .AddValue (deriveValueFromHandle (handle ))
242240 }
243241 }
244- stats , err := writer .Close ()
242+ fileStats , err := writer .Close ()
245243 if err != nil {
246- return err
244+ return nil , err
247245 }
248- metas [fileNum ].Size = stats .FileLen
249- metas [fileNum ].ValueSize = stats .UncompressedValueBytes
246+ stats [fileNum ] = fileStats
250247 }
251- return nil
248+ return stats , nil
252249}
253250
254251// errFromPanic can be used in a recover block to convert panics into errors.
0 commit comments