Change all TSM file sizes to uint32

pull/5019/head
Paul Dix 2015-12-07 10:12:24 -05:00
parent 937233d988
commit 440a8a8a1f
3 changed files with 18 additions and 18 deletions

View File

@ -21,7 +21,7 @@ import (
"time" "time"
) )
const maxTSMFileSize = 2048 * 1024 * 1024 // 2GB const maxTSMFileSize = uint32(2048 * 1024 * 1024) // 2GB
const CompactionTempExtension = "tmp" const CompactionTempExtension = "tmp"
@ -33,7 +33,7 @@ var (
) )
// compactionSteps are the sizes of files to roll up into before combining. // compactionSteps are the sizes of files to roll up into before combining.
var compactionSteps = []int64{ var compactionSteps = []uint32{
32 * 1024 * 1024, 32 * 1024 * 1024,
128 * 1024 * 1024, 128 * 1024 * 1024,
512 * 1024 * 1024, 512 * 1024 * 1024,
@ -76,10 +76,10 @@ type tsmGeneration struct {
} }
// size returns the total size of the generation // size returns the total size of the generation
func (t *tsmGeneration) size() int64 { func (t *tsmGeneration) size() uint32 {
var n int64 var n uint32
for _, f := range t.files { for _, f := range t.files {
n += int64(f.Size) n += uint32(f.Size)
} }
return n return n
} }
@ -115,7 +115,7 @@ func (c *DefaultPlanner) Plan(lastWrite time.Time) []string {
// First find the minimum size of all generations and set of generations. // First find the minimum size of all generations and set of generations.
// And mark if everything is fully compacted // And mark if everything is fully compacted
var order []int var order []int
minSize := int64(math.MaxInt64) minSize := uint32(math.MaxUint32)
fileCount := 0 fileCount := 0
for gen, group := range generations { for gen, group := range generations {
order = append(order, gen) order = append(order, gen)

View File

@ -115,7 +115,7 @@ type TSMWriter interface {
Close() error Close() error
// Size returns the current size in bytes of the file // Size returns the current size in bytes of the file
Size() int Size() uint32
} }
// TSMIndex represent the index section of a TSM file. The index records all // TSMIndex represent the index section of a TSM file. The index records all
@ -153,7 +153,7 @@ type TSMIndex interface {
KeyCount() int KeyCount() int
// Size returns the size of a the current index in bytes // Size returns the size of a the current index in bytes
Size() int Size() uint32
// TimeRange returns the min and max time across all keys in the file. // TimeRange returns the min and max time across all keys in the file.
TimeRange() (time.Time, time.Time) TimeRange() (time.Time, time.Time)
@ -430,7 +430,7 @@ func (d *directIndex) UnmarshalBinary(b []byte) error {
return nil return nil
} }
func (d *directIndex) Size() int { func (d *directIndex) Size() uint32 {
return 0 return 0
} }
@ -727,11 +727,11 @@ func (d *indirectIndex) UnmarshalBinary(b []byte) error {
return nil return nil
} }
func (d *indirectIndex) Size() int { func (d *indirectIndex) Size() uint32 {
d.mu.RLock() d.mu.RLock()
defer d.mu.RUnlock() defer d.mu.RUnlock()
return len(d.b) return uint32(len(d.b))
} }
// tsmWriter writes keys and values in the TSM format // tsmWriter writes keys and values in the TSM format
@ -815,8 +815,8 @@ func (t *tsmWriter) Close() error {
return nil return nil
} }
func (t *tsmWriter) Size() int { func (t *tsmWriter) Size() uint32 {
return int(t.n) + t.index.Size() return uint32(t.n) + t.index.Size()
} }
type TSMReader struct { type TSMReader struct {
@ -1025,14 +1025,14 @@ func (t *TSMReader) Entries(key string) []*IndexEntry {
return t.index.Entries(key) return t.index.Entries(key)
} }
func (t *TSMReader) IndexSize() int { func (t *TSMReader) IndexSize() uint32 {
return t.index.Size() return t.index.Size()
} }
func (t *TSMReader) Size() int { func (t *TSMReader) Size() uint32 {
t.mu.RLock() t.mu.RLock()
defer t.mu.RUnlock() defer t.mu.RUnlock()
return int(t.size) return uint32(t.size)
} }
func (t *TSMReader) LastModified() time.Time { func (t *TSMReader) LastModified() time.Time {

View File

@ -57,7 +57,7 @@ type TSMFile interface {
Close() error Close() error
// Size returns the size of the file on disk in bytes. // Size returns the size of the file on disk in bytes.
Size() int Size() uint32
// Remove deletes the file from the filesystem // Remove deletes the file from the filesystem
Remove() error Remove() error
@ -79,7 +79,7 @@ type FileStore struct {
type FileStat struct { type FileStat struct {
Path string Path string
HasTombstone bool HasTombstone bool
Size int Size uint32
LastModified time.Time LastModified time.Time
MinTime, MaxTime time.Time MinTime, MaxTime time.Time
MinKey, MaxKey string MinKey, MaxKey string