@@ -20,50 +20,9 @@ import (
2020 "math/bits"
2121
2222 "github.com/RoaringBitmap/roaring"
23+ "github.com/vmware-tanzu/velero/pkg/uploader/cbt/types"
2324)
2425
25- // Bitmap defines the methods to store and iterate the CBT bitmap
26- type Bitmap interface {
27- // Set sets bits within the provided range
28- Set (uint64 , uint64 )
29-
30- // SetFull sets all bits to the bitmap
31- SetFull ()
32-
33- // Snapshot returns snapshot of the bitmap
34- Snapshot () string
35-
36- // ChangeID returns the changeID of the bitmap
37- ChangeID () string
38-
39- // VolumeID return ID of the volume from which the snapshot is taken
40- VolumeID () string
41-
42- // Iterator returns the iterator for the CBT Bitmap
43- Iterator () Iterator
44- }
45-
46- // Iterator defines the methods to iterate the CBT bitmap and query the associated information
47- type Iterator interface {
48- // ChangeID returns the changeID of the bitmap
49- ChangeID () string
50-
51- // Snapshot returns snapshot of the bitmap
52- Snapshot () string
53-
54- // VolumeID return ID of the volume from which the snapshot is taken
55- VolumeID () string
56-
57- // BlockSize returns the granularity of the bitmap
58- BlockSize () uint
59-
60- // Count returns the toal number of count in the bitmap
61- Count () uint64
62-
63- // Next returns the offset of the next set block and whether it comes to the end of the iteration
64- Next () (uint64 , bool )
65- }
66-
6726const (
6827 InvalidOffset64 = ^ uint64 (0 )
6928)
@@ -83,7 +42,7 @@ type bitmapIterator struct {
8342 iterator roaring.IntPeekable
8443}
8544
86- func NewBitmap (blockSize uint , length uint64 , snapshot string , changeID string , volumeID string ) Bitmap {
45+ func NewBitmap (blockSize uint , length uint64 , snapshot string , changeID string , volumeID string ) types. Bitmap {
8746 return & bitmapImpl {
8847 bitmap : roaring .New (),
8948 blockSize : blockSize ,
@@ -105,14 +64,14 @@ func (c *bitmapImpl) Set(offset, length uint64) {
10564 }
10665
10766 start := offset >> c .blockSizeLog
108- end := uint64 (( offset + length + uint64 (c .blockSize ) - 1 ) >> c .blockSizeLog )
67+ end := ( offset + length + uint64 (c .blockSize ) - 1 ) >> c .blockSizeLog
10968
11069 c .bitmap .AddRange (start , end )
11170}
11271
11372func (c * bitmapImpl ) SetFull () {
11473 start := uint64 (0 )
115- end := uint64 (( c .length + uint64 (c .blockSize ) - 1 ) >> c .blockSizeLog )
74+ end := ( c .length + uint64 (c .blockSize ) - 1 ) >> c .blockSizeLog
11675
11776 c .bitmap .AddRange (start , end )
11877}
@@ -129,7 +88,7 @@ func (c *bitmapImpl) VolumeID() string {
12988 return c .volumeID
13089}
13190
132- func (c * bitmapImpl ) Iterator () Iterator {
91+ func (c * bitmapImpl ) Iterator () types. Iterator {
13392 if c .bitmap == nil {
13493 return nil
13594 }
0 commit comments