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

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Dieterbe committed May 20, 2018
1 parent e3c1aed commit 3823c2b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
11 changes: 4 additions & 7 deletions api/dataprocessor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,9 +499,6 @@ func TestGetSeriesCachedStore(t *testing.T) {
metrics := mdata.NewAggMetrics(store, &cache.MockCache{}, false, 0, 0, 0)
srv.BindMemoryStore(metrics)
metric := test.GetAMKey(1)
var c *cache.CCache
var itgen *chunk.IterGen
var prevts uint32

type testcase struct {
// the pattern of chunks
Expand Down Expand Up @@ -544,14 +541,14 @@ func TestGetSeriesCachedStore(t *testing.T) {
for from := start; from <= lastTs; from += step {
for to := from; to <= lastTs; to += step {
// use fresh store and cache
c = cache.NewCCache()
c := cache.NewCCache()
srv.BindCache(c)
store.Reset()

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

tsSlice := make([]uint32, 0)
var tsSlice []uint32
for i, it := range iters {
for it.Next() {
ts, _ := it.Values()
Expand Down
19 changes: 9 additions & 10 deletions mdata/cache/ccache.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,22 +204,21 @@ func (c *CCache) evict(target *accnt.EvictTarget) {
func (c *CCache) Search(ctx context.Context, metric schema.AMKey, from, until uint32) (*CCSearchResult, error) {
ctx, span := tracing.NewSpan(ctx, c.tracer, "CCache.Search")
defer span.Finish()
var hit chunk.IterGen
var cm *CCacheMetric
var ok bool
res := &CCSearchResult{
From: from,
Until: until,
}

if from >= until {
return nil, ErrInvalidRange
}

res := &CCSearchResult{
From: from,
Until: until,
}

c.RLock()
defer c.RUnlock()

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

accnt.CacheChunkHit.Add(len(res.Start) + len(res.End))
go func() {
for _, hit = range res.Start {
for _, hit := range res.Start {
c.accnt.HitChunk(metric, hit.Ts)
}
for _, hit = range res.End {
for _, hit := range res.End {
c.accnt.HitChunk(metric, hit.Ts)
}
}()
Expand Down
2 changes: 1 addition & 1 deletion store/cassandra/store_cassandra.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const Month_sec = 60 * 60 * 24 * 28
const Table_name_format = `metric_%d`

var (
errChunkTooSmall = errors.New("unpossibly small chunk in cassandra")
errChunkTooSmall = errors.New("impossibly small chunk in cassandra")
errInvalidRange = errors.New("CassandraStore: invalid range: from must be less than to")
errReadQueueFull = errors.New("the read queue is full")
errReadTooOld = errors.New("the read is too old")
Expand Down

0 comments on commit 3823c2b

Please sign in to comment.