Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.

Commit 3823c2b

Browse files
committed
cleanup
1 parent e3c1aed commit 3823c2b

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

api/dataprocessor_test.go

+4-7
Original file line numberDiff line numberDiff line change
@@ -499,9 +499,6 @@ func TestGetSeriesCachedStore(t *testing.T) {
499499
metrics := mdata.NewAggMetrics(store, &cache.MockCache{}, false, 0, 0, 0)
500500
srv.BindMemoryStore(metrics)
501501
metric := test.GetAMKey(1)
502-
var c *cache.CCache
503-
var itgen *chunk.IterGen
504-
var prevts uint32
505502

506503
type testcase struct {
507504
// the pattern of chunks
@@ -544,14 +541,14 @@ func TestGetSeriesCachedStore(t *testing.T) {
544541
for from := start; from <= lastTs; from += step {
545542
for to := from; to <= lastTs; to += step {
546543
// use fresh store and cache
547-
c = cache.NewCCache()
544+
c := cache.NewCCache()
548545
srv.BindCache(c)
549546
store.Reset()
550547

551548
// populate cache and store according to pattern definition
552-
prevts = 0
549+
var prevts uint32
553550
for i := 0; i < len(tc.Pattern); i++ {
554-
itgen = chunk.NewBareIterGen(chunks[i].Series.Bytes(), chunks[i].Series.T0, span)
551+
itgen := chunk.NewBareIterGen(chunks[i].Series.Bytes(), chunks[i].Series.T0, span)
555552
if pattern[i] == 'c' || pattern[i] == 'b' {
556553
c.Add(metric, prevts, *itgen)
557554
}
@@ -589,7 +586,7 @@ func TestGetSeriesCachedStore(t *testing.T) {
589586
// we use the tsTracker to increase together with the iterators and compare at each step
590587
tsTracker := expectResFrom
591588

592-
tsSlice := make([]uint32, 0)
589+
var tsSlice []uint32
593590
for i, it := range iters {
594591
for it.Next() {
595592
ts, _ := it.Values()

mdata/cache/ccache.go

+9-10
Original file line numberDiff line numberDiff line change
@@ -204,22 +204,21 @@ func (c *CCache) evict(target *accnt.EvictTarget) {
204204
func (c *CCache) Search(ctx context.Context, metric schema.AMKey, from, until uint32) (*CCSearchResult, error) {
205205
ctx, span := tracing.NewSpan(ctx, c.tracer, "CCache.Search")
206206
defer span.Finish()
207-
var hit chunk.IterGen
208-
var cm *CCacheMetric
209-
var ok bool
210-
res := &CCSearchResult{
211-
From: from,
212-
Until: until,
213-
}
214207

215208
if from >= until {
216209
return nil, ErrInvalidRange
217210
}
218211

212+
res := &CCSearchResult{
213+
From: from,
214+
Until: until,
215+
}
216+
219217
c.RLock()
220218
defer c.RUnlock()
221219

222-
if cm, ok = c.metricCache[metric]; !ok {
220+
cm, ok := c.metricCache[metric]
221+
if !ok {
223222
span.SetTag("cache", "miss")
224223
accnt.CacheMetricMiss.Inc()
225224
return res, nil
@@ -233,10 +232,10 @@ func (c *CCache) Search(ctx context.Context, metric schema.AMKey, from, until ui
233232

234233
accnt.CacheChunkHit.Add(len(res.Start) + len(res.End))
235234
go func() {
236-
for _, hit = range res.Start {
235+
for _, hit := range res.Start {
237236
c.accnt.HitChunk(metric, hit.Ts)
238237
}
239-
for _, hit = range res.End {
238+
for _, hit := range res.End {
240239
c.accnt.HitChunk(metric, hit.Ts)
241240
}
242241
}()

store/cassandra/store_cassandra.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const Month_sec = 60 * 60 * 24 * 28
3333
const Table_name_format = `metric_%d`
3434

3535
var (
36-
errChunkTooSmall = errors.New("unpossibly small chunk in cassandra")
36+
errChunkTooSmall = errors.New("impossibly small chunk in cassandra")
3737
errInvalidRange = errors.New("CassandraStore: invalid range: from must be less than to")
3838
errReadQueueFull = errors.New("the read queue is full")
3939
errReadTooOld = errors.New("the read is too old")

0 commit comments

Comments
 (0)