From c46bc991777932e5b717f608c7cd21f17391eba8 Mon Sep 17 00:00:00 2001 From: Jackson Owens Date: Thu, 15 Feb 2024 16:28:17 -0500 Subject: [PATCH] wip --- flushable.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/flushable.go b/flushable.go index 45d6751198..c02e94087c 100644 --- a/flushable.go +++ b/flushable.go @@ -571,6 +571,28 @@ func (b *bufferedSSTables) init(targetFileSize int) { b.curr.Grow(targetFileSize) } +// copyToProvider copies all the finished buffered sstables to the provided +// destination object storage Provider. +func (b *bufferedSSTables) copyToProvider(ctx context.Context, dst objstorage.Provider) error { + for i := range b.finished { + err := func() error { + w, _, err := dst.Create(ctx, base.FileTypeTable, b.finished[i].fileNum, objstorage.CreateOptions{}) + if err != nil { + return err + } + if err = w.Write(b.finished[i].buf); err != nil { + w.Abort() + return err + } + return w.Finish() + }() + if err != nil { + return errors.Wrapf(err, "copying file %s", b.finished[i].fileNum) + } + } + return dst.Sync() +} + // Assert that *bufferedSSTables implements the objectCreator interface. var _ objectCreator = (*bufferedSSTables)(nil)