@@ -35,14 +35,15 @@ type byteReader interface {
35
35
// Tag 8 is no longer used.
36
36
const (
37
37
// LevelDB tags.
38
- tagComparator = 1
39
- tagLogNumber = 2
40
- tagNextFileNumber = 3
41
- tagLastSequence = 4
42
- tagCompactPointer = 5
43
- tagDeletedFile = 6
44
- tagNewFile = 7
45
- tagPrevLogNumber = 9
38
+ tagComparator = 1
39
+ tagLogNumber = 2
40
+ tagNextFileNumber = 3
41
+ tagLastSequence = 4
42
+ tagCompactPointer = 5
43
+ tagDeletedFile = 6
44
+ tagNewFile = 7
45
+ tagPrevLogNumber = 9
46
+ tagExciseBoundsRecord = 10
46
47
47
48
// RocksDB tags.
48
49
tagNewFile2 = 100
@@ -98,6 +99,12 @@ type NewTableEntry struct {
98
99
BackingFileNum base.DiskFileNum
99
100
}
100
101
102
+ // ExciseOpEntry holds the bounds and sequence number for an excise operation.
103
+ type ExciseOpEntry struct {
104
+ Bounds base.UserKeyBounds
105
+ SeqNum base.SeqNum
106
+ }
107
+
101
108
// VersionEdit holds the state for an edit to a Version along with other
102
109
// on-disk state (log numbers, next file number, and the last sequence number).
103
110
type VersionEdit struct {
@@ -179,6 +186,9 @@ type VersionEdit struct {
179
186
// While replaying a MANIFEST, the values are nil. Otherwise the values must
180
187
// not be nil.
181
188
DeletedBlobFiles map [DeletedBlobFileEntry ]* PhysicalBlobFile
189
+
190
+ // ExciseBoundsRecord holds excise operations as a slice of entries.
191
+ ExciseBoundsRecord []ExciseOpEntry
182
192
}
183
193
184
194
// Decode decodes an edit from the specified reader.
@@ -575,6 +585,32 @@ func (v *VersionEdit) Decode(r io.Reader) error {
575
585
}
576
586
v .ObsoletePrevLogNum = n
577
587
588
+ case tagExciseBoundsRecord :
589
+ start , err := d .readBytes ()
590
+ if err != nil {
591
+ return err
592
+ }
593
+ end , err := d .readBytes ()
594
+ if err != nil {
595
+ return err
596
+ }
597
+ kind , err := d .readUvarint ()
598
+ if err != nil {
599
+ return err
600
+ }
601
+ seqNum , err := d .readUvarint ()
602
+ if err != nil {
603
+ return err
604
+ }
605
+ bounds := base.UserKeyBounds {
606
+ Start : start ,
607
+ End : base .UserKeyExclusiveIf (end , base .BoundaryKind (kind ) == base .Exclusive ),
608
+ }
609
+ v .ExciseBoundsRecord = append (v .ExciseBoundsRecord , ExciseOpEntry {
610
+ Bounds : bounds ,
611
+ SeqNum : base .SeqNum (seqNum ),
612
+ })
613
+
578
614
case tagColumnFamily , tagColumnFamilyAdd , tagColumnFamilyDrop , tagMaxColumnFamily :
579
615
return base .CorruptionErrorf ("column families are not supported" )
580
616
@@ -641,6 +677,10 @@ func (v *VersionEdit) string(verbose bool, fmtKey base.FormatKey) string {
641
677
for _ , df := range deletedBlobFileEntries {
642
678
fmt .Fprintf (& buf , " del-blob-file: %s %s\n " , df .FileID , df .FileNum )
643
679
}
680
+ for _ , exciseBounds := range v .ExciseBoundsRecord {
681
+ fmt .Fprintf (& buf , " excise-op: %s #%d\n " , exciseBounds .Bounds .String (), exciseBounds .SeqNum )
682
+ }
683
+
644
684
return buf .String ()
645
685
}
646
686
@@ -728,6 +768,14 @@ func ParseVersionEditDebug(s string) (_ *VersionEdit, err error) {
728
768
FileNum : p .DiskFileNum (),
729
769
}] = nil
730
770
771
+ case "excise-op" :
772
+ bounds := p .UserKeyBounds ()
773
+ seqNum := p .HashSeqNum ()
774
+ ve .ExciseBoundsRecord = append (ve .ExciseBoundsRecord , ExciseOpEntry {
775
+ Bounds : bounds ,
776
+ SeqNum : seqNum ,
777
+ })
778
+
731
779
default :
732
780
return nil , errors .Errorf ("field %q not implemented" , field )
733
781
}
@@ -869,6 +917,13 @@ func (v *VersionEdit) Encode(w io.Writer) error {
869
917
e .writeUvarint (uint64 (x .FileID ))
870
918
e .writeUvarint (uint64 (x .FileNum ))
871
919
}
920
+ for _ , entry := range v .ExciseBoundsRecord {
921
+ e .writeUvarint (tagExciseBoundsRecord )
922
+ e .writeBytes (entry .Bounds .Start )
923
+ e .writeBytes (entry .Bounds .End .Key )
924
+ e .writeUvarint (uint64 (entry .Bounds .End .Kind ))
925
+ e .writeUvarint (uint64 (entry .SeqNum ))
926
+ }
872
927
_ , err := w .Write (e .Bytes ())
873
928
return err
874
929
}
0 commit comments