Skip to content

Commit f406279

Browse files
committed
Made suggested change.
Signed-off-by: Cody Littley <[email protected]>
1 parent c1da131 commit f406279

File tree

7 files changed

+15
-16
lines changed

7 files changed

+15
-16
lines changed

litt/disktable/control_loop.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func (c *controlLoop) run() {
151151

152152
// doGarbageCollection performs garbage collection on all segments, deleting old ones as necessary.
153153
func (c *controlLoop) doGarbageCollection() {
154-
now := c.clock()
154+
start := c.clock()
155155
ttl := c.metadata.GetTTL()
156156
if ttl.Nanoseconds() <= 0 {
157157
// No TTL set, so nothing to do.
@@ -161,7 +161,7 @@ func (c *controlLoop) doGarbageCollection() {
161161
defer func() {
162162
if c.metrics != nil {
163163
end := c.clock()
164-
delta := end.Sub(now)
164+
delta := end.Sub(start)
165165
c.metrics.ReportGarbageCollectionLatency(c.name, delta)
166166

167167
}
@@ -176,7 +176,7 @@ func (c *controlLoop) doGarbageCollection() {
176176
}
177177

178178
sealTime := seg.GetSealTime()
179-
segmentAge := now.Sub(sealTime)
179+
segmentAge := start.Sub(sealTime)
180180
if segmentAge < ttl {
181181
// Segment is not old enough to be deleted.
182182
return

litt/disktable/disk_table.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,11 @@ func NewDiskTable(
198198
return nil, fmt.Errorf("failed to gather segment files: %w", err)
199199
}
200200

201-
keyCount := uint64(0)
201+
keyCount := int64(0)
202202
for _, seg := range segments {
203-
keyCount += uint64(seg.KeyCount())
203+
keyCount += int64(seg.KeyCount())
204204
}
205-
table.keyCount.Store(int64(keyCount))
205+
table.keyCount.Store(keyCount)
206206

207207
immutableSegmentSize := uint64(0)
208208
for _, seg := range segments {

litt/disktable/keymap/level_db_keymap.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ type LevelDBKeymap struct {
2929
syncWrites bool
3030
}
3131

32+
var _ BuildKeymap = NewLevelDBKeymap
33+
3234
// NewLevelDBKeymap creates a new LevelDBKeymap instance.
3335
func NewLevelDBKeymap(
3436
logger logging.Logger,

litt/disktable/keymap/mem_keymap.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ type memKeymap struct {
2525
lock sync.RWMutex
2626
}
2727

28+
var _ BuildKeymap = NewMemKeymap
29+
2830
// NewMemKeymap creates a new in-memory keymap.
2931
func NewMemKeymap(logger logging.Logger,
3032
_ string,

litt/disktable/segment/metadata_file.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const (
3838
// - and 1 byte for sealed.
3939
V1MetadataSize = 33
4040

41-
// V2MetadataSize is the size of the metadata file at version 3 (aka ValueSizeSegmentVersion).
41+
// V2MetadataSize is the size of the metadata file at version 2 (aka ValueSizeSegmentVersion).
4242
// This is a constant, so it's convenient to have it here.
4343
// - 4 bytes for version
4444
// - 4 bytes for the sharding factor

litt/disktable/segment/segment_scanner.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,7 @@ func scanDirectories(logger logging.Logger, rootDirectories []string) (
5151
var index uint32
5252

5353
switch extension {
54-
case MetadataSwapExtension:
55-
garbageFiles = append(garbageFiles, filePath)
56-
continue
57-
case KeyFileSwapExtension:
54+
case MetadataSwapExtension, KeyFileSwapExtension:
5855
garbageFiles = append(garbageFiles, filePath)
5956
continue
6057
case MetadataFileExtension:

litt/disktable/segment/segment_version.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@ package segment
44
// in segment files, this version should be incremented.
55
type SegmentVersion uint32
66

7-
// IMPORTANT! Never remove old versions from this list, as doing so remaps the segment version numbers.
8-
97
const (
108
// OldHashFunctionSegmentVersion is the serialization version for the old hash function.
11-
OldHashFunctionSegmentVersion SegmentVersion = iota
9+
OldHashFunctionSegmentVersion SegmentVersion = 0
1210

1311
// SipHashSegmentVersion is the version when the siphash hash function was introduced for sharding.
14-
SipHashSegmentVersion
12+
SipHashSegmentVersion SegmentVersion = 1
1513

1614
// ValueSizeSegmentVersion adds the length of values to the key file. Previously, only the key and the address were
1715
// stored in the key file. It also adds the key count to the segment metadata file.
18-
ValueSizeSegmentVersion
16+
ValueSizeSegmentVersion SegmentVersion = 2
1917
)
2018

2119
// LatestSegmentVersion always refers to the latest version of the segment serialization format.

0 commit comments

Comments
 (0)