From 80db24386eed6abe1b00476a1dad944eab2fd08d Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Thu, 20 Jun 2019 14:37:46 +0300 Subject: [PATCH] lib/storage: typo fixes found by golangci-lint; updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/69 --- lib/storage/index_db.go | 2 +- lib/storage/index_db_timing_test.go | 4 ---- lib/storage/metric_name.go | 7 ------- lib/storage/search_test.go | 2 +- lib/storage/table_search_timing_test.go | 2 +- 5 files changed, 3 insertions(+), 14 deletions(-) diff --git a/lib/storage/index_db.go b/lib/storage/index_db.go index 357b72adf..ccb678144 100644 --- a/lib/storage/index_db.go +++ b/lib/storage/index_db.go @@ -250,7 +250,7 @@ func (db *indexDB) incRef() { func (db *indexDB) decRef() { n := atomic.AddUint64(&db.refCount, ^uint64(0)) - if n < 0 { + if int64(n) < 0 { logger.Panicf("BUG: negative refCount: %d", n) } if n > 0 { diff --git a/lib/storage/index_db_timing_test.go b/lib/storage/index_db_timing_test.go index ae18371ad..4f03d925d 100644 --- a/lib/storage/index_db_timing_test.go +++ b/lib/storage/index_db_timing_test.go @@ -88,8 +88,6 @@ func BenchmarkIndexDBSearchTSIDs(b *testing.B) { } }() - const accountsCount = 111 - const projectsCount = 33333 const recordsCount = 1e5 // Fill the db with recordsCount records. @@ -160,8 +158,6 @@ func BenchmarkIndexDBGetTSIDs(b *testing.B) { }() const recordsPerLoop = 1000 - const accountsCount = 111 - const projectsCount = 33333 const recordsCount = 1e5 // Fill the db with recordsCount records. diff --git a/lib/storage/metric_name.go b/lib/storage/metric_name.go index 15dcaf265..968317b08 100644 --- a/lib/storage/metric_name.go +++ b/lib/storage/metric_name.go @@ -586,13 +586,6 @@ func copyTags(dst, src []Tag) []Tag { return dst } -func (mn *MetricName) tagsLess(i, j int) bool { - a, b := mn.Tags[i].Key, mn.Tags[j].Key - a = normalizeTagKey(a) - b = normalizeTagKey(b) - return bytes.Compare(a, b) < 0 -} - var commonTagKeys = func() map[string][]byte { lcm := map[string][]byte{ // job-like tags must go first in MetricName.Tags. diff --git a/lib/storage/search_test.go b/lib/storage/search_test.go index f0bdfd4bd..d02383669 100644 --- a/lib/storage/search_test.go +++ b/lib/storage/search_test.go @@ -44,7 +44,7 @@ func TestSearchQueryMarshalUnmarshal(t *testing.T) { if sq1.MaxTimestamp != sq2.MaxTimestamp { t.Fatalf("unexpected MaxTimestamp; got %d; want %d", sq2.MaxTimestamp, sq1.MaxTimestamp) } - if len(sq1.TagFilterss) != len(sq1.TagFilterss) { + if len(sq1.TagFilterss) != len(sq2.TagFilterss) { t.Fatalf("unexpected TagFilterss len; got %d; want %d", len(sq2.TagFilterss), len(sq1.TagFilterss)) } for ii := range sq1.TagFilterss { diff --git a/lib/storage/table_search_timing_test.go b/lib/storage/table_search_timing_test.go index 0aec43f90..917664de6 100644 --- a/lib/storage/table_search_timing_test.go +++ b/lib/storage/table_search_timing_test.go @@ -92,7 +92,7 @@ func createBenchTable(b *testing.B, path string, startTimestamp int64, rowsPerIn r.Value = value } if err := tb.AddRows(rows); err != nil { - b.Fatalf("cannot add %d rows: %s", rowsPerInsert, err) + panic(fmt.Errorf("cannot add %d rows: %s", rowsPerInsert, err)) } } wg.Done()