diff --git a/pkg/mmap/mmap_test.go b/pkg/mmap/mmap_test.go index 41096064d4..91aecf4119 100644 --- a/pkg/mmap/mmap_test.go +++ b/pkg/mmap/mmap_test.go @@ -2,7 +2,6 @@ package mmap_test import ( "bytes" - "io" "io/ioutil" "testing" diff --git a/pkg/rhh/rhh.go b/pkg/rhh/rhh.go index 85f24ee5c2..5eff0dabb6 100644 --- a/pkg/rhh/rhh.go +++ b/pkg/rhh/rhh.go @@ -21,7 +21,7 @@ type HashMap struct { func NewHashMap(opt Options) *HashMap { m := &HashMap{ - capacity: pow2(opt.Capacity), + capacity: pow2(opt.Capacity), // Limited to 2^32. loadFactor: opt.LoadFactor, } m.alloc() diff --git a/tsdb/engine/tsm1/engine_test.go b/tsdb/engine/tsm1/engine_test.go index 6d1ee5cb67..703dd209ec 100644 --- a/tsdb/engine/tsm1/engine_test.go +++ b/tsdb/engine/tsm1/engine_test.go @@ -44,7 +44,7 @@ func TestEngine_LoadMetadataIndex(t *testing.T) { } // Verify index is correct. - m, err := index.Measurement("cpu") + m, err := index.Measurement([]byte("cpu")) if err != nil { t.Fatal(err) } else if m == nil { @@ -70,7 +70,7 @@ func TestEngine_LoadMetadataIndex(t *testing.T) { } // Verify index is correct. - if m, err = index.Measurement("cpu"); err != nil { + if m, err = index.Measurement([]byte("cpu")); err != nil { t.Fatal(err) } else if m == nil { t.Fatal("measurement not found") @@ -97,7 +97,7 @@ func TestEngine_LoadMetadataIndex(t *testing.T) { } // Verify index is correct. - if m, err = index.Measurement("cpu"); err != nil { + if m, err = index.Measurement([]byte("cpu")); err != nil { t.Fatal(err) } else if m == nil { t.Fatal("measurement not found") @@ -121,7 +121,7 @@ func TestEngine_DeleteWALLoadMetadata(t *testing.T) { } // Remove series. - if err := e.DeleteSeriesRange([]string{"cpu,host=A"}, math.MinInt64, math.MaxInt64); err != nil { + if err := e.DeleteSeriesRange([][]byte{[]byte("cpu,host=A")}, math.MinInt64, math.MaxInt64); err != nil { t.Fatalf("failed to delete series: %s", err.Error()) } @@ -231,7 +231,7 @@ func TestEngine_CreateIterator_Cache_Ascending(t *testing.T) { e.CreateMeasurement("cpu") e.MeasurementFields("cpu").CreateFieldIfNotExists("value", influxql.Float, false) - e.CreateSeries("cpu", tsdb.NewSeries("cpu,host=A", models.NewTags(map[string]string{"host": "A"}))) + e.CreateSeries("cpu", tsdb.NewSeries([]byte("cpu,host=A"), models.NewTags(map[string]string{"host": "A"}))) if err := e.WritePointsString( `cpu,host=A value=1.1 1000000000`, `cpu,host=A value=1.2 2000000000`, @@ -284,7 +284,7 @@ func TestEngine_CreateIterator_Cache_Descending(t *testing.T) { e.CreateMeasurement("cpu") e.MeasurementFields("cpu").CreateFieldIfNotExists("value", influxql.Float, false) - e.CreateSeries("cpu", tsdb.NewSeries("cpu,host=A", models.NewTags(map[string]string{"host": "A"}))) + e.CreateSeries("cpu", tsdb.NewSeries([]byte("cpu,host=A"), models.NewTags(map[string]string{"host": "A"}))) if err := e.WritePointsString( `cpu,host=A value=1.1 1000000000`, `cpu,host=A value=1.2 2000000000`, @@ -337,7 +337,7 @@ func TestEngine_CreateIterator_TSM_Ascending(t *testing.T) { e.CreateMeasurement("cpu") e.MeasurementFields("cpu").CreateFieldIfNotExists("value", influxql.Float, false) - e.CreateSeries("cpu", tsdb.NewSeries("cpu,host=A", models.NewTags(map[string]string{"host": "A"}))) + e.CreateSeries("cpu", tsdb.NewSeries([]byte("cpu,host=A"), models.NewTags(map[string]string{"host": "A"}))) if err := e.WritePointsString( `cpu,host=A value=1.1 1000000000`, `cpu,host=A value=1.2 2000000000`, @@ -391,7 +391,7 @@ func TestEngine_CreateIterator_TSM_Descending(t *testing.T) { e.CreateMeasurement("cpu") e.MeasurementFields("cpu").CreateFieldIfNotExists("value", influxql.Float, false) - e.CreateSeries("cpu", tsdb.NewSeries("cpu,host=A", models.NewTags(map[string]string{"host": "A"}))) + e.CreateSeries("cpu", tsdb.NewSeries([]byte("cpu,host=A"), models.NewTags(map[string]string{"host": "A"}))) if err := e.WritePointsString( `cpu,host=A value=1.1 1000000000`, `cpu,host=A value=1.2 2000000000`, @@ -446,7 +446,7 @@ func TestEngine_CreateIterator_Aux(t *testing.T) { e.CreateMeasurement("cpu") e.MeasurementFields("cpu").CreateFieldIfNotExists("value", influxql.Float, false) e.MeasurementFields("cpu").CreateFieldIfNotExists("F", influxql.Float, false) - e.CreateSeries("cpu", tsdb.NewSeries("cpu,host=A", models.NewTags(map[string]string{"host": "A"}))) + e.CreateSeries("cpu", tsdb.NewSeries([]byte("cpu,host=A"), models.NewTags(map[string]string{"host": "A"}))) if err := e.WritePointsString( `cpu,host=A value=1.1 1000000000`, `cpu,host=A F=100 1000000000`, @@ -507,7 +507,7 @@ func TestEngine_CreateIterator_Condition(t *testing.T) { e.MeasurementFields("cpu").CreateFieldIfNotExists("value", influxql.Float, false) e.MeasurementFields("cpu").CreateFieldIfNotExists("X", influxql.Float, false) e.MeasurementFields("cpu").CreateFieldIfNotExists("Y", influxql.Float, false) - e.CreateSeries("cpu", tsdb.NewSeries("cpu,host=A", models.NewTags(map[string]string{"host": "A"}))) + e.CreateSeries("cpu", tsdb.NewSeries([]byte("cpu,host=A"), models.NewTags(map[string]string{"host": "A"}))) if err := e.WritePointsString( `cpu,host=A value=1.1 1000000000`, `cpu,host=A X=10 1000000000`, @@ -592,7 +592,7 @@ func TestEngine_DeleteSeries(t *testing.T) { t.Fatalf("series count mismatch: exp %v, got %v", exp, got) } - if err := e.DeleteSeriesRange([]string{"cpu,host=A"}, math.MinInt64, math.MaxInt64); err != nil { + if err := e.DeleteSeriesRange([][]byte{[]byte("cpu,host=A")}, math.MinInt64, math.MaxInt64); err != nil { t.Fatalf("failed to delete series: %v", err) } @@ -901,7 +901,7 @@ func MustInitBenchmarkEngine(pointN int) *Engine { // Initialize metadata. e.CreateMeasurement("cpu") e.MeasurementFields("cpu").CreateFieldIfNotExists("value", influxql.Float, false) - e.CreateSeries("cpu", tsdb.NewSeries("cpu,host=A", models.NewTags(map[string]string{"host": "A"}))) + e.CreateSeries("cpu", tsdb.NewSeries([]byte("cpu,host=A"), models.NewTags(map[string]string{"host": "A"}))) // Generate time ascending points with jitterred time & value. rand := rand.New(rand.NewSource(0)) @@ -1003,7 +1003,7 @@ func (e *Engine) MustWriteSnapshot() { // MustMeasurement calls Measurement on the underlying tsdb.Engine, and panics // if it returns an error. func (e *Engine) MustMeasurement(name string) *tsdb.Measurement { - m, err := e.Engine.Measurement(name) + m, err := e.Engine.Measurement([]byte(name)) if err != nil { panic(err) } diff --git a/tsdb/meta_test.go b/tsdb/meta_test.go index 09bfe5dfda..aeca64999d 100644 --- a/tsdb/meta_test.go +++ b/tsdb/meta_test.go @@ -122,7 +122,7 @@ func TestMeasurement_AppendSeriesKeysByID_Exists(t *testing.T) { func BenchmarkMeasurement_SeriesIDForExp_EQRegex(b *testing.B) { m := tsdb.NewMeasurement("cpu") for i := 0; i < 100000; i++ { - s := tsdb.NewSeries("cpu", models.Tags{models.Tag{ + s := tsdb.NewSeries([]byte("cpu"), models.Tags{models.Tag{ Key: []byte("host"), Value: []byte(fmt.Sprintf("host%d", i))}}) s.ID = uint64(i) @@ -153,7 +153,7 @@ func BenchmarkMeasurement_SeriesIDForExp_EQRegex(b *testing.B) { func BenchmarkMeasurement_SeriesIDForExp_NERegex(b *testing.B) { m := tsdb.NewMeasurement("cpu") for i := 0; i < 100000; i++ { - s := tsdb.NewSeries("cpu", models.Tags{models.Tag{ + s := tsdb.NewSeries([]byte("cpu"), models.Tags{models.Tag{ Key: []byte("host"), Value: []byte(fmt.Sprintf("host%d", i))}}) s.ID = uint64(i) @@ -279,7 +279,7 @@ func genTestSeries(mCnt, tCnt, vCnt int) []*TestSeries { for _, ts := range tagSets { series = append(series, &TestSeries{ Measurement: m, - Series: tsdb.NewSeries(fmt.Sprintf("%s:%s", m, string(tsdb.MarshalTags(ts))), models.NewTags(ts)), + Series: tsdb.NewSeries([]byte(fmt.Sprintf("%s:%s", m, string(tsdb.MarshalTags(ts)))), models.NewTags(ts)), }) } } diff --git a/tsdb/shard_test.go b/tsdb/shard_test.go index 453e44e442..5908896978 100644 --- a/tsdb/shard_test.go +++ b/tsdb/shard_test.go @@ -74,11 +74,11 @@ func TestShardWriteAndIndex(t *testing.T) { t.Fatalf("got %v series, exp %v series in index", got, exp) } - seriesTags := sh.Series(string(pt.Key())).Tags + seriesTags := sh.Series(pt.Key()).Tags if len(seriesTags) != len(pt.Tags()) || pt.Tags().GetString("host") != seriesTags.GetString("host") { t.Fatalf("tags weren't properly saved to series index: %v, %v", pt.Tags(), seriesTags) } - if !reflect.DeepEqual(sh.Measurement("cpu").TagKeys(), []string{"host"}) { + if !reflect.DeepEqual(sh.Measurement([]byte("cpu")).TagKeys(), []string{"host"}) { t.Fatalf("tag key wasn't saved to measurement index") } } @@ -238,7 +238,7 @@ func TestWriteTimeTag(t *testing.T) { t.Fatalf("unexpected log message: %s", strings.TrimSpace(got)) } - m := sh.Measurement("cpu") + m := sh.Measurement([]byte("cpu")) if m != nil { t.Fatal("unexpected cpu measurement") } @@ -258,7 +258,7 @@ func TestWriteTimeTag(t *testing.T) { t.Fatalf("unexpected log message: %s", strings.TrimSpace(got)) } - m = sh.Measurement("cpu") + m = sh.Measurement([]byte("cpu")) if m == nil { t.Fatal("expected cpu measurement") } @@ -299,7 +299,7 @@ func TestWriteTimeField(t *testing.T) { } key := models.MakeKey([]byte("cpu"), nil) - series := sh.Series(string(key)) + series := sh.Series(key) if series == nil { t.Fatal("expected series") } else if len(series.Tags) != 0 { @@ -354,15 +354,15 @@ func TestShardWriteAddNewField(t *testing.T) { t.Fatalf("got %d series, exp %d series in index", got, exp) } - seriesTags := sh.Series(string(pt.Key())).Tags + seriesTags := sh.Series(pt.Key()).Tags if len(seriesTags) != len(pt.Tags()) || pt.Tags().GetString("host") != seriesTags.GetString("host") { t.Fatalf("tags weren't properly saved to series index: %v, %v", pt.Tags(), seriesTags) } - if !reflect.DeepEqual(sh.Measurement("cpu").TagKeys(), []string{"host"}) { + if !reflect.DeepEqual(sh.Measurement([]byte("cpu")).TagKeys(), []string{"host"}) { t.Fatalf("tag key wasn't saved to measurement index") } - if len(sh.Measurement("cpu").FieldNames()) != 2 { + if len(sh.Measurement([]byte("cpu")).FieldNames()) != 2 { t.Fatalf("field names wasn't saved to measurement index") } }