@@ -6,13 +6,10 @@ package pebble
66
77import (
88 "bytes"
9- "context"
10- "encoding/binary"
119 "fmt"
1210 "io"
1311 "math"
1412 "os"
15- "slices"
1613 "sync"
1714 "sync/atomic"
1815
@@ -23,7 +20,6 @@ import (
2320 "github.com/cockroachdb/pebble/internal/cache"
2421 "github.com/cockroachdb/pebble/internal/inflight"
2522 "github.com/cockroachdb/pebble/internal/invariants"
26- "github.com/cockroachdb/pebble/internal/keyspan"
2723 "github.com/cockroachdb/pebble/internal/manifest"
2824 "github.com/cockroachdb/pebble/internal/manual"
2925 "github.com/cockroachdb/pebble/objstorage"
@@ -675,81 +671,6 @@ func GetVersion(dir string, fs vfs.FS) (string, error) {
675671 return version , nil
676672}
677673
678- func (d * DB ) replayIngestedFlushable (
679- b * Batch , logNum base.DiskFileNum ,
680- ) (entry * flushableEntry , err error ) {
681- br := b .Reader ()
682- seqNum := b .SeqNum ()
683-
684- fileNums := make ([]base.DiskFileNum , 0 , b .Count ())
685- var exciseSpan KeyRange
686- addFileNum := func (encodedFileNum []byte ) {
687- fileNum , n := binary .Uvarint (encodedFileNum )
688- if n <= 0 {
689- panic ("pebble: ingest sstable file num is invalid" )
690- }
691- fileNums = append (fileNums , base .DiskFileNum (fileNum ))
692- }
693-
694- for i := 0 ; i < int (b .Count ()); i ++ {
695- kind , key , val , ok , err := br .Next ()
696- if err != nil {
697- return nil , err
698- }
699- if kind != InternalKeyKindIngestSST && kind != InternalKeyKindExcise {
700- panic ("pebble: invalid batch key kind" )
701- }
702- if ! ok {
703- panic ("pebble: invalid batch count" )
704- }
705- if kind == base .InternalKeyKindExcise {
706- if exciseSpan .Valid () {
707- panic ("pebble: multiple excise spans in a single batch" )
708- }
709- exciseSpan .Start = slices .Clone (key )
710- exciseSpan .End = slices .Clone (val )
711- continue
712- }
713- addFileNum (key )
714- }
715-
716- if _ , _ , _ , ok , err := br .Next (); err != nil {
717- return nil , err
718- } else if ok {
719- panic ("pebble: invalid number of entries in batch" )
720- }
721-
722- meta := make ([]* manifest.TableMetadata , len (fileNums ))
723- var lastRangeKey keyspan.Span
724- for i , n := range fileNums {
725- readable , err := d .objProvider .OpenForReading (context .TODO (), base .FileTypeTable , n ,
726- objstorage.OpenOptions {MustExist : true })
727- if err != nil {
728- return nil , errors .Wrap (err , "pebble: error when opening flushable ingest files" )
729- }
730- // NB: ingestLoad1 will close readable.
731- meta [i ], lastRangeKey , _ , err = ingestLoad1 (context .TODO (), d .opts , d .FormatMajorVersion (),
732- readable , d .cacheHandle , base .PhysicalTableFileNum (n ), disableRangeKeyChecks ())
733- if err != nil {
734- return nil , errors .Wrap (err , "pebble: error when loading flushable ingest files" )
735- }
736- }
737- if lastRangeKey .Valid () && d .opts .Comparer .Split .HasSuffix (lastRangeKey .End ) {
738- return nil , errors .AssertionFailedf ("pebble: last ingest sstable has suffixed range key end %s" ,
739- d .opts .Comparer .FormatKey (lastRangeKey .End ))
740- }
741-
742- numFiles := len (meta )
743- if exciseSpan .Valid () {
744- numFiles ++
745- }
746- if uint32 (numFiles ) != b .Count () {
747- panic ("pebble: couldn't load all files in WAL entry" )
748- }
749-
750- return d .newIngestedFlushableEntry (meta , seqNum , logNum , exciseSpan )
751- }
752-
753674func readOptionsFile (opts * Options , path string ) (string , error ) {
754675 f , err := opts .FS .Open (path )
755676 if err != nil {
0 commit comments