Skip to content

Commit

Permalink
tsm/cache: Remove unused function parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobmarble committed Jun 13, 2018
1 parent 87d2469 commit 0dc5393
Show file tree
Hide file tree
Showing 6 changed files with 259 additions and 259 deletions.
2 changes: 1 addition & 1 deletion cmd/influx_inspect/buildtsi/buildtsi.go
Expand Up @@ -209,7 +209,7 @@ func (cmd *Command) processShard(sfile *tsdb.SeriesFile, dbName, rpName string,

// Write out wal files.
cmd.Logger.Info("building cache from wal files")
cache := tsm1.NewCache(tsdb.DefaultCacheMaxMemorySize, "")
cache := tsm1.NewCache(tsdb.DefaultCacheMaxMemorySize)
loader := tsm1.NewCacheLoader(walPaths)
loader.WithLogger(cmd.Logger)
if err := loader.Load(cache); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion tsdb/engine/tsm1/cache.go
Expand Up @@ -208,7 +208,7 @@ type Cache struct {

// NewCache returns an instance of a cache which will use a maximum of maxSize bytes of memory.
// Only used for engine caches, never for snapshots.
func NewCache(maxSize uint64, path string) *Cache {
func NewCache(maxSize uint64) *Cache {
c := &Cache{
maxSize: maxSize,
store: emptyStore{},
Expand Down
8 changes: 4 additions & 4 deletions tsdb/engine/tsm1/cache_race_test.go
Expand Up @@ -26,7 +26,7 @@ func TestCacheCheckConcurrentReadsAreSafe(t *testing.T) {
}

wg := sync.WaitGroup{}
c := tsm1.NewCache(1000000, "")
c := tsm1.NewCache(1000000)

ch := make(chan struct{})
for _, s := range series {
Expand Down Expand Up @@ -71,7 +71,7 @@ func TestCacheRace(t *testing.T) {
}

wg := sync.WaitGroup{}
c := tsm1.NewCache(1000000, "")
c := tsm1.NewCache(1000000)

ch := make(chan struct{})
for _, s := range series {
Expand Down Expand Up @@ -136,7 +136,7 @@ func TestCacheRace2Compacters(t *testing.T) {
}

wg := sync.WaitGroup{}
c := tsm1.NewCache(1000000, "")
c := tsm1.NewCache(1000000)

ch := make(chan struct{})
for _, s := range series {
Expand Down Expand Up @@ -181,7 +181,7 @@ func TestCacheRace2Compacters(t *testing.T) {
c.ClearSnapshot(true)
mu.Lock()
defer mu.Unlock()
for k, _ := range myFiles {
for k := range myFiles {
if _, ok := mapFiles[k]; !ok {
errC <- fmt.Errorf("something else deleted one of my files")
return
Expand Down
76 changes: 38 additions & 38 deletions tsdb/engine/tsm1/cache_test.go
Expand Up @@ -19,7 +19,7 @@ import (
)

func TestCache_NewCache(t *testing.T) {
c := NewCache(100, "")
c := NewCache(100)
if c == nil {
t.Fatalf("failed to create new cache")
}
Expand All @@ -42,7 +42,7 @@ func TestCache_CacheWrite(t *testing.T) {
values := Values{v0, v1, v2}
valuesSize := uint64(v0.Size() + v1.Size() + v2.Size())

c := NewCache(3*valuesSize, "")
c := NewCache(3 * valuesSize)

if err := c.Write([]byte("foo"), values); err != nil {
t.Fatalf("failed to write key foo to cache: %s", err.Error())
Expand All @@ -65,7 +65,7 @@ func TestCache_CacheWrite_TypeConflict(t *testing.T) {
values := Values{v0, v1}
valuesSize := v0.Size() + v1.Size()

c := NewCache(uint64(2*valuesSize), "")
c := NewCache(uint64(2 * valuesSize))

if err := c.Write([]byte("foo"), values[:1]); err != nil {
t.Fatalf("failed to write key foo to cache: %s", err.Error())
Expand All @@ -87,7 +87,7 @@ func TestCache_CacheWriteMulti(t *testing.T) {
values := Values{v0, v1, v2}
valuesSize := uint64(v0.Size() + v1.Size() + v2.Size())

c := NewCache(30*valuesSize, "")
c := NewCache(30 * valuesSize)

if err := c.WriteMulti(map[string][]Value{"foo": values, "bar": values}); err != nil {
t.Fatalf("failed to write key foo to cache: %s", err.Error())
Expand All @@ -104,19 +104,19 @@ func TestCache_CacheWriteMulti(t *testing.T) {
// Tests that the cache stats and size are correctly maintained during writes.
func TestCache_WriteMulti_Stats(t *testing.T) {
limit := uint64(1)
c := NewCache(limit, "")
c := NewCache(limit)
ms := NewTestStore()
c.store = ms

// Not enough room in the cache.
v := NewValue(1, 1.0)
values := map[string][]Value{"foo": []Value{v, v}}
values := map[string][]Value{"foo": {v, v}}
if got, exp := c.WriteMulti(values), ErrCacheMemorySizeLimitExceeded(uint64(v.Size()*2), limit); !reflect.DeepEqual(got, exp) {
t.Fatalf("got %q, expected %q", got, exp)
}

// Fail one of the values in the write.
c = NewCache(50, "")
c = NewCache(50)
c.init()
c.store = ms

Expand All @@ -127,7 +127,7 @@ func TestCache_WriteMulti_Stats(t *testing.T) {
return true, nil
}

values = map[string][]Value{"foo": []Value{v, v}, "bar": []Value{v}}
values = map[string][]Value{"foo": {v, v}, "bar": {v}}
if got, exp := c.WriteMulti(values), errors.New("write failed"); !reflect.DeepEqual(got, exp) {
t.Fatalf("got %v, expected %v", got, exp)
}
Expand All @@ -152,7 +152,7 @@ func TestCache_CacheWriteMulti_TypeConflict(t *testing.T) {
values := Values{v0, v1, v2}
valuesSize := uint64(v0.Size() + v1.Size() + v2.Size())

c := NewCache(3*valuesSize, "")
c := NewCache(3 * valuesSize)

if err := c.WriteMulti(map[string][]Value{"foo": values[:1], "bar": values[1:]}); err == nil {
t.Fatalf(" expected field type conflict")
Expand All @@ -174,7 +174,7 @@ func TestCache_Cache_DeleteRange(t *testing.T) {
values := Values{v0, v1, v2}
valuesSize := uint64(v0.Size() + v1.Size() + v2.Size())

c := NewCache(30*valuesSize, "")
c := NewCache(30 * valuesSize)

if err := c.WriteMulti(map[string][]Value{"foo": values, "bar": values}); err != nil {
t.Fatalf("failed to write key foo to cache: %s", err.Error())
Expand Down Expand Up @@ -213,7 +213,7 @@ func TestCache_DeleteRange_NoValues(t *testing.T) {
values := Values{v0, v1, v2}
valuesSize := uint64(v0.Size() + v1.Size() + v2.Size())

c := NewCache(3*valuesSize, "")
c := NewCache(3 * valuesSize)

if err := c.WriteMulti(map[string][]Value{"foo": values}); err != nil {
t.Fatalf("failed to write key foo to cache: %s", err.Error())
Expand Down Expand Up @@ -248,7 +248,7 @@ func TestCache_DeleteRange_NotSorted(t *testing.T) {
values := Values{v0, v1, v2}
valuesSize := uint64(v0.Size() + v1.Size() + v2.Size())

c := NewCache(3*valuesSize, "")
c := NewCache(3 * valuesSize)

if err := c.WriteMulti(map[string][]Value{"foo": values}); err != nil {
t.Fatalf("failed to write key foo to cache: %s", err.Error())
Expand Down Expand Up @@ -283,7 +283,7 @@ func TestCache_Cache_Delete(t *testing.T) {
values := Values{v0, v1, v2}
valuesSize := uint64(v0.Size() + v1.Size() + v2.Size())

c := NewCache(30*valuesSize, "")
c := NewCache(30 * valuesSize)

if err := c.WriteMulti(map[string][]Value{"foo": values, "bar": values}); err != nil {
t.Fatalf("failed to write key foo to cache: %s", err.Error())
Expand Down Expand Up @@ -316,7 +316,7 @@ func TestCache_Cache_Delete(t *testing.T) {
}

func TestCache_Cache_Delete_NonExistent(t *testing.T) {
c := NewCache(1024, "")
c := NewCache(1024)

c.Delete([][]byte{[]byte("bar")})

Expand All @@ -337,7 +337,7 @@ func TestCache_CacheWriteMulti_Duplicates(t *testing.T) {
v5 := NewValue(5, 3.0)
values1 := Values{v3, v4, v5}

c := NewCache(0, "")
c := NewCache(0)

if err := c.WriteMulti(map[string][]Value{"foo": values0}); err != nil {
t.Fatalf("failed to write key foo to cache: %s", err.Error())
Expand Down Expand Up @@ -367,7 +367,7 @@ func TestCache_CacheValues(t *testing.T) {
v3 := NewValue(1, 1.0)
v4 := NewValue(4, 4.0)

c := NewCache(512, "")
c := NewCache(512)
if deduped := c.Values([]byte("no such key")); deduped != nil {
t.Fatalf("Values returned for no such key")
}
Expand Down Expand Up @@ -395,7 +395,7 @@ func TestCache_CacheSnapshot(t *testing.T) {
v6 := NewValue(7, 5.0)
v7 := NewValue(2, 5.0)

c := NewCache(512, "")
c := NewCache(512)
if err := c.Write([]byte("foo"), Values{v0, v1, v2, v3}); err != nil {
t.Fatalf("failed to write 3 values, key foo to cache: %s", err.Error())
}
Expand Down Expand Up @@ -472,9 +472,9 @@ func TestCache_CacheSnapshot(t *testing.T) {
// Tests that Snapshot updates statistics correctly.
func TestCache_Snapshot_Stats(t *testing.T) {
limit := uint64(16)
c := NewCache(limit, "")
c := NewCache(limit)

values := map[string][]Value{"foo": []Value{NewValue(1, 1.0)}}
values := map[string][]Value{"foo": {NewValue(1, 1.0)}}
if err := c.WriteMulti(values); err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -504,7 +504,7 @@ func TestCache_Snapshot_Stats(t *testing.T) {
}

func TestCache_CacheEmptySnapshot(t *testing.T) {
c := NewCache(512, "")
c := NewCache(512)

// Grab snapshot, and ensure it's as expected.
snapshot, err := c.Snapshot()
Expand All @@ -531,7 +531,7 @@ func TestCache_CacheWriteMemoryExceeded(t *testing.T) {
v0 := NewValue(1, 1.0)
v1 := NewValue(2, 2.0)

c := NewCache(uint64(v1.Size()), "")
c := NewCache(uint64(v1.Size()))

if err := c.Write([]byte("foo"), Values{v0}); err != nil {
t.Fatalf("failed to write key foo to cache: %s", err.Error())
Expand Down Expand Up @@ -577,7 +577,7 @@ func TestCache_Deduplicate_Concurrent(t *testing.T) {
}

wg := sync.WaitGroup{}
c := NewCache(1000000, "")
c := NewCache(1000000)

wg.Add(1)
go func() {
Expand Down Expand Up @@ -611,9 +611,9 @@ func TestCacheLoader_LoadSingle(t *testing.T) {
p3 := NewValue(1, true)

values := map[string][]Value{
"foo": []Value{p1},
"bar": []Value{p2},
"baz": []Value{p3},
"foo": {p1},
"bar": {p2},
"baz": {p3},
}

entry := &WriteWALEntry{
Expand All @@ -629,7 +629,7 @@ func TestCacheLoader_LoadSingle(t *testing.T) {
}

// Load the cache using the segment.
cache := NewCache(1024, "")
cache := NewCache(1024)
loader := NewCacheLoader([]string{f.Name()})
if err := loader.Load(cache); err != nil {
t.Fatalf("failed to load cache: %s", err.Error())
Expand All @@ -652,7 +652,7 @@ func TestCacheLoader_LoadSingle(t *testing.T) {
}

// Reload the cache using the segment.
cache = NewCache(1024, "")
cache = NewCache(1024)
loader = NewCacheLoader([]string{f.Name()})
if err := loader.Load(cache); err != nil {
t.Fatalf("failed to load cache: %s", err.Error())
Expand Down Expand Up @@ -698,13 +698,13 @@ func TestCacheLoader_LoadDouble(t *testing.T) {
}

values := map[string][]Value{
"foo": []Value{p1},
"bar": []Value{p2},
"foo": {p1},
"bar": {p2},
}
segmentWrite(w1, values)
values = map[string][]Value{
"baz": []Value{p3},
"qux": []Value{p4},
"baz": {p3},
"qux": {p4},
}
segmentWrite(w2, values)

Expand All @@ -714,7 +714,7 @@ func TestCacheLoader_LoadDouble(t *testing.T) {
}

// Load the cache using the segments.
cache := NewCache(1024, "")
cache := NewCache(1024)
loader := NewCacheLoader([]string{f1.Name(), f2.Name()})
if err := loader.Load(cache); err != nil {
t.Fatalf("failed to load cache: %s", err.Error())
Expand Down Expand Up @@ -748,7 +748,7 @@ func TestCacheLoader_LoadDeleted(t *testing.T) {
p3 := NewValue(3, 3.0)

values := map[string][]Value{
"foo": []Value{p1, p2, p3},
"foo": {p1, p2, p3},
}

entry := &WriteWALEntry{
Expand Down Expand Up @@ -778,7 +778,7 @@ func TestCacheLoader_LoadDeleted(t *testing.T) {
}

// Load the cache using the segment.
cache := NewCache(1024, "")
cache := NewCache(1024)
loader := NewCacheLoader([]string{f.Name()})
if err := loader.Load(cache); err != nil {
t.Fatalf("failed to load cache: %s", err.Error())
Expand All @@ -790,7 +790,7 @@ func TestCacheLoader_LoadDeleted(t *testing.T) {
}

// Reload the cache using the segment.
cache = NewCache(1024, "")
cache = NewCache(1024)
loader = NewCacheLoader([]string{f.Name()})
if err := loader.Load(cache); err != nil {
t.Fatalf("failed to load cache: %s", err.Error())
Expand All @@ -809,7 +809,7 @@ func TestCache_Split(t *testing.T) {
values := Values{v0, v1, v2}
valuesSize := uint64(v0.Size() + v1.Size() + v2.Size())

c := NewCache(0, "")
c := NewCache(0)

if err := c.Write([]byte("foo"), values); err != nil {
t.Fatalf("failed to write key foo to cache: %s", err.Error())
Expand Down Expand Up @@ -898,7 +898,7 @@ func (s *TestStore) count() int { return s.c
var fvSize = uint64(NewValue(1, float64(1)).Size())

func BenchmarkCacheFloatEntries(b *testing.B) {
cache := NewCache(uint64(b.N)*fvSize, "")
cache := NewCache(uint64(b.N) * fvSize)
vals := make([][]Value, b.N)
for i := 0; i < b.N; i++ {
vals[i] = []Value{NewValue(1, float64(i))}
Expand All @@ -919,7 +919,7 @@ type points struct {

func BenchmarkCacheParallelFloatEntries(b *testing.B) {
c := b.N * runtime.GOMAXPROCS(0)
cache := NewCache(uint64(c)*fvSize*10, "")
cache := NewCache(uint64(c) * fvSize * 10)
vals := make([]points, c)
for i := 0; i < c; i++ {
v := make([]Value, 10)
Expand Down

0 comments on commit 0dc5393

Please sign in to comment.