From c014bee69db912f275bc91e5e91cbeca7e8b9f32 Mon Sep 17 00:00:00 2001 From: Subsegment <304741833@qq.com> Date: Thu, 22 Sep 2022 14:24:14 +0800 Subject: [PATCH 1/7] update http header --- cmd/load_cnosdb/http_writer.go | 9 ++++++--- cmd/load_cnosdb/process.go | 1 + go.sum | 1 - load/loader.go | 2 ++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cmd/load_cnosdb/http_writer.go b/cmd/load_cnosdb/http_writer.go index 6fb7c0d..a1a7699 100644 --- a/cmd/load_cnosdb/http_writer.go +++ b/cmd/load_cnosdb/http_writer.go @@ -5,7 +5,6 @@ package main import ( "bytes" "fmt" - "net/url" "time" "github.com/valyala/fasthttp" @@ -36,6 +35,8 @@ type HTTPWriterConfig struct { // Name of the target database into which points will be written. Database string + Auth string + // Debug label for more informative errors. DebugInfo string } @@ -56,7 +57,7 @@ func NewHTTPWriter(c HTTPWriterConfig, consistency string) *HTTPWriter { }, c: c, - url: []byte(c.Host + "/write/line_protocol?consistency=" + consistency + "&db=" + url.QueryEscape(c.Database)), + url: []byte(c.Host + "/write"), } } @@ -69,6 +70,8 @@ func (w *HTTPWriter) initializeReq(req *fasthttp.Request, body []byte, isGzip bo req.Header.SetContentTypeBytes(textPlain) req.Header.SetMethodBytes(methodPost) req.Header.SetRequestURIBytes(w.url) + req.Header.Add("database", w.c.Database) + req.Header.Add("user_id", w.c.Auth) if isGzip { req.Header.Add(headerContentEncoding, headerGzip) } @@ -83,7 +86,7 @@ func (w *HTTPWriter) executeReq(req *fasthttp.Request, resp *fasthttp.Response) sc := resp.StatusCode() if sc == 500 && backpressurePred(resp.Body()) { err = errBackoff - } else if sc != fasthttp.StatusNoContent { + } else if sc != fasthttp.StatusOK { err = fmt.Errorf("[DebugInfo: %s] Invalid write response (status %d): %s", w.c.DebugInfo, sc, resp.Body()) } } diff --git a/cmd/load_cnosdb/process.go b/cmd/load_cnosdb/process.go index 0d36830..f6fcc79 100644 --- a/cmd/load_cnosdb/process.go +++ b/cmd/load_cnosdb/process.go @@ -27,6 +27,7 @@ func (p *processor) Init(numWorker int, _, _ bool) { DebugInfo: fmt.Sprintf("worker #%d, dest url: %s", numWorker, daemonURL), Host: daemonURL, Database: loader.DatabaseName(), + Auth: config.Auth, } w := NewHTTPWriter(cfg, consistency) p.initWithHTTPWriter(numWorker, w) diff --git a/go.sum b/go.sum index 495f956..5153892 100644 --- a/go.sum +++ b/go.sum @@ -404,7 +404,6 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= diff --git a/load/loader.go b/load/loader.go index c468a08..5c7d06e 100644 --- a/load/loader.go +++ b/load/loader.go @@ -33,6 +33,7 @@ var ( // BenchmarkRunnerConfig contains all the configuration information required for running BenchmarkRunner. type BenchmarkRunnerConfig struct { DBName string `yaml:"db-name" mapstructure:"db-name" json:"db-name"` + Auth string `yaml:"user_id" mapstructure:"user_id" json:"user_id"` BatchSize uint `yaml:"batch-size" mapstructure:"batch-size" json:"batch-size"` Workers uint `yaml:"workers" mapstructure:"workers" json:"workers"` Limit uint64 `yaml:"limit" mapstructure:"limit" json:"limit"` @@ -53,6 +54,7 @@ type BenchmarkRunnerConfig struct { // AddToFlagSet adds command line flags needed by the BenchmarkRunnerConfig to the flag set. func (c BenchmarkRunnerConfig) AddToFlagSet(fs *pflag.FlagSet) { fs.String("db-name", "benchmark", "Name of database") + fs.String("user_id", "123", "auth of database") fs.Uint("batch-size", defaultBatchSize, "Number of items to batch together in a single insert") fs.Uint("workers", 1, "Number of parallel clients inserting") fs.Uint64("limit", 0, "Number of items to insert (0 = all of them).") From 8c71b381ac168ec90681f946081ffd69b05676d6 Mon Sep 17 00:00:00 2001 From: Subsegment <304741833@qq.com> Date: Thu, 29 Sep 2022 14:52:46 +0800 Subject: [PATCH 2/7] add flatbuffer --- cmd/generate_data/main.go | 26 +- .../databases/cnosdb/common.go | 8 +- cmd/generate_queries/databases/cnosdb/iot.go | 58 +- .../databases/cnosdb/iot_test.go | 174 +-- .../databases/influx/common.go | 8 +- cmd/generate_queries/databases/influx/iot.go | 58 +- .../databases/influx/iot_test.go | 174 +-- .../databases/timescaledb/common.go | 8 +- .../databases/timescaledb/iot.go | 84 +- .../databases/timescaledb/iot_test.go | 202 +-- cmd/generate_queries/main.go | 14 +- cmd/generate_queries/uses/common/common.go | 8 +- .../uses/common/common_test.go | 4 +- cmd/generate_queries/uses/iot/common.go | 14 +- cmd/load/config_cmd.go | 20 +- cmd/load/load_cmd.go | 10 +- cmd/load/load_cmd_flags.go | 2 +- cmd/load/parse_config.go | 22 +- cmd/load_cnosdb/http_writer.go | 1067 +++++++++++++++- cmd/load_cnosdb/main.go | 18 +- cmd/load_cnosdb/models/ColumnKey.go | 41 + cmd/load_cnosdb/models/ColumnKeys.go | 66 + cmd/load_cnosdb/models/ColumnKeysWithRange.go | 96 ++ cmd/load_cnosdb/models/Field.go | 136 ++ cmd/load_cnosdb/models/FieldType.go | 41 + cmd/load_cnosdb/models/PingBody.go | 81 ++ cmd/load_cnosdb/models/Point.go | 188 +++ cmd/load_cnosdb/models/Points.go | 107 ++ cmd/load_cnosdb/models/Row.go | 83 ++ cmd/load_cnosdb/models/RowField.go | 111 ++ cmd/load_cnosdb/models/RowKey.go | 41 + cmd/load_cnosdb/models/Rows.go | 67 + cmd/load_cnosdb/models/Tag.go | 121 ++ cmd/load_cnosdb/process.go | 20 +- cmd/load_cnosdb/process_test.go | 30 +- cmd/load_cnosdb/proto/kv_service.pb.go | 1130 +++++++++++++++++ cmd/load_cnosdb/proto/kv_service.proto | 90 ++ cmd/load_cnosdb/proto/kv_service_grpc.pb.go | 314 +++++ cmd/load_cnosdb/proto/model.fbs | 73 ++ cmd/load_cnosdb/scan.go | 4 +- cmd/load_cnosdb/scan_test.go | 8 +- cmd/load_influx/http_writer.go | 14 +- cmd/load_influx/main.go | 18 +- cmd/load_influx/process.go | 8 +- cmd/load_influx/process_test.go | 30 +- cmd/load_influx/scan.go | 4 +- cmd/load_influx/scan_test.go | 8 +- cmd/load_timescaledb/main.go | 34 +- cmd/run_queries_cnosdb/http_client.go | 20 +- cmd/run_queries_cnosdb/main.go | 18 +- cmd/run_queries_influx/http_client.go | 20 +- cmd/run_queries_influx/main.go | 20 +- cmd/run_queries_timescaledb/main.go | 48 +- go.mod | 3 + go.sum | 56 + internal/inputs/generator_data_test.go | 24 +- internal/inputs/generator_queries.go | 58 +- internal/inputs/generator_queries_test.go | 86 +- internal/inputs/generator_test.go | 18 +- internal/inputs/utils_test.go | 8 +- load/loader-no-flow-control.go | 10 +- load/loader_test.go | 44 +- load/scan_no_flow_control.go | 6 +- load/scan_no_flow_control_test.go | 4 +- load/scan_with_flow_control.go | 34 +- load/scan_with_flow_control_test.go | 12 +- pkg/data/source/config_test.go | 14 +- pkg/data/usecases/common/generator.go | 30 +- pkg/data/usecases/common/measurement.go | 4 +- pkg/data/usecases/common/measurement_test.go | 8 +- pkg/data/usecases/common/simulator.go | 44 +- pkg/data/usecases/common/simulator_test.go | 52 +- pkg/data/usecases/iot/diagnostics_test.go | 18 +- pkg/data/usecases/iot/readings_test.go | 4 +- pkg/data/usecases/iot/simulator.go | 64 +- pkg/data/usecases/iot/simulator_test.go | 46 +- pkg/data/usecases/iot/truck_test.go | 14 +- pkg/data/usecases/usecases.go | 6 +- pkg/data/usecases/usecases_test.go | 6 +- pkg/query/config/config.go | 16 +- pkg/query/timescaledb.go | 6 +- pkg/targets/cnosdb/serializer.go | 14 +- pkg/targets/cnosdb/serializer_test.go | 2 +- pkg/targets/influx/serializer.go | 12 +- pkg/targets/influx/serializer_test.go | 2 +- pkg/targets/targets.go | 10 +- pkg/targets/timescaledb/benchmark.go | 2 +- pkg/targets/timescaledb/creator.go | 46 +- pkg/targets/timescaledb/file_data_source.go | 10 +- pkg/targets/timescaledb/implemented_target.go | 16 +- pkg/targets/timescaledb/process.go | 58 +- pkg/targets/timescaledb/scan.go | 4 +- pkg/targets/timescaledb/scan_test.go | 14 +- pkg/targets/timescaledb/serializer.go | 2 +- pkg/targets/timescaledb/serializer_test.go | 2 +- .../timescaledb/simulation_data_source.go | 8 +- 96 files changed, 4942 insertions(+), 1024 deletions(-) create mode 100644 cmd/load_cnosdb/models/ColumnKey.go create mode 100644 cmd/load_cnosdb/models/ColumnKeys.go create mode 100644 cmd/load_cnosdb/models/ColumnKeysWithRange.go create mode 100644 cmd/load_cnosdb/models/Field.go create mode 100644 cmd/load_cnosdb/models/FieldType.go create mode 100644 cmd/load_cnosdb/models/PingBody.go create mode 100644 cmd/load_cnosdb/models/Point.go create mode 100644 cmd/load_cnosdb/models/Points.go create mode 100644 cmd/load_cnosdb/models/Row.go create mode 100644 cmd/load_cnosdb/models/RowField.go create mode 100644 cmd/load_cnosdb/models/RowKey.go create mode 100644 cmd/load_cnosdb/models/Rows.go create mode 100644 cmd/load_cnosdb/models/Tag.go create mode 100644 cmd/load_cnosdb/proto/kv_service.pb.go create mode 100644 cmd/load_cnosdb/proto/kv_service.proto create mode 100644 cmd/load_cnosdb/proto/kv_service_grpc.pb.go create mode 100644 cmd/load_cnosdb/proto/model.fbs diff --git a/cmd/generate_data/main.go b/cmd/generate_data/main.go index 9607b3a..6621429 100644 --- a/cmd/generate_data/main.go +++ b/cmd/generate_data/main.go @@ -17,7 +17,7 @@ import ( "os" "os/signal" "runtime/pprof" - + "github.com/blagojts/viper" "github.com/cnosdb/tsdb-comparisons/internal/inputs" "github.com/cnosdb/tsdb-comparisons/internal/utils" @@ -35,25 +35,25 @@ var ( // Parse args: func init() { config.AddToFlagSet(pflag.CommandLine) - + pflag.String("profile-file", "", "File to which to write go profiling data") - + pflag.Parse() - + err := utils.SetupConfigFile() - + if err != nil { panic(fmt.Errorf("fatal error config file: %s", err)) } - + if err := viper.Unmarshal(&config.BaseConfig); err != nil { panic(fmt.Errorf("unable to decode base config: %s", err)) } - + if err := viper.Unmarshal(&config); err != nil { panic(fmt.Errorf("unable to decode config: %s", err)) } - + profileFile = viper.GetString("profile-file") } @@ -75,25 +75,25 @@ func startMemoryProfile(profileFile string) func() { if err != nil { log.Fatal("could not create memory profile: ", err) } - + stop := func() { if err := pprof.WriteHeapProfile(f); err != nil { log.Fatal("could not write memory profile: ", err) } f.Close() } - + // Catches ctrl+c signals go func() { c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt) <-c - + fmt.Fprintln(os.Stderr, "\ncaught interrupt, stopping profile") stop() - + os.Exit(0) }() - + return stop } diff --git a/cmd/generate_queries/databases/cnosdb/common.go b/cmd/generate_queries/databases/cnosdb/common.go index f2e9e61..54f59f3 100644 --- a/cmd/generate_queries/databases/cnosdb/common.go +++ b/cmd/generate_queries/databases/cnosdb/common.go @@ -4,7 +4,7 @@ import ( "fmt" "net/url" "time" - + "github.com/cnosdb/tsdb-comparisons/cmd/generate_queries/uses/iot" "github.com/cnosdb/tsdb-comparisons/cmd/generate_queries/utils" "github.com/cnosdb/tsdb-comparisons/pkg/query" @@ -35,15 +35,15 @@ func (g *BaseGenerator) fillInQuery(qi query.Query, humanLabel, humanDesc, cnosq // NewIoT creates a new iot use case query generator. func (g *BaseGenerator) NewIoT(start, end time.Time, scale int) (utils.QueryGenerator, error) { core, err := iot.NewCore(start, end, scale) - + if err != nil { return nil, err } - + devops := &IoT{ BaseGenerator: g, Core: core, } - + return devops, nil } diff --git a/cmd/generate_queries/databases/cnosdb/iot.go b/cmd/generate_queries/databases/cnosdb/iot.go index 73fc041..8c7c5e4 100644 --- a/cmd/generate_queries/databases/cnosdb/iot.go +++ b/cmd/generate_queries/databases/cnosdb/iot.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" "time" - + "github.com/cnosdb/tsdb-comparisons/cmd/generate_queries/databases" "github.com/cnosdb/tsdb-comparisons/cmd/generate_queries/uses/iot" "github.com/cnosdb/tsdb-comparisons/pkg/query" @@ -31,7 +31,7 @@ func (i *IoT) getTrucksWhereWithNames(names []string) string { for _, s := range names { nameClauses = append(nameClauses, fmt.Sprintf("\"name\" = '%s'", s)) } - + combinedHostnameClause := strings.Join(nameClauses, " or ") return "(" + combinedHostnameClause + ")" } @@ -52,16 +52,16 @@ func (i *IoT) LastLocByTruck(qi query.Query, nTrucks int) { ORDER BY "time" LIMIT 1`, i.getTruckWhereString(nTrucks)) - + humanLabel := "cnosdb last location by specific truck" humanDesc := fmt.Sprintf("%s: random %4d trucks", humanLabel, nTrucks) - + i.fillInQuery(qi, humanLabel, humanDesc, cnosql) } // LastLocPerTruck finds all the truck locations along with truck and driver names. func (i *IoT) LastLocPerTruck(qi query.Query) { - + cnosql := fmt.Sprintf(`SELECT "latitude", "longitude" FROM "readings" WHERE "fleet"='%s' @@ -69,10 +69,10 @@ func (i *IoT) LastLocPerTruck(qi query.Query) { ORDER BY "time" LIMIT 1`, i.GetRandomFleet()) - + humanLabel := "cnosdb last location per truck" humanDesc := humanLabel - + i.fillInQuery(qi, humanLabel, humanDesc, cnosql) } @@ -85,10 +85,10 @@ func (i *IoT) TrucksWithLowFuel(qi query.Query) { ORDER BY "time" DESC LIMIT 1`, i.GetRandomFleet()) - + humanLabel := "cnosdb trucks with low fuel" humanDesc := fmt.Sprintf("%s: under 10 percent", humanLabel) - + i.fillInQuery(qi, humanLabel, humanDesc, cnosql) } @@ -104,10 +104,10 @@ func (i *IoT) TrucksWithHighLoad(qi query.Query) { GROUP BY "name" ORDER BY "time" DESC`, i.GetRandomFleet()) - + humanLabel := "cnosdb trucks with high load" humanDesc := fmt.Sprintf("%s: over 90 percent", humanLabel) - + i.fillInQuery(qi, humanLabel, humanDesc, cnosql) } @@ -125,10 +125,10 @@ func (i *IoT) StationaryTrucks(qi query.Query) { interval.Start().Format(time.RFC3339), interval.End().Format(time.RFC3339), i.GetRandomFleet()) - + humanLabel := "cnosdb stationary trucks" humanDesc := fmt.Sprintf("%s: with low avg velocity in last 10 minutes", humanLabel) - + i.fillInQuery(qi, humanLabel, humanDesc, cnosql) } @@ -149,10 +149,10 @@ func (i *IoT) TrucksWithLongDrivingSessions(qi query.Query) { interval.End().Format(time.RFC3339), // Calculate number of 10 min intervals that is the max driving duration for the session if we rest 5 mins per hour. tenMinutePeriods(5, iot.LongDrivingSessionDuration)) - + humanLabel := "cnosdb trucks with longer driving sessions" humanDesc := fmt.Sprintf("%s: stopped less than 20 mins in 4 hour period", humanLabel) - + i.fillInQuery(qi, humanLabel, humanDesc, cnosql) } @@ -173,10 +173,10 @@ func (i *IoT) TrucksWithLongDailySessions(qi query.Query) { interval.End().Format(time.RFC3339), // Calculate number of 10 min intervals that is the max driving duration for the session if we rest 35 mins per hour. tenMinutePeriods(35, iot.DailyDrivingDuration)) - + humanLabel := "cnosdb trucks with longer daily sessions" humanDesc := fmt.Sprintf("%s: drove more than 10 hours in the last 24 hours", humanLabel) - + i.fillInQuery(qi, humanLabel, humanDesc, cnosql) } @@ -186,10 +186,10 @@ func (i *IoT) AvgVsProjectedFuelConsumption(qi query.Query) { FROM "readings" WHERE "velocity" > 1 GROUP BY "fleet"` - + humanLabel := "cnosdb average vs projected fuel consumption per fleet" humanDesc := humanLabel - + i.fillInQuery(qi, humanLabel, humanDesc, cnosql) } @@ -209,10 +209,10 @@ func (i *IoT) AvgDailyDrivingDuration(qi query.Query) { start, end, ) - + humanLabel := "cnosdb average driver driving duration per day" humanDesc := humanLabel - + i.fillInQuery(qi, humanLabel, humanDesc, cnosql) } @@ -244,10 +244,10 @@ func (i *IoT) AvgDailyDrivingSession(qi query.Query) { start, end, ) - + humanLabel := "cnosdb average driver driving session without stopping per day" humanDesc := humanLabel - + i.fillInQuery(qi, humanLabel, humanDesc, cnosql) } @@ -258,10 +258,10 @@ func (i *IoT) AvgLoad(qi query.Query) { FROM "diagnostics" GROUP BY "name", "fleet", "model") GROUP BY "fleet", "model"` - + humanLabel := "cnosdb average load per truck model per fleet" humanDesc := humanLabel - + i.fillInQuery(qi, humanLabel, humanDesc, cnosql) } @@ -281,10 +281,10 @@ func (i *IoT) DailyTruckActivity(qi query.Query) { start, end, ) - + humanLabel := "cnosdb daily truck activity per fleet per model" humanDesc := humanLabel - + i.fillInQuery(qi, humanLabel, humanDesc, cnosql) } @@ -308,10 +308,10 @@ func (i *IoT) TruckBreakdownFrequency(qi query.Query) { start, end, ) - + humanLabel := "cnosdb truck breakdown frequency per model" humanDesc := humanLabel - + i.fillInQuery(qi, humanLabel, humanDesc, cnosql) } diff --git a/cmd/generate_queries/databases/cnosdb/iot_test.go b/cmd/generate_queries/databases/cnosdb/iot_test.go index 6f12f77..c88f168 100644 --- a/cmd/generate_queries/databases/cnosdb/iot_test.go +++ b/cmd/generate_queries/databases/cnosdb/iot_test.go @@ -6,7 +6,7 @@ import ( "net/url" "testing" "time" - + "github.com/cnosdb/tsdb-comparisons/pkg/query" ) @@ -41,7 +41,7 @@ func TestLastLocByTruck(t *testing.T) { { desc: "one truck", input: 1, - + expectedHumanLabel: "cnosdb last location by specific truck", expectedHumanDesc: "cnosdb last location by specific truck: random 1 trucks", expectedQuery: `SELECT "name", "driver", "latitude", "longitude" @@ -53,7 +53,7 @@ func TestLastLocByTruck(t *testing.T) { { desc: "three truck", input: 3, - + expectedHumanLabel: "cnosdb last location by specific truck", expectedHumanDesc: "cnosdb last location by specific truck: random 3 trucks", expectedQuery: `SELECT "name", "driver", "latitude", "longitude" @@ -63,13 +63,13 @@ func TestLastLocByTruck(t *testing.T) { LIMIT 1`, }, } - + testFunc := func(i *IoT, c IoTTestCase) query.Query { q := i.GenerateEmptyQuery() i.LastLocByTruck(q, c.input) return q } - + runIoTTestCases(t, testFunc, time.Now(), time.Now(), cases) } @@ -77,7 +77,7 @@ func TestLastLocPerTruck(t *testing.T) { cases := []IoTTestCase{ { desc: "default", - + expectedHumanLabel: "cnosdb last location per truck", expectedHumanDesc: "cnosdb last location per truck", expectedQuery: "/query?q=SELECT+%22latitude%22%2C+%22longitude%22+%0A%09%09" + @@ -85,7 +85,7 @@ func TestLastLocPerTruck(t *testing.T) { "GROUP+BY+%22name%22%2C%22driver%22+%0A%09%09ORDER+BY+%22time%22+%0A%09%09LIMIT+1", }, } - + for _, c := range cases { rand.Seed(123) b := BaseGenerator{} @@ -93,12 +93,12 @@ func TestLastLocPerTruck(t *testing.T) { if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() g.LastLocPerTruck(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedQuery) } } @@ -107,7 +107,7 @@ func TestTrucksWithLowFuel(t *testing.T) { cases := []IoTTestCase{ { desc: "default", - + expectedHumanLabel: "cnosdb trucks with low fuel", expectedHumanDesc: "cnosdb trucks with low fuel: under 10 percent", expectedQuery: "/query?q=SELECT+%22name%22%2C+%22driver%22%2C+%22fuel_state%22+%0A%09%09" + @@ -115,7 +115,7 @@ func TestTrucksWithLowFuel(t *testing.T) { "GROUP+BY+%22name%22+%0A%09%09ORDER+BY+%22time%22+DESC+%0A%09%09LIMIT+1", }, } - + for _, c := range cases { rand.Seed(123) b := BaseGenerator{} @@ -123,12 +123,12 @@ func TestTrucksWithLowFuel(t *testing.T) { if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() g.TrucksWithLowFuel(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedQuery) } } @@ -137,7 +137,7 @@ func TestTrucksWithHighLoad(t *testing.T) { cases := []IoTTestCase{ { desc: "default", - + expectedHumanLabel: "cnosdb trucks with high load", expectedHumanDesc: "cnosdb trucks with high load: over 90 percent", expectedQuery: "/query?q=SELECT+%22name%22%2C+%22driver%22%2C+%22current_load%22%2C+%22load_capacity%22+%0A%09%09" + @@ -147,7 +147,7 @@ func TestTrucksWithHighLoad(t *testing.T) { "GROUP+BY+%22name%22+%0A%09%09ORDER+BY+%22time%22+DESC", }, } - + for _, c := range cases { rand.Seed(123) b := BaseGenerator{} @@ -155,12 +155,12 @@ func TestTrucksWithHighLoad(t *testing.T) { if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() g.TrucksWithHighLoad(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedQuery) } } @@ -169,10 +169,10 @@ func TestStationaryTrucks(t *testing.T) { cases := []IoTTestCase{ { desc: "default", - + expectedHumanLabel: "cnosdb stationary trucks", expectedHumanDesc: "cnosdb stationary trucks: with low avg velocity in last 10 minutes", - + expectedQuery: "/query?q=SELECT+%22name%22%2C+%22driver%22+%0A%09%09FROM%28" + "SELECT+mean%28%22velocity%22%29+as+mean_velocity+%0A%09%09+FROM+%22readings%22+%0A%09%09+" + "WHERE+time+%3E+%271970-01-01T00%3A36%3A22Z%27+AND+time+%3C%3D+%271970-01-01T00%3A46%3A22Z%27+%0A%09%09+" + @@ -180,15 +180,15 @@ func TestStationaryTrucks(t *testing.T) { "LIMIT+1%29+%0A%09%09WHERE+%22fleet%22+%3D+%27West%27+AND+%22mean_velocity%22+%3C+1+%0A%09%09GROUP+BY+%22name%22", }, } - + for _, c := range cases { b := &BaseGenerator{} g := NewIoT(time.Unix(0, 0), time.Unix(0, 0).Add(time.Hour), 10, b) - + q := g.GenerateEmptyQuery() rand.Seed(123) g.StationaryTrucks(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedQuery) } } @@ -197,10 +197,10 @@ func TestTrucksWithLongDrivingSessions(t *testing.T) { cases := []IoTTestCase{ { desc: "default", - + expectedHumanLabel: "cnosdb trucks with longer driving sessions", expectedHumanDesc: "cnosdb trucks with longer driving sessions: stopped less than 20 mins in 4 hour period", - + expectedQuery: "/query?q=SELECT+%22name%22%2C%22driver%22+%0A%09%09FROM%28" + "SELECT+count%28%2A%29+AS+ten_min+%0A%09%09+FROM%28SELECT+mean%28%22velocity%22%29+AS+mean_velocity+%0A%09%09++" + "FROM+readings+%0A%09%09++" + @@ -210,20 +210,20 @@ func TestTrucksWithLongDrivingSessions(t *testing.T) { "WHERE+ten_min_mean_velocity+%3E+22", }, } - + for _, c := range cases { b := BaseGenerator{} ig, err := b.NewIoT(time.Unix(0, 0), time.Unix(0, 0).Add(6*time.Hour), 10) if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() rand.Seed(123) g.TrucksWithLongDrivingSessions(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedQuery) } } @@ -232,10 +232,10 @@ func TestTrucksWithLongDailySessions(t *testing.T) { cases := []IoTTestCase{ { desc: "default", - + expectedHumanLabel: "cnosdb trucks with longer daily sessions", expectedHumanDesc: "cnosdb trucks with longer daily sessions: drove more than 10 hours in the last 24 hours", - + expectedQuery: "/query?q=SELECT+%22name%22%2C%22driver%22+%0A%09%09" + "FROM%28SELECT+count%28%2A%29+AS+ten_min+%0A%09%09+FROM%28" + "SELECT+mean%28%22velocity%22%29+AS+mean_velocity+%0A%09%09++FROM+readings+%0A%09%09++" + @@ -245,20 +245,20 @@ func TestTrucksWithLongDailySessions(t *testing.T) { "GROUP+BY+%22name%22%2C%22driver%22%29+%0A%09%09WHERE+ten_min_mean_velocity+%3E+60", }, } - + for _, c := range cases { b := BaseGenerator{} ig, err := b.NewIoT(time.Unix(0, 0), time.Unix(0, 0).Add(25*time.Hour), 10) if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() rand.Seed(123) g.TrucksWithLongDailySessions(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedQuery) } } @@ -267,28 +267,28 @@ func TestAvgVsProjectedFuelConsumption(t *testing.T) { cases := []IoTTestCase{ { desc: "default", - + expectedHumanLabel: "cnosdb average vs projected fuel consumption per fleet", expectedHumanDesc: "cnosdb average vs projected fuel consumption per fleet", - + expectedQuery: "/query?q=SELECT+mean%28%22fuel_consumption%22%29+AS+%22mean_fuel_consumption%22%2C+mean%28%22nominal_fuel_consumption%22%29+AS+%22nominal_fuel_consumption%22+%0A%09%09" + "FROM+%22readings%22+%0A%09%09WHERE+%22velocity%22+%3E+1+%0A%09%09GROUP+BY+%22fleet%22", }, } - + for _, c := range cases { b := BaseGenerator{} ig, err := b.NewIoT(time.Unix(0, 0), time.Unix(0, 0).Add(25*time.Hour), 10) if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() rand.Seed(123) g.AvgVsProjectedFuelConsumption(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedQuery) } } @@ -297,10 +297,10 @@ func TestAvgDailyDrivingDuration(t *testing.T) { cases := []IoTTestCase{ { desc: "default", - + expectedHumanLabel: "cnosdb average driver driving duration per day", expectedHumanDesc: "cnosdb average driver driving duration per day", - + expectedQuery: "/query?q=SELECT+count%28%22mv%22%29%2F6+as+%22hours+driven%22+%0A%09%09" + "FROM+%28SELECT+mean%28%22velocity%22%29+as+%22mv%22+%0A%09%09+" + "FROM+%22readings%22+%0A%09%09+WHERE+time+%3E+%271970-01-01T00%3A00%3A00Z%27+AND+time+%3C+%271970-01-02T01%3A00%3A00Z%27+%0A%09%09+" + @@ -309,20 +309,20 @@ func TestAvgDailyDrivingDuration(t *testing.T) { "GROUP+BY+time%281d%29%2C%22fleet%22%2C+%22name%22%2C+%22driver%22", }, } - + for _, c := range cases { b := BaseGenerator{} ig, err := b.NewIoT(time.Unix(0, 0), time.Unix(0, 0).Add(25*time.Hour), 10) if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() rand.Seed(123) g.AvgDailyDrivingDuration(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedQuery) } } @@ -331,10 +331,10 @@ func TestAvgDailyDrivingSession(t *testing.T) { cases := []IoTTestCase{ { desc: "default", - + expectedHumanLabel: "cnosdb average driver driving session without stopping per day", expectedHumanDesc: "cnosdb average driver driving session without stopping per day", - + expectedQuery: "/query?q=SELECT+%22elapsed%22+%0A%09%09INTO+%22random_measure2_1%22+%0A%09%09FROM+%28" + "SELECT+difference%28%22difka%22%29%2C+elapsed%28%22difka%22%2C+1m%29+%0A%09%09+" + "FROM+%28SELECT+%22difka%22+%0A%09%09++FROM+%28SELECT+difference%28%22mv%22%29+AS+difka+%0A%09%09+++" + @@ -350,20 +350,20 @@ func TestAvgDailyDrivingSession(t *testing.T) { "GROUP+BY+time%281d%29%2C%22name%22", }, } - + for _, c := range cases { b := BaseGenerator{} ig, err := b.NewIoT(time.Unix(0, 0), time.Unix(0, 0).Add(25*time.Hour), 10) if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() rand.Seed(123) g.AvgDailyDrivingSession(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedQuery) } } @@ -372,30 +372,30 @@ func TestAvgLoad(t *testing.T) { cases := []IoTTestCase{ { desc: "default", - + expectedHumanLabel: "cnosdb average load per truck model per fleet", expectedHumanDesc: "cnosdb average load per truck model per fleet", - + expectedQuery: "/query?q=SELECT+mean%28%22ml%22%29+AS+mean_load_percentage+%0A%09%09" + "FROM+%28SELECT+%22current_load%22%2F%22load_capacity%22+AS+%22ml%22+%0A%09%09+" + "FROM+%22diagnostics%22+%0A%09%09+GROUP+BY+%22name%22%2C+%22fleet%22%2C+%22model%22%29+%0A%09%09" + "GROUP+BY+%22fleet%22%2C+%22model%22", }, } - + for _, c := range cases { b := BaseGenerator{} ig, err := b.NewIoT(time.Unix(0, 0), time.Unix(0, 0).Add(25*time.Hour), 10) if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() rand.Seed(123) g.AvgLoad(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedQuery) } } @@ -404,10 +404,10 @@ func TestDailyTruckActivity(t *testing.T) { cases := []IoTTestCase{ { desc: "default", - + expectedHumanLabel: "cnosdb daily truck activity per fleet per model", expectedHumanDesc: "cnosdb daily truck activity per fleet per model", - + expectedQuery: "/query?q=SELECT+count%28%22ms%22%29%2F144+%0A%09%09FROM+%28" + "SELECT+mean%28%22status%22%29+AS+ms+%0A%09%09+FROM+%22diagnostics%22+%0A%09%09+" + "WHERE+time+%3E%3D+%271970-01-01T00%3A00%3A00Z%27+AND+time+%3C+%271970-01-02T01%3A00%3A00Z%27+%0A%09%09+" + @@ -416,20 +416,20 @@ func TestDailyTruckActivity(t *testing.T) { "GROUP+BY+time%281d%29%2C+%22model%22%2C+%22fleet%22", }, } - + for _, c := range cases { b := BaseGenerator{} ig, err := b.NewIoT(time.Unix(0, 0), time.Unix(0, 0).Add(25*time.Hour), 10) if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() rand.Seed(123) g.DailyTruckActivity(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedQuery) } } @@ -438,10 +438,10 @@ func TestTruckBreakdownFrequency(t *testing.T) { cases := []IoTTestCase{ { desc: "default", - + expectedHumanLabel: "cnosdb truck breakdown frequency per model", expectedHumanDesc: "cnosdb truck breakdown frequency per model", - + expectedQuery: "/query?q=SELECT+count%28%22state_changed%22%29+%0A%09%09" + "FROM+%28SELECT+difference%28%22broken_down%22%29+AS+%22state_changed%22+%0A%09%09+" + "FROM+%28SELECT+floor%282%2A%28sum%28%22nzs%22%29%2Fcount%28%22nzs%22%29%29%29%2Ffloor%282%2A%28sum%28%22nzs%22%29%2Fcount%28%22nzs%22%29%29%29+AS+%22broken_down%22+%0A%09%09++" + @@ -453,20 +453,20 @@ func TestTruckBreakdownFrequency(t *testing.T) { "WHERE+%22state_changed%22+%3D+1+%0A%09%09GROUP+BY+%22model%22", }, } - + for _, c := range cases { b := BaseGenerator{} ig, err := b.NewIoT(time.Unix(0, 0), time.Unix(0, 0).Add(25*time.Hour), 10) if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() rand.Seed(123) g.TruckBreakdownFrequency(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedQuery) } } @@ -508,18 +508,18 @@ func TestTenMinutePeriods(t *testing.T) { result: 2, }, } - + for _, c := range cases { if got := tenMinutePeriods(c.minutesPerHour, c.duration); got != c.result { t.Errorf("incorrect result for %.2f minutes per hour, duration %s: got %d want %d", c.minutesPerHour, c.duration.String(), got, c.result) } } - + } func runIoTTestCases(t *testing.T, testFunc func(*IoT, IoTTestCase) query.Query, s time.Time, e time.Time, cases []IoTTestCase) { rand.Seed(123) // Setting seed for testing purposes. - + for _, c := range cases { t.Run(c.desc, func(t *testing.T) { b := BaseGenerator{} @@ -528,7 +528,7 @@ func runIoTTestCases(t *testing.T, testFunc func(*IoT, IoTTestCase) query.Query, t.Fatalf("Error while creating devops generator") } i := dq.(*IoT) - + if c.fail { func() { defer func() { @@ -536,21 +536,21 @@ func runIoTTestCases(t *testing.T, testFunc func(*IoT, IoTTestCase) query.Query, if r == nil { t.Fatalf("did not panic when should") } - + if r != c.failMsg { t.Fatalf("incorrect fail message: got %s, want %s", r, c.failMsg) } }() - + testFunc(i, c) }() } else { q := testFunc(i, c) - + v := url.Values{} v.Set("q", c.expectedQuery) expectedPath := fmt.Sprintf("/query?%s", v.Encode()) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, expectedPath) } }) @@ -558,27 +558,27 @@ func runIoTTestCases(t *testing.T, testFunc func(*IoT, IoTTestCase) query.Query, } func verifyQuery(t *testing.T, q query.Query, humanLabel, humanDesc, path string) { cnosql, ok := q.(*query.HTTP) - + if !ok { t.Fatal("Filled query is not *query.HTTP type") } - + if got := string(cnosql.HumanLabel); got != humanLabel { t.Errorf("incorrect human label:\ngot\n%s\nwant\n%s", got, humanLabel) } - + if got := string(cnosql.HumanDescription); got != humanDesc { t.Errorf("incorrect human description:\ngot\n%s\nwant\n%s", got, humanDesc) } - + if got := string(cnosql.Method); got != "POST" { t.Errorf("incorrect method:\ngot\n%s\nwant POST", got) } - + if got := string(cnosql.Path); got != path { t.Errorf("incorrect path:\ngot\n%s\nwant\n%s", got, path) } - + if cnosql.Body != nil { t.Errorf("body not nil, got %+v", cnosql.Body) } diff --git a/cmd/generate_queries/databases/influx/common.go b/cmd/generate_queries/databases/influx/common.go index f9bddfd..803477a 100644 --- a/cmd/generate_queries/databases/influx/common.go +++ b/cmd/generate_queries/databases/influx/common.go @@ -4,7 +4,7 @@ import ( "fmt" "net/url" "time" - + "github.com/cnosdb/tsdb-comparisons/cmd/generate_queries/uses/iot" "github.com/cnosdb/tsdb-comparisons/cmd/generate_queries/utils" "github.com/cnosdb/tsdb-comparisons/pkg/query" @@ -35,15 +35,15 @@ func (g *BaseGenerator) fillInQuery(qi query.Query, humanLabel, humanDesc, influ // NewIoT creates a new iot use case query generator. func (g *BaseGenerator) NewIoT(start, end time.Time, scale int) (utils.QueryGenerator, error) { core, err := iot.NewCore(start, end, scale) - + if err != nil { return nil, err } - + devops := &IoT{ BaseGenerator: g, Core: core, } - + return devops, nil } diff --git a/cmd/generate_queries/databases/influx/iot.go b/cmd/generate_queries/databases/influx/iot.go index 9aea252..3e51388 100644 --- a/cmd/generate_queries/databases/influx/iot.go +++ b/cmd/generate_queries/databases/influx/iot.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" "time" - + "github.com/cnosdb/tsdb-comparisons/cmd/generate_queries/databases" "github.com/cnosdb/tsdb-comparisons/cmd/generate_queries/uses/iot" "github.com/cnosdb/tsdb-comparisons/pkg/query" @@ -31,7 +31,7 @@ func (i *IoT) getTrucksWhereWithNames(names []string) string { for _, s := range names { nameClauses = append(nameClauses, fmt.Sprintf("\"name\" = '%s'", s)) } - + combinedHostnameClause := strings.Join(nameClauses, " or ") return "(" + combinedHostnameClause + ")" } @@ -52,16 +52,16 @@ func (i *IoT) LastLocByTruck(qi query.Query, nTrucks int) { ORDER BY "time" LIMIT 1`, i.getTruckWhereString(nTrucks)) - + humanLabel := "Influx last location by specific truck" humanDesc := fmt.Sprintf("%s: random %4d trucks", humanLabel, nTrucks) - + i.fillInQuery(qi, humanLabel, humanDesc, influxql) } // LastLocPerTruck finds all the truck locations along with truck and driver names. func (i *IoT) LastLocPerTruck(qi query.Query) { - + influxql := fmt.Sprintf(`SELECT "latitude", "longitude" FROM "readings" WHERE "fleet"='%s' @@ -69,10 +69,10 @@ func (i *IoT) LastLocPerTruck(qi query.Query) { ORDER BY "time" LIMIT 1`, i.GetRandomFleet()) - + humanLabel := "Influx last location per truck" humanDesc := humanLabel - + i.fillInQuery(qi, humanLabel, humanDesc, influxql) } @@ -85,10 +85,10 @@ func (i *IoT) TrucksWithLowFuel(qi query.Query) { ORDER BY "time" DESC LIMIT 1`, i.GetRandomFleet()) - + humanLabel := "Influx trucks with low fuel" humanDesc := fmt.Sprintf("%s: under 10 percent", humanLabel) - + i.fillInQuery(qi, humanLabel, humanDesc, influxql) } @@ -104,10 +104,10 @@ func (i *IoT) TrucksWithHighLoad(qi query.Query) { GROUP BY "name" ORDER BY "time" DESC`, i.GetRandomFleet()) - + humanLabel := "Influx trucks with high load" humanDesc := fmt.Sprintf("%s: over 90 percent", humanLabel) - + i.fillInQuery(qi, humanLabel, humanDesc, influxql) } @@ -125,10 +125,10 @@ func (i *IoT) StationaryTrucks(qi query.Query) { interval.Start().Format(time.RFC3339), interval.End().Format(time.RFC3339), i.GetRandomFleet()) - + humanLabel := "Influx stationary trucks" humanDesc := fmt.Sprintf("%s: with low avg velocity in last 10 minutes", humanLabel) - + i.fillInQuery(qi, humanLabel, humanDesc, influxql) } @@ -149,10 +149,10 @@ func (i *IoT) TrucksWithLongDrivingSessions(qi query.Query) { interval.End().Format(time.RFC3339), // Calculate number of 10 min intervals that is the max driving duration for the session if we rest 5 mins per hour. tenMinutePeriods(5, iot.LongDrivingSessionDuration)) - + humanLabel := "Influx trucks with longer driving sessions" humanDesc := fmt.Sprintf("%s: stopped less than 20 mins in 4 hour period", humanLabel) - + i.fillInQuery(qi, humanLabel, humanDesc, influxql) } @@ -173,10 +173,10 @@ func (i *IoT) TrucksWithLongDailySessions(qi query.Query) { interval.End().Format(time.RFC3339), // Calculate number of 10 min intervals that is the max driving duration for the session if we rest 35 mins per hour. tenMinutePeriods(35, iot.DailyDrivingDuration)) - + humanLabel := "Influx trucks with longer daily sessions" humanDesc := fmt.Sprintf("%s: drove more than 10 hours in the last 24 hours", humanLabel) - + i.fillInQuery(qi, humanLabel, humanDesc, influxql) } @@ -186,10 +186,10 @@ func (i *IoT) AvgVsProjectedFuelConsumption(qi query.Query) { FROM "readings" WHERE "velocity" > 1 GROUP BY "fleet"` - + humanLabel := "Influx average vs projected fuel consumption per fleet" humanDesc := humanLabel - + i.fillInQuery(qi, humanLabel, humanDesc, influxql) } @@ -209,10 +209,10 @@ func (i *IoT) AvgDailyDrivingDuration(qi query.Query) { start, end, ) - + humanLabel := "Influx average driver driving duration per day" humanDesc := humanLabel - + i.fillInQuery(qi, humanLabel, humanDesc, influxql) } @@ -244,10 +244,10 @@ func (i *IoT) AvgDailyDrivingSession(qi query.Query) { start, end, ) - + humanLabel := "Influx average driver driving session without stopping per day" humanDesc := humanLabel - + i.fillInQuery(qi, humanLabel, humanDesc, influxql) } @@ -258,10 +258,10 @@ func (i *IoT) AvgLoad(qi query.Query) { FROM "diagnostics" GROUP BY "name", "fleet", "model") GROUP BY "fleet", "model"` - + humanLabel := "Influx average load per truck model per fleet" humanDesc := humanLabel - + i.fillInQuery(qi, humanLabel, humanDesc, influxql) } @@ -281,10 +281,10 @@ func (i *IoT) DailyTruckActivity(qi query.Query) { start, end, ) - + humanLabel := "Influx daily truck activity per fleet per model" humanDesc := humanLabel - + i.fillInQuery(qi, humanLabel, humanDesc, influxql) } @@ -308,10 +308,10 @@ func (i *IoT) TruckBreakdownFrequency(qi query.Query) { start, end, ) - + humanLabel := "Influx truck breakdown frequency per model" humanDesc := humanLabel - + i.fillInQuery(qi, humanLabel, humanDesc, influxql) } diff --git a/cmd/generate_queries/databases/influx/iot_test.go b/cmd/generate_queries/databases/influx/iot_test.go index 9023ac6..9f3fe95 100644 --- a/cmd/generate_queries/databases/influx/iot_test.go +++ b/cmd/generate_queries/databases/influx/iot_test.go @@ -6,7 +6,7 @@ import ( "net/url" "testing" "time" - + "github.com/cnosdb/tsdb-comparisons/pkg/query" ) @@ -41,7 +41,7 @@ func TestLastLocByTruck(t *testing.T) { { desc: "one truck", input: 1, - + expectedHumanLabel: "Influx last location by specific truck", expectedHumanDesc: "Influx last location by specific truck: random 1 trucks", expectedQuery: `SELECT "name", "driver", "latitude", "longitude" @@ -53,7 +53,7 @@ func TestLastLocByTruck(t *testing.T) { { desc: "three truck", input: 3, - + expectedHumanLabel: "Influx last location by specific truck", expectedHumanDesc: "Influx last location by specific truck: random 3 trucks", expectedQuery: `SELECT "name", "driver", "latitude", "longitude" @@ -63,13 +63,13 @@ func TestLastLocByTruck(t *testing.T) { LIMIT 1`, }, } - + testFunc := func(i *IoT, c IoTTestCase) query.Query { q := i.GenerateEmptyQuery() i.LastLocByTruck(q, c.input) return q } - + runIoTTestCases(t, testFunc, time.Now(), time.Now(), cases) } @@ -77,7 +77,7 @@ func TestLastLocPerTruck(t *testing.T) { cases := []IoTTestCase{ { desc: "default", - + expectedHumanLabel: "Influx last location per truck", expectedHumanDesc: "Influx last location per truck", expectedQuery: "/query?q=SELECT+%22latitude%22%2C+%22longitude%22+%0A%09%09" + @@ -85,7 +85,7 @@ func TestLastLocPerTruck(t *testing.T) { "GROUP+BY+%22name%22%2C%22driver%22+%0A%09%09ORDER+BY+%22time%22+%0A%09%09LIMIT+1", }, } - + for _, c := range cases { rand.Seed(123) b := BaseGenerator{} @@ -93,12 +93,12 @@ func TestLastLocPerTruck(t *testing.T) { if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() g.LastLocPerTruck(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedQuery) } } @@ -107,7 +107,7 @@ func TestTrucksWithLowFuel(t *testing.T) { cases := []IoTTestCase{ { desc: "default", - + expectedHumanLabel: "Influx trucks with low fuel", expectedHumanDesc: "Influx trucks with low fuel: under 10 percent", expectedQuery: "/query?q=SELECT+%22name%22%2C+%22driver%22%2C+%22fuel_state%22+%0A%09%09" + @@ -115,7 +115,7 @@ func TestTrucksWithLowFuel(t *testing.T) { "GROUP+BY+%22name%22+%0A%09%09ORDER+BY+%22time%22+DESC+%0A%09%09LIMIT+1", }, } - + for _, c := range cases { rand.Seed(123) b := BaseGenerator{} @@ -123,12 +123,12 @@ func TestTrucksWithLowFuel(t *testing.T) { if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() g.TrucksWithLowFuel(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedQuery) } } @@ -137,7 +137,7 @@ func TestTrucksWithHighLoad(t *testing.T) { cases := []IoTTestCase{ { desc: "default", - + expectedHumanLabel: "Influx trucks with high load", expectedHumanDesc: "Influx trucks with high load: over 90 percent", expectedQuery: "/query?q=SELECT+%22name%22%2C+%22driver%22%2C+%22current_load%22%2C+%22load_capacity%22+%0A%09%09" + @@ -147,7 +147,7 @@ func TestTrucksWithHighLoad(t *testing.T) { "GROUP+BY+%22name%22+%0A%09%09ORDER+BY+%22time%22+DESC", }, } - + for _, c := range cases { rand.Seed(123) b := BaseGenerator{} @@ -155,12 +155,12 @@ func TestTrucksWithHighLoad(t *testing.T) { if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() g.TrucksWithHighLoad(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedQuery) } } @@ -169,10 +169,10 @@ func TestStationaryTrucks(t *testing.T) { cases := []IoTTestCase{ { desc: "default", - + expectedHumanLabel: "Influx stationary trucks", expectedHumanDesc: "Influx stationary trucks: with low avg velocity in last 10 minutes", - + expectedQuery: "/query?q=SELECT+%22name%22%2C+%22driver%22+%0A%09%09FROM%28" + "SELECT+mean%28%22velocity%22%29+as+mean_velocity+%0A%09%09+FROM+%22readings%22+%0A%09%09+" + "WHERE+time+%3E+%271970-01-01T00%3A36%3A22Z%27+AND+time+%3C%3D+%271970-01-01T00%3A46%3A22Z%27+%0A%09%09+" + @@ -180,15 +180,15 @@ func TestStationaryTrucks(t *testing.T) { "LIMIT+1%29+%0A%09%09WHERE+%22fleet%22+%3D+%27West%27+AND+%22mean_velocity%22+%3C+1+%0A%09%09GROUP+BY+%22name%22", }, } - + for _, c := range cases { b := &BaseGenerator{} g := NewIoT(time.Unix(0, 0), time.Unix(0, 0).Add(time.Hour), 10, b) - + q := g.GenerateEmptyQuery() rand.Seed(123) g.StationaryTrucks(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedQuery) } } @@ -197,10 +197,10 @@ func TestTrucksWithLongDrivingSessions(t *testing.T) { cases := []IoTTestCase{ { desc: "default", - + expectedHumanLabel: "Influx trucks with longer driving sessions", expectedHumanDesc: "Influx trucks with longer driving sessions: stopped less than 20 mins in 4 hour period", - + expectedQuery: "/query?q=SELECT+%22name%22%2C%22driver%22+%0A%09%09FROM%28" + "SELECT+count%28%2A%29+AS+ten_min+%0A%09%09+FROM%28SELECT+mean%28%22velocity%22%29+AS+mean_velocity+%0A%09%09++" + "FROM+readings+%0A%09%09++" + @@ -210,20 +210,20 @@ func TestTrucksWithLongDrivingSessions(t *testing.T) { "WHERE+ten_min_mean_velocity+%3E+22", }, } - + for _, c := range cases { b := BaseGenerator{} ig, err := b.NewIoT(time.Unix(0, 0), time.Unix(0, 0).Add(6*time.Hour), 10) if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() rand.Seed(123) g.TrucksWithLongDrivingSessions(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedQuery) } } @@ -232,10 +232,10 @@ func TestTrucksWithLongDailySessions(t *testing.T) { cases := []IoTTestCase{ { desc: "default", - + expectedHumanLabel: "Influx trucks with longer daily sessions", expectedHumanDesc: "Influx trucks with longer daily sessions: drove more than 10 hours in the last 24 hours", - + expectedQuery: "/query?q=SELECT+%22name%22%2C%22driver%22+%0A%09%09" + "FROM%28SELECT+count%28%2A%29+AS+ten_min+%0A%09%09+FROM%28" + "SELECT+mean%28%22velocity%22%29+AS+mean_velocity+%0A%09%09++FROM+readings+%0A%09%09++" + @@ -245,20 +245,20 @@ func TestTrucksWithLongDailySessions(t *testing.T) { "GROUP+BY+%22name%22%2C%22driver%22%29+%0A%09%09WHERE+ten_min_mean_velocity+%3E+60", }, } - + for _, c := range cases { b := BaseGenerator{} ig, err := b.NewIoT(time.Unix(0, 0), time.Unix(0, 0).Add(25*time.Hour), 10) if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() rand.Seed(123) g.TrucksWithLongDailySessions(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedQuery) } } @@ -267,28 +267,28 @@ func TestAvgVsProjectedFuelConsumption(t *testing.T) { cases := []IoTTestCase{ { desc: "default", - + expectedHumanLabel: "Influx average vs projected fuel consumption per fleet", expectedHumanDesc: "Influx average vs projected fuel consumption per fleet", - + expectedQuery: "/query?q=SELECT+mean%28%22fuel_consumption%22%29+AS+%22mean_fuel_consumption%22%2C+mean%28%22nominal_fuel_consumption%22%29+AS+%22nominal_fuel_consumption%22+%0A%09%09" + "FROM+%22readings%22+%0A%09%09WHERE+%22velocity%22+%3E+1+%0A%09%09GROUP+BY+%22fleet%22", }, } - + for _, c := range cases { b := BaseGenerator{} ig, err := b.NewIoT(time.Unix(0, 0), time.Unix(0, 0).Add(25*time.Hour), 10) if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() rand.Seed(123) g.AvgVsProjectedFuelConsumption(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedQuery) } } @@ -297,10 +297,10 @@ func TestAvgDailyDrivingDuration(t *testing.T) { cases := []IoTTestCase{ { desc: "default", - + expectedHumanLabel: "Influx average driver driving duration per day", expectedHumanDesc: "Influx average driver driving duration per day", - + expectedQuery: "/query?q=SELECT+count%28%22mv%22%29%2F6+as+%22hours+driven%22+%0A%09%09" + "FROM+%28SELECT+mean%28%22velocity%22%29+as+%22mv%22+%0A%09%09+" + "FROM+%22readings%22+%0A%09%09+WHERE+time+%3E+%271970-01-01T00%3A00%3A00Z%27+AND+time+%3C+%271970-01-02T01%3A00%3A00Z%27+%0A%09%09+" + @@ -309,20 +309,20 @@ func TestAvgDailyDrivingDuration(t *testing.T) { "GROUP+BY+time%281d%29%2C%22fleet%22%2C+%22name%22%2C+%22driver%22", }, } - + for _, c := range cases { b := BaseGenerator{} ig, err := b.NewIoT(time.Unix(0, 0), time.Unix(0, 0).Add(25*time.Hour), 10) if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() rand.Seed(123) g.AvgDailyDrivingDuration(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedQuery) } } @@ -331,10 +331,10 @@ func TestAvgDailyDrivingSession(t *testing.T) { cases := []IoTTestCase{ { desc: "default", - + expectedHumanLabel: "Influx average driver driving session without stopping per day", expectedHumanDesc: "Influx average driver driving session without stopping per day", - + expectedQuery: "/query?q=SELECT+%22elapsed%22+%0A%09%09INTO+%22random_measure2_1%22+%0A%09%09FROM+%28" + "SELECT+difference%28%22difka%22%29%2C+elapsed%28%22difka%22%2C+1m%29+%0A%09%09+" + "FROM+%28SELECT+%22difka%22+%0A%09%09++FROM+%28SELECT+difference%28%22mv%22%29+AS+difka+%0A%09%09+++" + @@ -350,20 +350,20 @@ func TestAvgDailyDrivingSession(t *testing.T) { "GROUP+BY+time%281d%29%2C%22name%22", }, } - + for _, c := range cases { b := BaseGenerator{} ig, err := b.NewIoT(time.Unix(0, 0), time.Unix(0, 0).Add(25*time.Hour), 10) if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() rand.Seed(123) g.AvgDailyDrivingSession(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedQuery) } } @@ -372,30 +372,30 @@ func TestAvgLoad(t *testing.T) { cases := []IoTTestCase{ { desc: "default", - + expectedHumanLabel: "Influx average load per truck model per fleet", expectedHumanDesc: "Influx average load per truck model per fleet", - + expectedQuery: "/query?q=SELECT+mean%28%22ml%22%29+AS+mean_load_percentage+%0A%09%09" + "FROM+%28SELECT+%22current_load%22%2F%22load_capacity%22+AS+%22ml%22+%0A%09%09+" + "FROM+%22diagnostics%22+%0A%09%09+GROUP+BY+%22name%22%2C+%22fleet%22%2C+%22model%22%29+%0A%09%09" + "GROUP+BY+%22fleet%22%2C+%22model%22", }, } - + for _, c := range cases { b := BaseGenerator{} ig, err := b.NewIoT(time.Unix(0, 0), time.Unix(0, 0).Add(25*time.Hour), 10) if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() rand.Seed(123) g.AvgLoad(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedQuery) } } @@ -404,10 +404,10 @@ func TestDailyTruckActivity(t *testing.T) { cases := []IoTTestCase{ { desc: "default", - + expectedHumanLabel: "Influx daily truck activity per fleet per model", expectedHumanDesc: "Influx daily truck activity per fleet per model", - + expectedQuery: "/query?q=SELECT+count%28%22ms%22%29%2F144+%0A%09%09FROM+%28" + "SELECT+mean%28%22status%22%29+AS+ms+%0A%09%09+FROM+%22diagnostics%22+%0A%09%09+" + "WHERE+time+%3E%3D+%271970-01-01T00%3A00%3A00Z%27+AND+time+%3C+%271970-01-02T01%3A00%3A00Z%27+%0A%09%09+" + @@ -416,20 +416,20 @@ func TestDailyTruckActivity(t *testing.T) { "GROUP+BY+time%281d%29%2C+%22model%22%2C+%22fleet%22", }, } - + for _, c := range cases { b := BaseGenerator{} ig, err := b.NewIoT(time.Unix(0, 0), time.Unix(0, 0).Add(25*time.Hour), 10) if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() rand.Seed(123) g.DailyTruckActivity(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedQuery) } } @@ -438,10 +438,10 @@ func TestTruckBreakdownFrequency(t *testing.T) { cases := []IoTTestCase{ { desc: "default", - + expectedHumanLabel: "Influx truck breakdown frequency per model", expectedHumanDesc: "Influx truck breakdown frequency per model", - + expectedQuery: "/query?q=SELECT+count%28%22state_changed%22%29+%0A%09%09" + "FROM+%28SELECT+difference%28%22broken_down%22%29+AS+%22state_changed%22+%0A%09%09+" + "FROM+%28SELECT+floor%282%2A%28sum%28%22nzs%22%29%2Fcount%28%22nzs%22%29%29%29%2Ffloor%282%2A%28sum%28%22nzs%22%29%2Fcount%28%22nzs%22%29%29%29+AS+%22broken_down%22+%0A%09%09++" + @@ -453,20 +453,20 @@ func TestTruckBreakdownFrequency(t *testing.T) { "WHERE+%22state_changed%22+%3D+1+%0A%09%09GROUP+BY+%22model%22", }, } - + for _, c := range cases { b := BaseGenerator{} ig, err := b.NewIoT(time.Unix(0, 0), time.Unix(0, 0).Add(25*time.Hour), 10) if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() rand.Seed(123) g.TruckBreakdownFrequency(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedQuery) } } @@ -508,18 +508,18 @@ func TestTenMinutePeriods(t *testing.T) { result: 2, }, } - + for _, c := range cases { if got := tenMinutePeriods(c.minutesPerHour, c.duration); got != c.result { t.Errorf("incorrect result for %.2f minutes per hour, duration %s: got %d want %d", c.minutesPerHour, c.duration.String(), got, c.result) } } - + } func runIoTTestCases(t *testing.T, testFunc func(*IoT, IoTTestCase) query.Query, s time.Time, e time.Time, cases []IoTTestCase) { rand.Seed(123) // Setting seed for testing purposes. - + for _, c := range cases { t.Run(c.desc, func(t *testing.T) { b := BaseGenerator{} @@ -528,7 +528,7 @@ func runIoTTestCases(t *testing.T, testFunc func(*IoT, IoTTestCase) query.Query, t.Fatalf("Error while creating devops generator") } i := dq.(*IoT) - + if c.fail { func() { defer func() { @@ -536,21 +536,21 @@ func runIoTTestCases(t *testing.T, testFunc func(*IoT, IoTTestCase) query.Query, if r == nil { t.Fatalf("did not panic when should") } - + if r != c.failMsg { t.Fatalf("incorrect fail message: got %s, want %s", r, c.failMsg) } }() - + testFunc(i, c) }() } else { q := testFunc(i, c) - + v := url.Values{} v.Set("q", c.expectedQuery) expectedPath := fmt.Sprintf("/query?%s", v.Encode()) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, expectedPath) } }) @@ -558,27 +558,27 @@ func runIoTTestCases(t *testing.T, testFunc func(*IoT, IoTTestCase) query.Query, } func verifyQuery(t *testing.T, q query.Query, humanLabel, humanDesc, path string) { influxql, ok := q.(*query.HTTP) - + if !ok { t.Fatal("Filled query is not *query.HTTP type") } - + if got := string(influxql.HumanLabel); got != humanLabel { t.Errorf("incorrect human label:\ngot\n%s\nwant\n%s", got, humanLabel) } - + if got := string(influxql.HumanDescription); got != humanDesc { t.Errorf("incorrect human description:\ngot\n%s\nwant\n%s", got, humanDesc) } - + if got := string(influxql.Method); got != "POST" { t.Errorf("incorrect method:\ngot\n%s\nwant POST", got) } - + if got := string(influxql.Path); got != path { t.Errorf("incorrect path:\ngot\n%s\nwant\n%s", got, path) } - + if influxql.Body != nil { t.Errorf("body not nil, got %+v", influxql.Body) } diff --git a/cmd/generate_queries/databases/timescaledb/common.go b/cmd/generate_queries/databases/timescaledb/common.go index a2bd023..e117ff0 100644 --- a/cmd/generate_queries/databases/timescaledb/common.go +++ b/cmd/generate_queries/databases/timescaledb/common.go @@ -2,7 +2,7 @@ package timescaledb import ( "time" - + "github.com/cnosdb/tsdb-comparisons/cmd/generate_queries/uses/iot" "github.com/cnosdb/tsdb-comparisons/cmd/generate_queries/utils" "github.com/cnosdb/tsdb-comparisons/pkg/query" @@ -34,15 +34,15 @@ func (g *BaseGenerator) fillInQuery(qi query.Query, humanLabel, humanDesc, table // NewIoT creates a new iot use case query generator. func (g *BaseGenerator) NewIoT(start, end time.Time, scale int) (utils.QueryGenerator, error) { core, err := iot.NewCore(start, end, scale) - + if err != nil { return nil, err } - + iot := &IoT{ BaseGenerator: g, Core: core, } - + return iot, nil } diff --git a/cmd/generate_queries/databases/timescaledb/iot.go b/cmd/generate_queries/databases/timescaledb/iot.go index 669d3ad..6e8e961 100644 --- a/cmd/generate_queries/databases/timescaledb/iot.go +++ b/cmd/generate_queries/databases/timescaledb/iot.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" "time" - + "github.com/cnosdb/tsdb-comparisons/cmd/generate_queries/uses/iot" "github.com/cnosdb/tsdb-comparisons/pkg/query" ) @@ -39,7 +39,7 @@ func (i *IoT) columnSelect(column string) string { if i.UseJSON { return fmt.Sprintf("tagset->>'%[1]s'", column) } - + return column } @@ -55,7 +55,7 @@ func (i *IoT) getTrucksWhereWithNames(names []string) string { } return fmt.Sprintf("tags_id IN (SELECT id FROM tags WHERE %s)", strings.Join(nameClauses, " OR ")) } - + for _, s := range names { nameClauses = append(nameClauses, fmt.Sprintf("'%s'", s)) } @@ -72,7 +72,7 @@ func (i *IoT) getTruckWhereString(nTrucks int) string { // LastLocByTruck finds the truck location for nTrucks. func (i *IoT) LastLocByTruck(qi query.Query, nTrucks int) { name, driver := "name", "driver" - + sql := fmt.Sprintf(`SELECT t.%s, t.%s, r.* FROM tags t INNER JOIN LATERAL (SELECT longitude, latitude @@ -83,17 +83,17 @@ func (i *IoT) LastLocByTruck(qi query.Query, nTrucks int) { i.withAlias(name), i.withAlias(driver), i.getTruckWhereString(nTrucks)) - + humanLabel := "TimescaleDB last location by specific truck" humanDesc := fmt.Sprintf("%s: random %4d trucks", humanLabel, nTrucks) - + i.fillInQuery(qi, humanLabel, humanDesc, iot.ReadingsTableName, sql) } // LastLocPerTruck finds all the truck locations along with truck and driver names. func (i *IoT) LastLocPerTruck(qi query.Query) { name, driver, fleet := "name", "driver", "fleet" - + sql := fmt.Sprintf(`SELECT t.%s, t.%s, r.* FROM tags t INNER JOIN LATERAL (SELECT longitude, latitude @@ -107,17 +107,17 @@ func (i *IoT) LastLocPerTruck(qi query.Query) { i.columnSelect(name), i.columnSelect(fleet), i.GetRandomFleet()) - + humanLabel := "TimescaleDB last location per truck" humanDesc := humanLabel - + i.fillInQuery(qi, humanLabel, humanDesc, iot.ReadingsTableName, sql) } // TrucksWithLowFuel finds all trucks with low fuel (less than 10%). func (i *IoT) TrucksWithLowFuel(qi query.Query) { name, driver, fleet := "name", "driver", "fleet" - + sql := fmt.Sprintf(`SELECT t.%s, t.%s, d.* FROM tags t INNER JOIN LATERAL (SELECT fuel_state @@ -132,17 +132,17 @@ func (i *IoT) TrucksWithLowFuel(qi query.Query) { i.columnSelect(name), i.columnSelect(fleet), i.GetRandomFleet()) - + humanLabel := "TimescaleDB trucks with low fuel" humanDesc := fmt.Sprintf("%s: under 10 percent", humanLabel) - + i.fillInQuery(qi, humanLabel, humanDesc, iot.DiagnosticsTableName, sql) } // TrucksWithHighLoad finds all trucks that have load over 90%. func (i *IoT) TrucksWithHighLoad(qi query.Query) { name, driver, fleet, load := "name", "driver", "fleet", "load_capacity" - + sql := fmt.Sprintf(`SELECT t.%s, t.%s, d.* FROM tags t INNER JOIN LATERAL (SELECT current_load @@ -158,17 +158,17 @@ func (i *IoT) TrucksWithHighLoad(qi query.Query) { i.columnSelect(load), i.columnSelect(fleet), i.GetRandomFleet()) - + humanLabel := "TimescaleDB trucks with high load" humanDesc := fmt.Sprintf("%s: over 90 percent", humanLabel) - + i.fillInQuery(qi, humanLabel, humanDesc, iot.DiagnosticsTableName, sql) } // StationaryTrucks finds all trucks that have low average velocity in a time window. func (i *IoT) StationaryTrucks(qi query.Query) { name, driver, fleet := "name", "driver", "fleet" - + interval := i.Interval.MustRandWindow(iot.StationaryDuration) sql := fmt.Sprintf(`SELECT t.%s, t.%s FROM tags t @@ -185,17 +185,17 @@ func (i *IoT) StationaryTrucks(qi query.Query) { i.columnSelect(name), i.columnSelect(fleet), i.GetRandomFleet()) - + humanLabel := "TimescaleDB stationary trucks" humanDesc := fmt.Sprintf("%s: with low avg velocity in last 10 minutes", humanLabel) - + i.fillInQuery(qi, humanLabel, humanDesc, iot.ReadingsTableName, sql) } // TrucksWithLongDrivingSessions finds all trucks that have not stopped at least 20 mins in the last 4 hours. func (i *IoT) TrucksWithLongDrivingSessions(qi query.Query) { name, driver, fleet := "name", "driver", "fleet" - + interval := i.Interval.MustRandWindow(iot.LongDrivingSessionDuration) sql := fmt.Sprintf(`SELECT t.%s, t.%s FROM tags t @@ -219,17 +219,17 @@ func (i *IoT) TrucksWithLongDrivingSessions(qi query.Query) { i.GetRandomFleet(), // Calculate number of 10 min intervals that is the max driving duration for the session if we rest 5 mins per hour. tenMinutePeriods(5, iot.LongDrivingSessionDuration)) - + humanLabel := "TimescaleDB trucks with longer driving sessions" humanDesc := fmt.Sprintf("%s: stopped less than 20 mins in 4 hour period", humanLabel) - + i.fillInQuery(qi, humanLabel, humanDesc, iot.ReadingsTableName, sql) } // TrucksWithLongDailySessions finds all trucks that have driven more than 10 hours in the last 24 hours. func (i *IoT) TrucksWithLongDailySessions(qi query.Query) { name, driver, fleet := "name", "driver", "fleet" - + interval := i.Interval.MustRandWindow(iot.DailyDrivingDuration) sql := fmt.Sprintf(`SELECT t.%s, t.%s FROM tags t @@ -253,17 +253,17 @@ func (i *IoT) TrucksWithLongDailySessions(qi query.Query) { i.GetRandomFleet(), // Calculate number of 10 min intervals that is the max driving duration for the session if we rest 35 mins per hour. tenMinutePeriods(35, iot.DailyDrivingDuration)) - + humanLabel := "TimescaleDB trucks with longer daily sessions" humanDesc := fmt.Sprintf("%s: drove more than 10 hours in the last 24 hours", humanLabel) - + i.fillInQuery(qi, humanLabel, humanDesc, iot.ReadingsTableName, sql) } // AvgVsProjectedFuelConsumption calculates average and projected fuel consumption per fleet. func (i *IoT) AvgVsProjectedFuelConsumption(qi query.Query) { fleet, consumption, name := "fleet", "nominal_fuel_consumption", "name" - + sql := fmt.Sprintf(`SELECT t.%s, avg(r.fuel_consumption) AS avg_fuel_consumption, avg(t.%s) AS projected_fuel_consumption FROM tags t @@ -277,17 +277,17 @@ func (i *IoT) AvgVsProjectedFuelConsumption(qi query.Query) { i.columnSelect(fleet), i.columnSelect(consumption), i.columnSelect(name)) - + humanLabel := "TimescaleDB average vs projected fuel consumption per fleet" humanDesc := humanLabel - + i.fillInQuery(qi, humanLabel, humanDesc, iot.ReadingsTableName, sql) } // AvgDailyDrivingDuration finds the average driving duration per driver. func (i *IoT) AvgDailyDrivingDuration(qi query.Query) { name, driver, fleet := "name", "driver", "fleet" - + sql := fmt.Sprintf(`WITH ten_minute_driving_sessions AS ( SELECT time_bucket('10 minutes', TIME) AS ten_minutes, tags_id @@ -307,17 +307,17 @@ func (i *IoT) AvgDailyDrivingDuration(qi query.Query) { i.withAlias(fleet), i.withAlias(name), i.withAlias(driver)) - + humanLabel := "TimescaleDB average driver driving duration per day" humanDesc := humanLabel - + i.fillInQuery(qi, humanLabel, humanDesc, iot.ReadingsTableName, sql) } // AvgDailyDrivingSession finds the average driving session without stopping per driver per day. func (i *IoT) AvgDailyDrivingSession(qi query.Query) { name := "name" - + sql := fmt.Sprintf(`WITH driver_status AS ( SELECT tags_id, time_bucket('10 mins', TIME) AS ten_minutes, avg(velocity) > 5 AS driving @@ -342,17 +342,17 @@ func (i *IoT) AvgDailyDrivingSession(qi query.Query) { ORDER BY name, day`, i.withAlias(name), i.columnSelect(name)) - + humanLabel := "TimescaleDB average driver driving session without stopping per day" humanDesc := humanLabel - + i.fillInQuery(qi, humanLabel, humanDesc, iot.ReadingsTableName, sql) } // AvgLoad finds the average load per truck model per fleet. func (i *IoT) AvgLoad(qi query.Query) { fleet, model, load, name := "fleet", "model", "load_capacity", "name" - + sql := fmt.Sprintf(`SELECT t.%s, t.%s, t.%s, avg(d.avg_load / t.%s) AS avg_load_percentage FROM tags t INNER JOIN ( @@ -367,17 +367,17 @@ func (i *IoT) AvgLoad(qi query.Query) { i.withAlias(load), i.columnSelect(load), i.columnSelect(name)) - + humanLabel := "TimescaleDB average load per truck model per fleet" humanDesc := humanLabel - + i.fillInQuery(qi, humanLabel, humanDesc, iot.ReadingsTableName, sql) } // DailyTruckActivity returns the number of hours trucks has been active (not out-of-commission) per day per fleet per model. func (i *IoT) DailyTruckActivity(qi query.Query) { fleet, model, name := "fleet", "model", "name" - + sql := fmt.Sprintf(`SELECT t.%s, t.%s, y.day, sum(y.ten_mins_per_day) / 144 AS daily_activity FROM tags t INNER JOIN ( @@ -392,17 +392,17 @@ func (i *IoT) DailyTruckActivity(qi query.Query) { i.withAlias(fleet), i.withAlias(model), i.columnSelect(name)) - + humanLabel := "TimescaleDB daily truck activity per fleet per model" humanDesc := humanLabel - + i.fillInQuery(qi, humanLabel, humanDesc, iot.ReadingsTableName, sql) } // TruckBreakdownFrequency calculates the amount of times a truck model broke down in the last period. func (i *IoT) TruckBreakdownFrequency(qi query.Query) { model, name := "model", "name" - + sql := fmt.Sprintf(`WITH breakdown_per_truck_per_ten_minutes AS ( SELECT time_bucket('10 minutes', TIME) AS ten_minutes, tags_id, count(STATUS = 0) / count(*) >= 0.5 AS broken_down @@ -423,10 +423,10 @@ func (i *IoT) TruckBreakdownFrequency(qi query.Query) { GROUP BY model`, i.withAlias(model), i.columnSelect(name)) - + humanLabel := "TimescaleDB truck breakdown frequency per model" humanDesc := humanLabel - + i.fillInQuery(qi, humanLabel, humanDesc, iot.DiagnosticsTableName, sql) } diff --git a/cmd/generate_queries/databases/timescaledb/iot_test.go b/cmd/generate_queries/databases/timescaledb/iot_test.go index 9a55ced..da78b9f 100644 --- a/cmd/generate_queries/databases/timescaledb/iot_test.go +++ b/cmd/generate_queries/databases/timescaledb/iot_test.go @@ -5,7 +5,7 @@ import ( "math/rand" "testing" "time" - + "github.com/cnosdb/tsdb-comparisons/cmd/generate_queries/uses/iot" "github.com/cnosdb/tsdb-comparisons/pkg/query" ) @@ -43,7 +43,7 @@ func TestLastLocByTruck(t *testing.T) { { desc: "one truck", input: 1, - + expectedHumanLabel: "TimescaleDB last location by specific truck", expectedHumanDesc: "TimescaleDB last location by specific truck: random 1 trucks", expectedHypertable: "readings", @@ -59,7 +59,7 @@ func TestLastLocByTruck(t *testing.T) { desc: "one truck use json", input: 1, useJSON: true, - + expectedHumanLabel: "TimescaleDB last location by specific truck", expectedHumanDesc: "TimescaleDB last location by specific truck: random 1 trucks", expectedHypertable: "readings", @@ -74,7 +74,7 @@ func TestLastLocByTruck(t *testing.T) { { desc: "three truck", input: 3, - + expectedHumanLabel: "TimescaleDB last location by specific truck", expectedHumanDesc: "TimescaleDB last location by specific truck: random 3 trucks", expectedHypertable: "readings", @@ -87,13 +87,13 @@ func TestLastLocByTruck(t *testing.T) { WHERE t.name IN ('truck_3','truck_5','truck_9')`, }, } - + testFunc := func(i *IoT, c testCase) query.Query { q := i.GenerateEmptyQuery() i.LastLocByTruck(q, c.input) return q } - + runTestCases(t, testFunc, time.Now(), time.Now(), cases) } @@ -101,7 +101,7 @@ func TestLastLocPerTruck(t *testing.T) { cases := []testCase{ { desc: "default to using tags", - + expectedHumanLabel: "TimescaleDB last location per truck", expectedHumanDesc: "TimescaleDB last location per truck", expectedHypertable: iot.ReadingsTableName, @@ -114,10 +114,10 @@ func TestLastLocPerTruck(t *testing.T) { WHERE t.name IS NOT NULL AND t.fleet = 'South'`, }, - + { desc: "use JSON", - + useJSON: true, expectedHumanLabel: "TimescaleDB last location per truck", expectedHumanDesc: "TimescaleDB last location per truck", @@ -132,7 +132,7 @@ func TestLastLocPerTruck(t *testing.T) { AND t.tagset->>'fleet' = 'South'`, }, } - + for _, c := range cases { rand.Seed(123) b := BaseGenerator{ @@ -142,12 +142,12 @@ func TestLastLocPerTruck(t *testing.T) { if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() g.LastLocPerTruck(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedHypertable, c.expectedSQLQuery) } } @@ -156,7 +156,7 @@ func TestTrucksWithLowFuel(t *testing.T) { cases := []testCase{ { desc: "default to using tags", - + expectedHumanLabel: "TimescaleDB trucks with low fuel", expectedHumanDesc: "TimescaleDB trucks with low fuel: under 10 percent", expectedHypertable: iot.DiagnosticsTableName, @@ -170,10 +170,10 @@ func TestTrucksWithLowFuel(t *testing.T) { AND d.fuel_state < 0.1 AND t.fleet = 'South'`, }, - + { desc: "use JSON", - + useJSON: true, expectedHumanLabel: "TimescaleDB trucks with low fuel", expectedHumanDesc: "TimescaleDB trucks with low fuel: under 10 percent", @@ -189,7 +189,7 @@ func TestTrucksWithLowFuel(t *testing.T) { AND t.tagset->>'fleet' = 'South'`, }, } - + for _, c := range cases { rand.Seed(123) b := BaseGenerator{ @@ -199,12 +199,12 @@ func TestTrucksWithLowFuel(t *testing.T) { if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() g.TrucksWithLowFuel(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedHypertable, c.expectedSQLQuery) } } @@ -213,7 +213,7 @@ func TestTrucksWithHighLoad(t *testing.T) { cases := []testCase{ { desc: "default to using tags", - + expectedHumanLabel: "TimescaleDB trucks with high load", expectedHumanDesc: "TimescaleDB trucks with high load: over 90 percent", expectedHypertable: iot.DiagnosticsTableName, @@ -227,10 +227,10 @@ func TestTrucksWithHighLoad(t *testing.T) { AND d.current_load/t.load_capacity > 0.9 AND t.fleet = 'South'`, }, - + { desc: "use JSON", - + useJSON: true, expectedHumanLabel: "TimescaleDB trucks with high load", expectedHumanDesc: "TimescaleDB trucks with high load: over 90 percent", @@ -246,7 +246,7 @@ func TestTrucksWithHighLoad(t *testing.T) { AND t.tagset->>'fleet' = 'South'`, }, } - + for _, c := range cases { rand.Seed(123) b := BaseGenerator{ @@ -256,12 +256,12 @@ func TestTrucksWithHighLoad(t *testing.T) { if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() g.TrucksWithHighLoad(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedHypertable, c.expectedSQLQuery) } } @@ -270,7 +270,7 @@ func TestStationaryTrucks(t *testing.T) { cases := []testCase{ { desc: "default to using tags", - + expectedHumanLabel: "TimescaleDB stationary trucks", expectedHumanDesc: "TimescaleDB stationary trucks: with low avg velocity in last 10 minutes", expectedHypertable: iot.ReadingsTableName, @@ -283,10 +283,10 @@ func TestStationaryTrucks(t *testing.T) { GROUP BY 1, 2 HAVING avg(r.velocity) < 1`, }, - + { desc: "use JSON", - + useJSON: true, expectedHumanLabel: "TimescaleDB stationary trucks", expectedHumanDesc: "TimescaleDB stationary trucks: with low avg velocity in last 10 minutes", @@ -301,17 +301,17 @@ func TestStationaryTrucks(t *testing.T) { HAVING avg(r.velocity) < 1`, }, } - + for _, c := range cases { b := &BaseGenerator{ UseJSON: c.useJSON, } g := NewIoT(time.Unix(0, 0), time.Unix(0, 0).Add(time.Hour), 10, b) - + q := g.GenerateEmptyQuery() rand.Seed(123) g.StationaryTrucks(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedHypertable, c.expectedSQLQuery) } } @@ -320,7 +320,7 @@ func TestTrucksWithLongDrivingSessions(t *testing.T) { cases := []testCase{ { desc: "default to using tags", - + expectedHumanLabel: "TimescaleDB trucks with longer driving sessions", expectedHumanDesc: "TimescaleDB trucks with longer driving sessions: stopped less than 20 mins in 4 hour period", expectedHypertable: iot.ReadingsTableName, @@ -338,10 +338,10 @@ func TestTrucksWithLongDrivingSessions(t *testing.T) { GROUP BY name, driver HAVING count(r.ten_minutes) > 22`, }, - + { desc: "use JSON", - + useJSON: true, expectedHumanLabel: "TimescaleDB trucks with longer driving sessions", expectedHumanDesc: "TimescaleDB trucks with longer driving sessions: stopped less than 20 mins in 4 hour period", @@ -361,7 +361,7 @@ func TestTrucksWithLongDrivingSessions(t *testing.T) { HAVING count(r.ten_minutes) > 22`, }, } - + for _, c := range cases { b := BaseGenerator{ UseJSON: c.useJSON, @@ -370,13 +370,13 @@ func TestTrucksWithLongDrivingSessions(t *testing.T) { if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() rand.Seed(123) g.TrucksWithLongDrivingSessions(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedHypertable, c.expectedSQLQuery) } } @@ -385,7 +385,7 @@ func TestTrucksWithLongDailySessions(t *testing.T) { cases := []testCase{ { desc: "default to using tags", - + expectedHumanLabel: "TimescaleDB trucks with longer daily sessions", expectedHumanDesc: "TimescaleDB trucks with longer daily sessions: drove more than 10 hours in the last 24 hours", expectedHypertable: iot.ReadingsTableName, @@ -403,10 +403,10 @@ func TestTrucksWithLongDailySessions(t *testing.T) { GROUP BY name, driver HAVING count(r.ten_minutes) > 60`, }, - + { desc: "use JSON", - + useJSON: true, expectedHumanLabel: "TimescaleDB trucks with longer daily sessions", expectedHumanDesc: "TimescaleDB trucks with longer daily sessions: drove more than 10 hours in the last 24 hours", @@ -426,7 +426,7 @@ func TestTrucksWithLongDailySessions(t *testing.T) { HAVING count(r.ten_minutes) > 60`, }, } - + for _, c := range cases { b := BaseGenerator{ UseJSON: c.useJSON, @@ -435,13 +435,13 @@ func TestTrucksWithLongDailySessions(t *testing.T) { if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() rand.Seed(123) g.TrucksWithLongDailySessions(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedHypertable, c.expectedSQLQuery) } } @@ -450,7 +450,7 @@ func TestAvgVsProjectedFuelConsumption(t *testing.T) { cases := []testCase{ { desc: "default to using tags", - + expectedHumanLabel: "TimescaleDB average vs projected fuel consumption per fleet", expectedHumanDesc: "TimescaleDB average vs projected fuel consumption per fleet", expectedHypertable: iot.ReadingsTableName, @@ -463,10 +463,10 @@ func TestAvgVsProjectedFuelConsumption(t *testing.T) { AND t.name IS NOT NULL GROUP BY fleet`, }, - + { desc: "use JSON", - + useJSON: true, expectedHumanLabel: "TimescaleDB average vs projected fuel consumption per fleet", expectedHumanDesc: "TimescaleDB average vs projected fuel consumption per fleet", @@ -481,7 +481,7 @@ func TestAvgVsProjectedFuelConsumption(t *testing.T) { GROUP BY fleet`, }, } - + for _, c := range cases { b := BaseGenerator{ UseJSON: c.useJSON, @@ -490,13 +490,13 @@ func TestAvgVsProjectedFuelConsumption(t *testing.T) { if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() rand.Seed(123) g.AvgVsProjectedFuelConsumption(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedHypertable, c.expectedSQLQuery) } } @@ -505,7 +505,7 @@ func TestAvgDailyDrivingDuration(t *testing.T) { cases := []testCase{ { desc: "default to using tags", - + expectedHumanLabel: "TimescaleDB average driver driving duration per day", expectedHumanDesc: "TimescaleDB average driver driving duration per day", expectedHypertable: iot.ReadingsTableName, @@ -526,10 +526,10 @@ func TestAvgDailyDrivingDuration(t *testing.T) { INNER JOIN tags t ON t.id = d.tags_id GROUP BY fleet, name, driver`, }, - + { desc: "use JSON", - + useJSON: true, expectedHumanLabel: "TimescaleDB average driver driving duration per day", expectedHumanDesc: "TimescaleDB average driver driving duration per day", @@ -552,7 +552,7 @@ func TestAvgDailyDrivingDuration(t *testing.T) { GROUP BY fleet, name, driver`, }, } - + for _, c := range cases { b := BaseGenerator{ UseJSON: c.useJSON, @@ -561,13 +561,13 @@ func TestAvgDailyDrivingDuration(t *testing.T) { if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() rand.Seed(123) g.AvgDailyDrivingDuration(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedHypertable, c.expectedSQLQuery) } } @@ -576,7 +576,7 @@ func TestAvgDailyDrivingSession(t *testing.T) { cases := []testCase{ { desc: "default to using tags", - + expectedHumanLabel: "TimescaleDB average driver driving session without stopping per day", expectedHumanDesc: "TimescaleDB average driver driving session without stopping per day", expectedHypertable: iot.ReadingsTableName, @@ -603,10 +603,10 @@ func TestAvgDailyDrivingSession(t *testing.T) { GROUP BY name, day ORDER BY name, day`, }, - + { desc: "use JSON", - + useJSON: true, expectedHumanLabel: "TimescaleDB average driver driving session without stopping per day", expectedHumanDesc: "TimescaleDB average driver driving session without stopping per day", @@ -635,7 +635,7 @@ func TestAvgDailyDrivingSession(t *testing.T) { ORDER BY name, day`, }, } - + for _, c := range cases { b := BaseGenerator{ UseJSON: c.useJSON, @@ -644,13 +644,13 @@ func TestAvgDailyDrivingSession(t *testing.T) { if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() rand.Seed(123) g.AvgDailyDrivingSession(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedHypertable, c.expectedSQLQuery) } } @@ -659,7 +659,7 @@ func TestAvgLoad(t *testing.T) { cases := []testCase{ { desc: "default to using tags", - + expectedHumanLabel: "TimescaleDB average load per truck model per fleet", expectedHumanDesc: "TimescaleDB average load per truck model per fleet", expectedHypertable: iot.ReadingsTableName, @@ -673,10 +673,10 @@ func TestAvgLoad(t *testing.T) { WHERE t.name IS NOT NULL GROUP BY fleet, model, load_capacity`, }, - + { desc: "use JSON", - + useJSON: true, expectedHumanLabel: "TimescaleDB average load per truck model per fleet", expectedHumanDesc: "TimescaleDB average load per truck model per fleet", @@ -692,7 +692,7 @@ func TestAvgLoad(t *testing.T) { GROUP BY fleet, model, load_capacity`, }, } - + for _, c := range cases { b := BaseGenerator{ UseJSON: c.useJSON, @@ -701,13 +701,13 @@ func TestAvgLoad(t *testing.T) { if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() rand.Seed(123) g.AvgLoad(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedHypertable, c.expectedSQLQuery) } } @@ -716,7 +716,7 @@ func TestDailyTruckActivity(t *testing.T) { cases := []testCase{ { desc: "default to using tags", - + expectedHumanLabel: "TimescaleDB daily truck activity per fleet per model", expectedHumanDesc: "TimescaleDB daily truck activity per fleet per model", expectedHypertable: iot.ReadingsTableName, @@ -732,10 +732,10 @@ func TestDailyTruckActivity(t *testing.T) { GROUP BY fleet, model, y.day ORDER BY y.day`, }, - + { desc: "use JSON", - + useJSON: true, expectedHumanLabel: "TimescaleDB daily truck activity per fleet per model", expectedHumanDesc: "TimescaleDB daily truck activity per fleet per model", @@ -753,7 +753,7 @@ func TestDailyTruckActivity(t *testing.T) { ORDER BY y.day`, }, } - + for _, c := range cases { b := BaseGenerator{ UseJSON: c.useJSON, @@ -762,13 +762,13 @@ func TestDailyTruckActivity(t *testing.T) { if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() rand.Seed(123) g.DailyTruckActivity(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedHypertable, c.expectedSQLQuery) } } @@ -777,7 +777,7 @@ func TestTruckBreakdownFrequency(t *testing.T) { cases := []testCase{ { desc: "default to using tags", - + expectedHumanLabel: "TimescaleDB truck breakdown frequency per model", expectedHumanDesc: "TimescaleDB truck breakdown frequency per model", expectedHypertable: iot.DiagnosticsTableName, @@ -800,10 +800,10 @@ func TestTruckBreakdownFrequency(t *testing.T) { AND broken_down = false AND next_broken_down = true GROUP BY model`, }, - + { desc: "use JSON", - + useJSON: true, expectedHumanLabel: "TimescaleDB truck breakdown frequency per model", expectedHumanDesc: "TimescaleDB truck breakdown frequency per model", @@ -828,7 +828,7 @@ func TestTruckBreakdownFrequency(t *testing.T) { GROUP BY model`, }, } - + for _, c := range cases { b := BaseGenerator{ UseJSON: c.useJSON, @@ -837,13 +837,13 @@ func TestTruckBreakdownFrequency(t *testing.T) { if err != nil { t.Fatalf("Error while creating iot generator") } - + g := ig.(*IoT) - + q := g.GenerateEmptyQuery() rand.Seed(123) g.TruckBreakdownFrequency(q) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedHypertable, c.expectedSQLQuery) } } @@ -885,18 +885,18 @@ func TestTenMinutePeriods(t *testing.T) { result: 2, }, } - + for _, c := range cases { if got := tenMinutePeriods(c.minutesPerHour, c.duration); got != c.result { t.Errorf("incorrect result for %.2f minutes per hour, duration %s: got %d want %d", c.minutesPerHour, c.duration.String(), got, c.result) } } - + } func runTestCases(t *testing.T, testFunc func(*IoT, testCase) query.Query, s time.Time, e time.Time, cases []testCase) { rand.Seed(123) // Setting seed for testing purposes. - + for _, c := range cases { t.Run(c.desc, func(t *testing.T) { b := BaseGenerator{} @@ -906,7 +906,7 @@ func runTestCases(t *testing.T, testFunc func(*IoT, testCase) query.Query, s tim t.Fatalf("Error while creating devops generator") } i := dq.(*IoT) - + if c.fail { func() { defer func() { @@ -914,17 +914,17 @@ func runTestCases(t *testing.T, testFunc func(*IoT, testCase) query.Query, s tim if r == nil { t.Fatalf("did not panic when should") } - + if r != c.failMsg { t.Fatalf("incorrect fail message: got %s, want %s", r, c.failMsg) } }() - + testFunc(i, c) }() } else { q := testFunc(i, c) - + verifyQuery(t, q, c.expectedHumanLabel, c.expectedHumanDesc, c.expectedHypertable, c.expectedSQLQuery) } }) @@ -932,23 +932,23 @@ func runTestCases(t *testing.T, testFunc func(*IoT, testCase) query.Query, s tim } func verifyQuery(t *testing.T, q query.Query, humanLabel, humanDesc, hypertable, sqlQuery string) { tsq, ok := q.(*query.TimescaleDB) - + if !ok { t.Fatal("Filled query is not *query.TimescaleDB type") } - + if got := string(tsq.HumanLabel); got != humanLabel { t.Errorf("incorrect human label:\ngot\n%s\nwant\n%s", got, humanLabel) } - + if got := string(tsq.HumanDescription); got != humanDesc { t.Errorf("incorrect human description:\ngot\n%s\nwant\n%s", got, humanDesc) } - + if got := string(tsq.Hypertable); got != hypertable { t.Errorf("incorrect hypertable:\ngot\n%s\nwant\n%s", got, hypertable) } - + if got := string(tsq.SqlQuery); got != sqlQuery { t.Errorf("incorrect SQL query:\ndiff\n%s\ngot\n%s\nwant\n%s", diff.CharacterDiff(got, sqlQuery), got, sqlQuery) } diff --git a/cmd/generate_queries/main.go b/cmd/generate_queries/main.go index 7eeaf79..a7d7a94 100644 --- a/cmd/generate_queries/main.go +++ b/cmd/generate_queries/main.go @@ -41,7 +41,7 @@ func init() { oldUsage := pflag.Usage pflag.Usage = func() { oldUsage() - + fmt.Fprintf(os.Stderr, "\n") fmt.Fprintf(os.Stderr, "The use case matrix of choices is:\n") for uc, queryTypes := range useCaseMatrix { @@ -50,21 +50,21 @@ func init() { } } } - + conf.AddToFlagSet(pflag.CommandLine) - + pflag.Parse() - + err := internalUtils.SetupConfigFile() - + if err != nil { panic(fmt.Errorf("fatal error config file: %s", err)) } - + if err := viper.Unmarshal(&conf.BaseConfig); err != nil { panic(fmt.Errorf("unable to decode base config: %s", err)) } - + if err := viper.Unmarshal(&conf); err != nil { panic(fmt.Errorf("unable to decode config: %s", err)) } diff --git a/cmd/generate_queries/uses/common/common.go b/cmd/generate_queries/uses/common/common.go index 3a66567..5a8ff36 100644 --- a/cmd/generate_queries/uses/common/common.go +++ b/cmd/generate_queries/uses/common/common.go @@ -5,7 +5,7 @@ import ( "math/rand" "reflect" "time" - + "github.com/cnosdb/tsdb-comparisons/cmd/generate_queries/utils" internalutils "github.com/cnosdb/tsdb-comparisons/internal/utils" ) @@ -18,7 +18,7 @@ const ( type Core struct { // Interval is the entire time range of the dataset Interval *internalutils.TimeInterval - + // Scale is the cardinality of the dataset in terms of devices/hosts Scale int } @@ -29,7 +29,7 @@ func NewCore(start, end time.Time, scale int) (*Core, error) { if err != nil { return nil, err } - + return &Core{Interval: ti, Scale: scale}, nil } @@ -48,7 +48,7 @@ func GetRandomSubsetPerm(numItems int, totalItems int) ([]int, error) { // Cannot make a subset longer than the original set return nil, fmt.Errorf(errMoreItemsThanScale) } - + seen := map[int]bool{} res := make([]int, numItems) for i := 0; i < numItems; i++ { diff --git a/cmd/generate_queries/uses/common/common_test.go b/cmd/generate_queries/uses/common/common_test.go index 3d03659..4c14e6f 100644 --- a/cmd/generate_queries/uses/common/common_test.go +++ b/cmd/generate_queries/uses/common/common_test.go @@ -4,7 +4,7 @@ import ( "sort" "testing" "time" - + "github.com/cnosdb/tsdb-comparisons/internal/utils" ) @@ -46,7 +46,7 @@ func TestGetRandomSubsetPerm(t *testing.T) { {scale: 10, nItems: 10}, {scale: 1000, nItems: 1000}, } - + for _, c := range cases { ret, err := GetRandomSubsetPerm(c.nItems, c.scale) if err != nil { diff --git a/cmd/generate_queries/uses/iot/common.go b/cmd/generate_queries/uses/iot/common.go index 91016a5..12363c3 100644 --- a/cmd/generate_queries/uses/iot/common.go +++ b/cmd/generate_queries/uses/iot/common.go @@ -5,7 +5,7 @@ import ( "github.com/cnosdb/tsdb-comparisons/pkg/data/usecases/iot" "math/rand" "time" - + "github.com/cnosdb/tsdb-comparisons/cmd/generate_queries/uses/common" "github.com/cnosdb/tsdb-comparisons/pkg/query" ) @@ -17,7 +17,7 @@ const ( // DiagnosticsTableName is the name of the table where all the diagnostics // time series data is stored. DiagnosticsTableName = "diagnostics" - + // StationaryDuration is the time duration to evaluate stationary trucks. StationaryDuration = 10 * time.Minute // LongDrivingSessionDuration is the the time duration which is considered a @@ -25,7 +25,7 @@ const ( LongDrivingSessionDuration = 4 * time.Hour // DailyDrivingDuration is time duration of one day of driving. DailyDrivingDuration = 24 * time.Hour - + // LabelLastLoc is the label for the last location query. LabelLastLoc = "last-loc" // LabelLastLocSingleTruck is the label for the last location query for a single truck. @@ -68,7 +68,7 @@ func (c Core) GetRandomFleet() string { func NewCore(start, end time.Time, scale int) (*Core, error) { c, err := common.NewCore(start, end, scale) return &Core{Core: c}, err - + } // GetRandomTrucks returns a random set of nTrucks from a given Core @@ -86,17 +86,17 @@ func getRandomTrucks(numTrucks int, totalTrucks int) ([]string, error) { if numTrucks > totalTrucks { return nil, fmt.Errorf("number of trucks (%d) larger than total trucks. See --scale (%d)", numTrucks, totalTrucks) } - + randomNumbers, err := common.GetRandomSubsetPerm(numTrucks, totalTrucks) if err != nil { return nil, err } - + truckNames := []string{} for _, n := range randomNumbers { truckNames = append(truckNames, fmt.Sprintf("truck_%d", n)) } - + return truckNames, nil } diff --git a/cmd/load/config_cmd.go b/cmd/load/config_cmd.go index 5abc795..eb181da 100644 --- a/cmd/load/config_cmd.go +++ b/cmd/load/config_cmd.go @@ -16,7 +16,7 @@ import ( const ( dataSourceFlag = "data-source" targetDbFlag = "target" - + writeConfigTo = "./config.yaml" ) @@ -26,7 +26,7 @@ func initConfigCMD() *cobra.Command { Short: "Generate example config yaml file and save it to" + writeConfigTo, Run: config, } - + cmd.PersistentFlags().String( dataSourceFlag, source.SimulatorDataSourceType, @@ -38,11 +38,11 @@ func initConfigCMD() *cobra.Command { func config(cmd *cobra.Command, _ []string) { dataSourceSelected := readFlag(cmd, dataSourceFlag) targetSelected := readFlag(cmd, targetDbFlag) - + exampleConfig := getEmptyConfigWithoutDbSpecifics(targetSelected, dataSourceSelected) target := initializers.GetTarget(targetSelected) v := setExampleConfigInViper(exampleConfig, target) - + if err := v.WriteConfigAs(writeConfigTo); err != nil { panic(fmt.Errorf("could not write sample config to file %s: %v", writeConfigTo, err)) } @@ -79,27 +79,27 @@ func readFlag(cmd *cobra.Command, flag string) string { func setExampleConfigInViper(confWithoutDBSpecifics *LoadConfig, t targets.ImplementedTarget) *viper.Viper { v := viper.New() v.SetConfigType("yaml") - + // convert LoaderConfig to yaml to load into viper configInBytes, err := yaml.Marshal(confWithoutDBSpecifics) if err != nil { panic(fmt.Errorf("could not convert example config to yaml: %v", err)) } - + if err := v.ReadConfig(bytes.NewBuffer(configInBytes)); err != nil { panic(fmt.Errorf("could not load example config in viper: %v", err)) } - + // get loader.runner and data-source flags // and remove either data-source.file or data-source.simulator depending on selected // data source type loadCmdFlagSet := cleanDataSourceFlags(confWithoutDBSpecifics.DataSource.Type, loadCmdFlags()) - + // bind loader.runner and data-source flags if err := v.BindPFlags(loadCmdFlagSet); err != nil { panic(fmt.Errorf("could not bind loader.runner and data-source flags in viper: %v", err)) } - + // get target specific flags flagSet := pflag.NewFlagSet("", pflag.ContinueOnError) t.TargetSpecificFlags("loader.db-specific.", flagSet) @@ -107,7 +107,7 @@ func setExampleConfigInViper(confWithoutDBSpecifics *LoadConfig, t targets.Imple if err := v.BindPFlags(flagSet); err != nil { panic(fmt.Errorf("could not bind target specific config flags in viper: %v", err)) } - + return v } diff --git a/cmd/load/load_cmd.go b/cmd/load/load_cmd.go index a8227d0..6486679 100644 --- a/cmd/load/load_cmd.go +++ b/cmd/load/load_cmd.go @@ -23,11 +23,11 @@ func initLoadCMD() (*cobra.Command, error) { err := viper.BindPFlags(cmd.PersistentFlags()) // don't bind --config which specifies the file from where to read config cmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is ./config.yaml)") - + if err != nil { return nil, fmt.Errorf("could not bind flags to configuration: %v", err) } - + subCommands := initLoadSubCommands() cmd.AddCommand(subCommands...) return cmd, nil @@ -50,11 +50,11 @@ func initLoadSubCommands() []*cobra.Command { Short: "Load data into " + format + " as a target db", Run: createRunLoad(target), } - + target.TargetSpecificFlags("loader.db-specific.", cmd.PersistentFlags()) commands[i] = cmd } - + return commands } @@ -84,7 +84,7 @@ func initViperConfig(*cobra.Command, []string) { viper.SetConfigName("config") viper.SetConfigType("yaml") } - + if err := viper.ReadInConfig(); err == nil { fmt.Println("Using config file:", viper.ConfigFileUsed()) } diff --git a/cmd/load/load_cmd_flags.go b/cmd/load/load_cmd_flags.go index 2bea4a6..a9693b7 100644 --- a/cmd/load/load_cmd_flags.go +++ b/cmd/load/load_cmd_flags.go @@ -2,9 +2,9 @@ package main import ( "fmt" - "github.com/spf13/pflag" "github.com/cnosdb/tsdb-comparisons/load" "github.com/cnosdb/tsdb-comparisons/pkg/data/source" + "github.com/spf13/pflag" "strings" "time" ) diff --git a/cmd/load/parse_config.go b/cmd/load/parse_config.go index 798d2f7..59df488 100644 --- a/cmd/load/parse_config.go +++ b/cmd/load/parse_config.go @@ -20,34 +20,34 @@ func parseConfig(target targets.ImplementedTarget, v *viper.Viper) (targets.Benc return nil, nil, err } dataSourceInternal := convertDataSourceConfigToInternalRepresentation(target.TargetName(), dataSource) - + loaderViper := v.Sub("loader") if loaderViper == nil { return nil, nil, fmt.Errorf("config file didn't have a top-level 'loader' object") } - + runnerViper := loaderViper.Sub("runner") if runnerViper == nil { return nil, nil, fmt.Errorf("config file didn't have loader.runner specified") } - + loaderConfig, err := parseRunnerConfig(runnerViper) if err != nil { return nil, nil, err } - + loaderConfigInternal := convertRunnerConfigToInternalRep(loaderConfig) - + dbSpecificViper := loaderViper.Sub("db-specific") if dbSpecificViper == nil { return nil, nil, fmt.Errorf("config file didn't have loader.db-specific specified") } - + benchmark, err := target.Benchmark(loaderConfigInternal.DBName, dataSourceInternal, dbSpecificViper) if err != nil { return nil, nil, err } - + return benchmark, load.GetBenchmarkRunner(*loaderConfigInternal), nil } @@ -94,7 +94,7 @@ func parseDataSourceConfig(v *viper.Viper) (*DataSourceConfig, error) { if err := validateSourceType(conf.Type); err != nil { return nil, err } - + if conf.Type == source.FileDataSourceType { if conf.File == nil { errStr := fmt.Sprintf( @@ -105,7 +105,7 @@ func parseDataSourceConfig(v *viper.Viper) (*DataSourceConfig, error) { } return &conf, nil } - + if conf.Simulator == nil { errStr := fmt.Sprintf( "specified type %s, but no simulator data source config provided", @@ -141,8 +141,8 @@ func convertDataSourceConfigToInternalRepresentation(format string, d *DataSourc } } return &source.DataSourceConfig{ - Type: d.Type, - File: file, + Type: d.Type, + File: file, Simulator: simulator, } } diff --git a/cmd/load_cnosdb/http_writer.go b/cmd/load_cnosdb/http_writer.go index a1a7699..bc700a3 100644 --- a/cmd/load_cnosdb/http_writer.go +++ b/cmd/load_cnosdb/http_writer.go @@ -4,10 +4,14 @@ package main import ( "bytes" + "errors" "fmt" - "time" - + "github.com/cnosdb/tsdb-comparisons/cmd/load_cnosdb/models" + flatbuffers "github.com/google/flatbuffers/go" "github.com/valyala/fasthttp" + "strconv" + "time" + "unsafe" ) const ( @@ -97,6 +101,7 @@ func (w *HTTPWriter) executeReq(req *fasthttp.Request, resp *fasthttp.Response) // It returns the latency in nanoseconds and any error received while sending the data over HTTP, // or it returns a new error if the HTTP response isn't as expected. func (w *HTTPWriter) WriteLineProtocol(body []byte, isGzip bool) (int64, error) { + //client := TSKVServiceClient req := fasthttp.AcquireRequest() defer fasthttp.ReleaseRequest(req) w.initializeReq(req, body, isGzip) @@ -107,6 +112,46 @@ func (w *HTTPWriter) WriteLineProtocol(body []byte, isGzip bool) (int64, error) return w.executeReq(req, resp) } +func parserLine(lines []byte) []byte { + pointFb := flatbuffers.NewBuilder(0) + fb := flatbuffers.NewBuilder(0) + numLines := bytes.Count(lines, []byte{'\n'}) + + var pointOffs []flatbuffers.UOffsetT + var ( + pos int + block []byte + ) + for pos < len(lines) { + pos, block = scanLine(lines, pos) + if len(block) == 0 { + continue + } + start := skipWhitespace(block, 0) + if start >= len(block) { + continue + } + if block[start] == '#' { + continue + } + if block[len(block)-1] == '\n' { + block = block[:len(block)-1] + } + pointOffs = append(pointOffs, parsePoint(fb, block[start:])) + } + models.PointsStartPointsVector(fb, numLines) + for _, i := range pointOffs { + fb.PrependUOffsetT(i) + } + ptVec := fb.EndVector(numLines) + models.PointsStart(pointFb) + models.PointsAddPoints(pointFb, ptVec) + models.PointsAddDatabase(pointFb, pointFb.CreateByteString([]byte("public"))) + endPoints := models.PointsEnd(pointFb) + pointFb.Finish(endPoints) + return pointFb.FinishedBytes() +} + func backpressurePred(body []byte) bool { if bytes.Contains(body, backoffMagicWords0) { return true @@ -124,3 +169,1021 @@ func backpressurePred(body []byte) bool { return false } } + +func scanLine(buf []byte, i int) (int, []byte) { + start := i + quoted := false + fields := false + + // tracks how many '=' and commas we've seen + // this duplicates some of the functionality in scanFields + equals := 0 + commas := 0 + for { + // reached the end of buf? + if i >= len(buf) { + break + } + + // skip past escaped characters + if buf[i] == '\\' && i+2 < len(buf) { + i += 2 + continue + } + + if buf[i] == ' ' { + fields = true + } + + // If we see a double quote, makes sure it is not escaped + if fields { + if !quoted && buf[i] == '=' { + i++ + equals++ + continue + } else if !quoted && buf[i] == ',' { + i++ + commas++ + continue + } else if buf[i] == '"' && equals > commas { + i++ + quoted = !quoted + continue + } + } + + if buf[i] == '\n' && !quoted { + break + } + + i++ + + } + + return i, buf[start:i] +} + +func skipWhitespace(buf []byte, i int) int { + for i < len(buf) { + if buf[i] != ' ' && buf[i] != '\t' && buf[i] != 0 { + break + } + i++ + } + return i +} + +func parsePoint(fb *flatbuffers.Builder, buf []byte) flatbuffers.UOffsetT { + pos, key, err, mPos := scanKey(buf, 0) + + if err != nil { + panic(err) + } + if len(key) == 0 { + panic(fmt.Errorf("missing measurement")) + } + + if len(key) > 65535 { + panic(fmt.Errorf("max key length exceeded: %v > %v", len(key), 65535)) + } + tableOff := fb.CreateByteVector(buf[0 : mPos-1]) + + tkValOffs, tvValOffs := parseTags(fb, buf[mPos:]) + tagOffs := make([]flatbuffers.UOffsetT, len(tkValOffs)) + for i := 0; i < len(tkValOffs); i++ { + models.TagStart(fb) + models.TagAddKey(fb, tkValOffs[i]) + models.TagAddKey(fb, tvValOffs[i]) + tagOffs = append(tagOffs, models.TagEnd(fb)) + } + models.PointStartTagsVector(fb, len(tagOffs)) + for _, off := range tagOffs { + fb.PrependUOffsetT(off) + } + tagsOff := fb.EndVector(len(tagOffs)) + + pos, fields, err := scanFields(buf, pos) + if err != nil { + panic(err) + } + if len(fields) == 0 { + panic(fmt.Errorf("missing fields")) + } + i := 0 + + var fkOffs []flatbuffers.UOffsetT + var fvOffs []flatbuffers.UOffsetT + var fTyps []models.FieldType + err = walkFields(fields, func(k, v []byte) bool { + fkOffs = append(fkOffs, fb.CreateByteVector(k)) + fvOffs = append(fvOffs, fb.CreateByteVector(v)) + fTyps = append(fTyps, models.FieldTypeUnknown) + i++ + return true + }) + fieldOffs := make([]flatbuffers.UOffsetT, len(fkOffs)) + for i := 0; i < len(fkOffs); i++ { + models.FieldStart(fb) + models.FieldAddName(fb, fkOffs[i]) + models.FieldAddValue(fb, fvOffs[i]) + models.FieldAddType(fb, fTyps[i]) + fieldOffs = append(fieldOffs, models.FieldEnd(fb)) + } + models.PointStartFieldsVector(fb, len(fieldOffs)) + for _, off := range fieldOffs { + fb.PrependUOffsetT(off) + } + fieldsOff := fb.EndVector(len(fieldOffs)) + + pos, ts, err := scanTime(buf, pos) + tsInt, err := strconv.Atoi(string(ts)) + if err != nil { + panic(err) + } + + models.PointStart(fb) + models.PointAddDb(fb, tableOff) + models.PointAddTags(fb, tagsOff) + models.PointAddFields(fb, fieldsOff) + models.PointAddTimestamp(fb, int64(tsInt)) + return models.PointEnd(fb) +} + +func scanKey(buf []byte, i int) (int, []byte, error, int) { + start := skipWhitespace(buf, i) + + i = start + + // Determines whether the tags are sort, assume they are + sorted := true + + // indices holds the indexes within buf of the start of each tag. For example, + // a buf of 'cpu,host=a,region=b,zone=c' would have indices slice of [4,11,20] + // which indicates that the first tag starts at buf[4], seconds at buf[11], and + // last at buf[20] + indices := make([]int, 100) + + // tracks how many commas we've seen so we know how many values are indices. + // Since indices is an arbitrarily large slice, + // we need to know how many values in the buffer are in use. + commas := 0 + + // First scan the Point's measurement. + state, i, err := scanMeasurement(buf, i) + meaPos := i + if err != nil { + return i, buf[start:i], err, meaPos + } + + // Optionally scan tags if needed. + if state == tagKeyState { + i, commas, indices, err = scanTags(buf, i, indices) + if err != nil { + return i, buf[start:i], err, meaPos + } + } + + // Iterate over tags keys ensure that we do not encounter any + // of the reserved tag keys such as _measurement or _field. + for j := 0; j < commas; j++ { + _, key := scanTo(buf[indices[j]:indices[j+1]-1], 0, '=') + + for _, reserved := range reservedTagKeys { + if bytes.Equal(key, reserved) { + return i, buf[start:i], fmt.Errorf("cannot use reserved tag key %q", key), meaPos + } + } + } + + // Now we know where the key region is within buf, and the location of tags, we + // need to determine if duplicate tags exist and if the tags are sorted. This iterates + // over the list comparing each tag in the sequence with each other. + for j := 0; j < commas-1; j++ { + // get the left and right tags + _, left := scanTo(buf[indices[j]:indices[j+1]-1], 0, '=') + _, right := scanTo(buf[indices[j+1]:indices[j+2]-1], 0, '=') + + // If left is greater than right, the tags are not sorted. We do not have to + // continue because the short path no longer works. + // If the tags are equal, then there are duplicate tags, and we should abort. + // If the tags are not sorted, this pass may not find duplicate tags and we + // need to do a more exhaustive search later. + if cmp := bytes.Compare(left, right); cmp > 0 { + sorted = false + break + } else if cmp == 0 { + return i, buf[start:i], fmt.Errorf("duplicate tags"), meaPos + } + } + + // If the tags are not sorted, then sort them. This sort is inline and + // uses the tag indices we created earlier. The actual buffer is not sorted, the + // indices are using the buffer for value comparison. After the indices are sorted, + // the buffer is reconstructed from the sorted indices. + if !sorted && commas > 0 { + // Get the measurement name for later + measurement := buf[start : indices[0]-1] + + // Sort the indices + indices := indices[:commas] + insertionSort(0, commas, buf, indices) + + // Create a new key using the measurement and sorted indices + b := make([]byte, len(buf[start:i])) + pos := copy(b, measurement) + for _, i := range indices { + b[pos] = ',' + pos++ + _, v := scanToSpaceOr(buf, i, ',') + pos += copy(b[pos:], v) + } + + // Check again for duplicate tags now that the tags are sorted. + for j := 0; j < commas-1; j++ { + // get the left and right tags + _, left := scanTo(buf[indices[j]:], 0, '=') + _, right := scanTo(buf[indices[j+1]:], 0, '=') + + // If the tags are equal, then there are duplicate tags, and we should abort. + // If the tags are not sorted, this pass may not find duplicate tags and we + // need to do a more exhaustive search later. + if bytes.Equal(left, right) { + return i, b, fmt.Errorf("duplicate tags"), meaPos + } + } + + return i, b, nil, meaPos + } + + return i, buf[start:i], nil, meaPos +} + +func scanMeasurement(buf []byte, i int) (int, int, error) { + // Check first byte of measurement, anything except a comma is fine. + // It can't be a space, since whitespace is stripped prior to this + // function call. + if i >= len(buf) || buf[i] == ',' { + return -1, i, fmt.Errorf("missing measurement") + } + + for { + i++ + if i >= len(buf) { + // cpu + return -1, i, fmt.Errorf("missing fields") + } + + if buf[i-1] == '\\' { + // Skip character (it's escaped). + continue + } + + // Unescaped comma; move onto scanning the tags. + if buf[i] == ',' { + return tagKeyState, i + 1, nil + } + + // Unescaped space; move onto scanning the fields. + if buf[i] == ' ' { + // cpu value=1.0 + return fieldsState, i, nil + } + } +} + +const ( + tagKeyState = iota + tagValueState + fieldsState +) + +func scanTags(buf []byte, i int, indices []int) (int, int, []int, error) { + var ( + err error + commas int + state = tagKeyState + ) + + for { + switch state { + case tagKeyState: + // Grow our indices slice if we have too many tags. + if commas >= len(indices) { + newIndics := make([]int, cap(indices)*2) + copy(newIndics, indices) + indices = newIndics + } + indices[commas] = i + commas++ + + i, err = scanTagsKey(buf, i) + state = tagValueState // tag value always follows a tag key + case tagValueState: + state, i, err = scanTagsValue(buf, i) + case fieldsState: + // Grow our indices slice if we had exactly enough tags to fill it + if commas >= len(indices) { + // The parser is in `fieldsState`, so there are no more + // tags. We only need 1 more entry in the slice to store + // the final entry. + newIndics := make([]int, cap(indices)+1) + copy(newIndics, indices) + indices = newIndics + } + indices[commas] = i + 1 + return i, commas, indices, nil + } + + if err != nil { + return i, commas, indices, err + } + } +} + +func scanTo(buf []byte, i int, stop byte) (int, []byte) { + start := i + for { + // reached the end of buf? + if i >= len(buf) { + break + } + + // Reached unescaped stop value? + if buf[i] == stop && (i == 0 || buf[i-1] != '\\') { + break + } + i++ + } + + return i, buf[start:i] +} + +func insertionSort(l, r int, buf []byte, indices []int) { + for i := l + 1; i < r; i++ { + for j := i; j > l && less(buf, indices, j, j-1); j-- { + indices[j], indices[j-1] = indices[j-1], indices[j] + } + } +} + +func less(buf []byte, indices []int, i, j int) bool { + // This grabs the tag names for i & j, it ignores the values + _, a := scanTo(buf, indices[i], '=') + _, b := scanTo(buf, indices[j], '=') + return bytes.Compare(a, b) < 0 +} + +func scanToSpaceOr(buf []byte, i int, stop byte) (int, []byte) { + start := i + if buf[i] == stop || buf[i] == ' ' { + return i, buf[start:i] + } + + for { + i++ + if buf[i-1] == '\\' { + continue + } + + // reached the end of buf? + if i >= len(buf) { + return i, buf[start:i] + } + + // reached end of block? + if buf[i] == stop || buf[i] == ' ' { + return i, buf[start:i] + } + } +} + +func scanTagsValue(buf []byte, i int) (int, int, error) { + // Tag value cannot be empty. + if i >= len(buf) || buf[i] == ',' || buf[i] == ' ' { + // cpu,tag={',', ' '} + return -1, i, fmt.Errorf("missing tag value") + } + + // Examine each character in the tag value until we hit an unescaped + // comma (move onto next tag key), an unescaped space (move onto + // fields), or we error out. + for { + i++ + if i >= len(buf) { + // cpu,tag=value + return -1, i, fmt.Errorf("missing fields") + } + + // An unescaped equals sign is an invalid tag value. + if buf[i] == '=' && buf[i-1] != '\\' { + // cpu,tag={'=', 'fo=o'} + return -1, i, fmt.Errorf("invalid tag format") + } + + if buf[i] == ',' && buf[i-1] != '\\' { + // cpu,tag=foo, + return tagKeyState, i + 1, nil + } + + // cpu,tag=foo value=1.0 + // cpu, tag=foo\= value=1.0 + if buf[i] == ' ' && buf[i-1] != '\\' { + return fieldsState, i, nil + } + } +} + +func scanTagsKey(buf []byte, i int) (int, error) { + // First character of the key. + if i >= len(buf) || buf[i] == ' ' || buf[i] == ',' || buf[i] == '=' { + // cpu,{'', ' ', ',', '='} + return i, fmt.Errorf("missing tag key") + } + + // Examine each character in the tag key until we hit an unescaped + // equals (the tag value), or we hit an error (i.e., unescaped + // space or comma). + for { + i++ + + // Either we reached the end of the buffer or we hit an + // unescaped comma or space. + if i >= len(buf) || + ((buf[i] == ' ' || buf[i] == ',') && buf[i-1] != '\\') { + // cpu,tag{'', ' ', ','} + return i, fmt.Errorf("missing tag value") + } + + if buf[i] == '=' && buf[i-1] != '\\' { + // cpu,tag= + return i + 1, nil + } + } +} + +const ( + // Values used to store the field key and measurement name as special internal tags. + FieldKeyTagKey = "\xff" + MeasurementTagKey = "\x00" + + // reserved tag keys which when present cause the point to be discarded + // and an error returned + reservedFieldTagKey = "_field" + reservedMeasurementTagKey = "_measurement" + reservedTimeTagKey = "time" +) + +var ( + // Predefined byte representations of special tag keys. + FieldKeyTagKeyBytes = []byte(FieldKeyTagKey) + MeasurementTagKeyBytes = []byte(MeasurementTagKey) + + // set of reserved tag keys which cannot be present when a point is being parsed. + reservedTagKeys = [][]byte{ + FieldKeyTagKeyBytes, + MeasurementTagKeyBytes, + []byte(reservedFieldTagKey), + []byte(reservedMeasurementTagKey), + []byte(reservedTimeTagKey), + } +) + +func parseTags(fb *flatbuffers.Builder, buf []byte) ([]flatbuffers.UOffsetT, []flatbuffers.UOffsetT) { + if len(buf) == 0 { + panic("unexpected has 0 tags") + } + + // Series keys can contain escaped commas, therefore the number of commas + // in a series key only gives an estimation of the upper bound on the number + // of tags. + var tgkoff []flatbuffers.UOffsetT + var tgvoff []flatbuffers.UOffsetT + var i int + walkTags(buf, func(key, value []byte) bool { + tgkoff = append(tgkoff, fb.CreateByteVector(key)) + tgvoff = append(tgvoff, fb.CreateByteVector(value)) + i++ + return true + }) + return tgkoff, tgvoff +} + +func walkTags(buf []byte, fn func(key, value []byte) bool) { + if len(buf) == 0 { + return + } + + pos, name := scanTo(buf, 0, ',') + + // it's an empty key, so there are no tags + if len(name) == 0 { + return + } + + hasEscape := bytes.IndexByte(buf, '\\') != -1 + i := pos + 1 + var key, value []byte + for { + if i >= len(buf) { + break + } + i, key = scanTo(buf, i, '=') + i, value = scanTagValue(buf, i+1) + + if len(value) == 0 { + continue + } + + if hasEscape { + if !fn(unescapeTag(key), unescapeTag(value)) { + return + } + } else { + if !fn(key, value) { + return + } + } + + i++ + } +} + +func scanTagValue(buf []byte, i int) (int, []byte) { + start := i + for { + if i >= len(buf) { + break + } + + if buf[i] == ',' && buf[i-1] != '\\' { + break + } + i++ + } + if i > len(buf) { + return i, nil + } + return i, buf[start:i] +} + +func unescapeTag(in []byte) []byte { + if bytes.IndexByte(in, '\\') == -1 { + return in + } + + for i := range tagEscapeCodes { + c := &tagEscapeCodes[i] + if bytes.IndexByte(in, c.k[0]) != -1 { + in = bytes.Replace(in, c.esc[:], c.k[:], -1) + } + } + return in +} + +var ( + measurementEscapeCodes = [...]escapeSet{ + {k: [1]byte{','}, esc: [2]byte{'\\', ','}}, + {k: [1]byte{' '}, esc: [2]byte{'\\', ' '}}, + } + + tagEscapeCodes = [...]escapeSet{ + {k: [1]byte{','}, esc: [2]byte{'\\', ','}}, + {k: [1]byte{' '}, esc: [2]byte{'\\', ' '}}, + {k: [1]byte{'='}, esc: [2]byte{'\\', '='}}, + } + + // ErrPointMustHaveAField is returned when operating on a point that does not have any fields. + ErrPointMustHaveAField = errors.New("point without fields is unsupported") + + // ErrInvalidNumber is returned when a number is expected but not provided. + ErrInvalidNumber = errors.New("invalid number") + + // ErrInvalidPoint is returned when a point cannot be parsed correctly. + ErrInvalidPoint = errors.New("point is invalid") + + // ErrInvalidKevValuePairs is returned when the number of key, value pairs + // is odd, indicating a missing value. + ErrInvalidKevValuePairs = errors.New("key/value pairs is an odd length") +) + +type escapeSet struct { + k [1]byte + esc [2]byte +} + +func scanFields(buf []byte, i int) (int, []byte, error) { + start := skipWhitespace(buf, i) + i = start + quoted := false + + // tracks how many '=' we've seen + equals := 0 + + // tracks how many commas we've seen + commas := 0 + + for { + // reached the end of buf? + if i >= len(buf) { + break + } + + // escaped characters? + if buf[i] == '\\' && i+1 < len(buf) { + i += 2 + continue + } + + // If the value is quoted, scan until we get to the end quote + // Only quote values in the field value since quotes are not significant + // in the field key + if buf[i] == '"' && equals > commas { + quoted = !quoted + i++ + continue + } + + // If we see an =, ensure that there is at least on char before and after it + if buf[i] == '=' && !quoted { + equals++ + + // check for "... =123" but allow "a\ =123" + if buf[i-1] == ' ' && buf[i-2] != '\\' { + return i, buf[start:i], fmt.Errorf("missing field key") + } + + // check for "...a=123,=456" but allow "a=123,a\,=456" + if buf[i-1] == ',' && buf[i-2] != '\\' { + return i, buf[start:i], fmt.Errorf("missing field key") + } + + // check for "... value=" + if i+1 >= len(buf) { + return i, buf[start:i], fmt.Errorf("missing field value") + } + + // check for "... value=,value2=..." + if buf[i+1] == ',' || buf[i+1] == ' ' { + return i, buf[start:i], fmt.Errorf("missing field value") + } + + if isNumeric(buf[i+1]) || buf[i+1] == '-' || buf[i+1] == 'N' || buf[i+1] == 'n' { + var err error + i, err = scanNumber(buf, i+1) + if err != nil { + return i, buf[start:i], err + } + continue + } + // If next byte is not a double-quote, the value must be a boolean + if buf[i+1] != '"' { + var err error + i, _, err = scanBoolean(buf, i+1) + if err != nil { + return i, buf[start:i], err + } + continue + } + } + + if buf[i] == ',' && !quoted { + commas++ + } + + // reached end of block? + if buf[i] == ' ' && !quoted { + break + } + i++ + } + + if quoted { + return i, buf[start:i], fmt.Errorf("unbalanced quotes") + } + + // check that all field sections had key and values (e.g. prevent "a=1,b" + if equals == 0 || commas != equals-1 { + return i, buf[start:i], fmt.Errorf("invalid field format") + } + + return i, buf[start:i], nil +} + +func isNumeric(b byte) bool { + return (b >= '0' && b <= '9') || b == '.' +} + +func scanNumber(buf []byte, i int) (int, error) { + start := i + var isInt, isUnsigned bool + + // Is negative number? + if i < len(buf) && buf[i] == '-' { + i++ + // There must be more characters now, as just '-' is illegal. + if i == len(buf) { + return i, ErrInvalidNumber + } + } + + // how many decimal points we've see + decimal := false + + // indicates the number is float in scientific notation + scientific := false + + for { + if i >= len(buf) { + break + } + + if buf[i] == ',' || buf[i] == ' ' { + break + } + + if buf[i] == 'i' && i > start && !(isInt || isUnsigned) { + isInt = true + i++ + continue + } else if buf[i] == 'u' && i > start && !(isInt || isUnsigned) { + isUnsigned = true + i++ + continue + } + + if buf[i] == '.' { + // Can't have more than 1 decimal (e.g. 1.1.1 should fail) + if decimal { + return i, ErrInvalidNumber + } + decimal = true + } + + // `e` is valid for floats but not as the first char + if i > start && (buf[i] == 'e' || buf[i] == 'E') { + scientific = true + i++ + continue + } + + // + and - are only valid at this point if they follow an e (scientific notation) + if (buf[i] == '+' || buf[i] == '-') && (buf[i-1] == 'e' || buf[i-1] == 'E') { + i++ + continue + } + + // NaN is an unsupported value + if i+2 < len(buf) && (buf[i] == 'N' || buf[i] == 'n') { + return i, ErrInvalidNumber + } + + if !isNumeric(buf[i]) { + return i, ErrInvalidNumber + } + i++ + } + + if (isInt || isUnsigned) && (decimal || scientific) { + return i, ErrInvalidNumber + } + + numericDigits := i - start + if isInt { + numericDigits-- + } + if decimal { + numericDigits-- + } + if buf[start] == '-' { + numericDigits-- + } + + if numericDigits == 0 { + return i, ErrInvalidNumber + } + + // It's more common that numbers will be within min/max range for their type but we need to prevent + // out or range numbers from being parsed successfully. This uses some simple heuristics to decide + // if we should parse the number to the actual type. It does not do it all the time because it incurs + // extra allocations and we end up converting the type again when writing points to disk. + if isInt { + // Make sure the last char is an 'i' for integers (e.g. 9i10 is not valid) + if buf[i-1] != 'i' { + return i, ErrInvalidNumber + } + // Parse the int to check bounds the number of digits could be larger than the max range + // We subtract 1 from the index to remove the `i` from our tests + if len(buf[start:i-1]) >= maxInt64Digits || len(buf[start:i-1]) >= minInt64Digits { + if _, err := parseIntBytes(buf[start:i-1], 10, 64); err != nil { + return i, fmt.Errorf("unable to parse integer %s: %s", buf[start:i-1], err) + } + } + } else if isUnsigned { + // Make sure the last char is a 'u' for unsigned + if buf[i-1] != 'u' { + return i, ErrInvalidNumber + } + // Make sure the first char is not a '-' for unsigned + if buf[start] == '-' { + return i, ErrInvalidNumber + } + // Parse the uint to check bounds the number of digits could be larger than the max range + // We subtract 1 from the index to remove the `u` from our tests + if len(buf[start:i-1]) >= maxUint64Digits { + if _, err := parseUintBytes(buf[start:i-1], 10, 64); err != nil { + return i, fmt.Errorf("unable to parse unsigned %s: %s", buf[start:i-1], err) + } + } + } else { + // Parse the float to check bounds if it's scientific or the number of digits could be larger than the max range + if scientific || len(buf[start:i]) >= maxFloat64Digits || len(buf[start:i]) >= minFloat64Digits { + if _, err := parseFloatBytes(buf[start:i], 64); err != nil { + return i, fmt.Errorf("invalid float") + } + } + } + + return i, nil +} + +func scanBoolean(buf []byte, i int) (int, []byte, error) { + start := i + + if i < len(buf) && (buf[i] != 't' && buf[i] != 'f' && buf[i] != 'T' && buf[i] != 'F') { + return i, buf[start:i], fmt.Errorf("invalid boolean") + } + + i++ + for { + if i >= len(buf) { + break + } + + if buf[i] == ',' || buf[i] == ' ' { + break + } + i++ + } + + // Single char bool (t, T, f, F) is ok + if i-start == 1 { + return i, buf[start:i], nil + } + + // length must be 4 for true or TRUE + if (buf[start] == 't' || buf[start] == 'T') && i-start != 4 { + return i, buf[start:i], fmt.Errorf("invalid boolean") + } + + // length must be 5 for false or FALSE + if (buf[start] == 'f' || buf[start] == 'F') && i-start != 5 { + return i, buf[start:i], fmt.Errorf("invalid boolean") + } + + // Otherwise + valid := false + switch buf[start] { + case 't': + valid = bytes.Equal(buf[start:i], []byte("true")) + case 'f': + valid = bytes.Equal(buf[start:i], []byte("false")) + case 'T': + valid = bytes.Equal(buf[start:i], []byte("TRUE")) || bytes.Equal(buf[start:i], []byte("True")) + case 'F': + valid = bytes.Equal(buf[start:i], []byte("FALSE")) || bytes.Equal(buf[start:i], []byte("False")) + } + + if !valid { + return i, buf[start:i], fmt.Errorf("invalid boolean") + } + + return i, buf[start:i], nil + +} + +const ( + // the number of characters for the largest possible int64 (9223372036854775807) + maxInt64Digits = 19 + + // the number of characters for the smallest possible int64 (-9223372036854775808) + minInt64Digits = 20 + + // the number of characters for the largest possible uint64 (18446744073709551615) + maxUint64Digits = 20 + + // the number of characters required for the largest float64 before a range check + // would occur during parsing + maxFloat64Digits = 25 + + // the number of characters required for smallest float64 before a range check occur + // would occur during parsing + minFloat64Digits = 27 +) + +// parseIntBytes is a zero-alloc wrapper around strconv.ParseInt. +func parseIntBytes(b []byte, base int, bitSize int) (i int64, err error) { + s := unsafeBytesToString(b) + return strconv.ParseInt(s, base, bitSize) +} + +// parseUintBytes is a zero-alloc wrapper around strconv.ParseUint. +func parseUintBytes(b []byte, base int, bitSize int) (i uint64, err error) { + s := unsafeBytesToString(b) + return strconv.ParseUint(s, base, bitSize) +} + +// parseFloatBytes is a zero-alloc wrapper around strconv.ParseFloat. +func parseFloatBytes(b []byte, bitSize int) (float64, error) { + s := unsafeBytesToString(b) + return strconv.ParseFloat(s, bitSize) +} + +// parseBoolBytes is a zero-alloc wrapper around strconv.ParseBool. +func parseBoolBytes(b []byte) (bool, error) { + return strconv.ParseBool(unsafeBytesToString(b)) +} + +// unsafeBytesToString converts a []byte to a string without a heap allocation. +func unsafeBytesToString(in []byte) string { + return *(*string)(unsafe.Pointer(&in)) +} + +// is stopped. The values are the raw byte slices and not the converted types. +func walkFields(buf []byte, fn func(key, value []byte) bool) error { + var i int + var key, val []byte + for len(buf) > 0 { + i, key = scanTo(buf, 0, '=') + if i > len(buf)-2 { + return fmt.Errorf("invalid value: field-key=%s", key) + } + buf = buf[i+1:] + i, val = scanFieldValue(buf, 0) + buf = buf[i:] + if !fn(key, val) { + break + } + + // slice off comma + if len(buf) > 0 { + buf = buf[1:] + } + } + return nil +} + +func scanFieldValue(buf []byte, i int) (int, []byte) { + start := i + quoted := false + for i < len(buf) { + // Only escape char for a field value is a double-quote and backslash + if buf[i] == '\\' && i+1 < len(buf) && (buf[i+1] == '"' || buf[i+1] == '\\') { + i += 2 + continue + } + + // Quoted value? (e.g. string) + if buf[i] == '"' { + i++ + quoted = !quoted + continue + } + + if buf[i] == ',' && !quoted { + break + } + i++ + } + return i, buf[start:i] +} + +func scanTime(buf []byte, i int) (int, []byte, error) { + start := skipWhitespace(buf, i) + i = start + + for { + // reached the end of buf? + if i >= len(buf) { + break + } + + // Reached end of block or trailing whitespace? + if buf[i] == '\n' || buf[i] == ' ' { + break + } + + // Handle negative timestamps + if i == start && buf[i] == '-' { + i++ + continue + } + + // Timestamps should be integers, make sure they are so we don't need + // to actually parse the timestamp until needed. + if buf[i] < '0' || buf[i] > '9' { + return i, buf[start:i], fmt.Errorf("bad timestamp") + } + i++ + } + return i, buf[start:i], nil +} diff --git a/cmd/load_cnosdb/main.go b/cmd/load_cnosdb/main.go index b269d0c..8613341 100644 --- a/cmd/load_cnosdb/main.go +++ b/cmd/load_cnosdb/main.go @@ -12,7 +12,7 @@ import ( "strings" "sync" "time" - + "github.com/blagojts/viper" "github.com/cnosdb/tsdb-comparisons/internal/utils" "github.com/cnosdb/tsdb-comparisons/load" @@ -57,29 +57,29 @@ func init() { config.AddToFlagSet(pflag.CommandLine) target.TargetSpecificFlags("", pflag.CommandLine) var csvDaemonURLs string - + pflag.Parse() - + err := utils.SetupConfigFile() - + if err != nil { panic(fmt.Errorf("fatal error config file: %s", err)) } - + if err := viper.Unmarshal(&config); err != nil { panic(fmt.Errorf("unable to decode config: %s", err)) } - + csvDaemonURLs = viper.GetString("urls") replicationFactor = viper.GetInt("replication-factor") consistency = viper.GetString("consistency") backoff = viper.GetDuration("backoff") useGzip = viper.GetBool("gzip") - + if _, ok := consistencyChoices[consistency]; !ok { log.Fatalf("invalid consistency settings") } - + daemonURLs = strings.Split(csvDaemonURLs, ",") if len(daemonURLs) == 0 { log.Fatal("missing 'urls' flag") @@ -116,6 +116,6 @@ func main() { return bytes.NewBuffer(make([]byte, 0, 4*1024*1024)) }, } - + loader.RunBenchmark(&benchmark{}) } diff --git a/cmd/load_cnosdb/models/ColumnKey.go b/cmd/load_cnosdb/models/ColumnKey.go new file mode 100644 index 0000000..392f9b3 --- /dev/null +++ b/cmd/load_cnosdb/models/ColumnKey.go @@ -0,0 +1,41 @@ +// Code generated by the FlatBuffers compiler. DO NOT EDIT. + +package models + +import ( + flatbuffers "github.com/google/flatbuffers/go" +) + +type ColumnKey struct { + _tab flatbuffers.Struct +} + +func (rcv *ColumnKey) Init(buf []byte, i flatbuffers.UOffsetT) { + rcv._tab.Bytes = buf + rcv._tab.Pos = i +} + +func (rcv *ColumnKey) Table() flatbuffers.Table { + return rcv._tab.Table +} + +func (rcv *ColumnKey) SeriesId() uint64 { + return rcv._tab.GetUint64(rcv._tab.Pos + flatbuffers.UOffsetT(0)) +} +func (rcv *ColumnKey) MutateSeriesId(n uint64) bool { + return rcv._tab.MutateUint64(rcv._tab.Pos+flatbuffers.UOffsetT(0), n) +} + +func (rcv *ColumnKey) FieldId() uint64 { + return rcv._tab.GetUint64(rcv._tab.Pos + flatbuffers.UOffsetT(8)) +} +func (rcv *ColumnKey) MutateFieldId(n uint64) bool { + return rcv._tab.MutateUint64(rcv._tab.Pos+flatbuffers.UOffsetT(8), n) +} + +func CreateColumnKey(builder *flatbuffers.Builder, seriesId uint64, fieldId uint64) flatbuffers.UOffsetT { + builder.Prep(8, 16) + builder.PrependUint64(fieldId) + builder.PrependUint64(seriesId) + return builder.Offset() +} diff --git a/cmd/load_cnosdb/models/ColumnKeys.go b/cmd/load_cnosdb/models/ColumnKeys.go new file mode 100644 index 0000000..e718867 --- /dev/null +++ b/cmd/load_cnosdb/models/ColumnKeys.go @@ -0,0 +1,66 @@ +// Code generated by the FlatBuffers compiler. DO NOT EDIT. + +package models + +import ( + flatbuffers "github.com/google/flatbuffers/go" +) + +type ColumnKeys struct { + _tab flatbuffers.Table +} + +func GetRootAsColumnKeys(buf []byte, offset flatbuffers.UOffsetT) *ColumnKeys { + n := flatbuffers.GetUOffsetT(buf[offset:]) + x := &ColumnKeys{} + x.Init(buf, n+offset) + return x +} + +func GetSizePrefixedRootAsColumnKeys(buf []byte, offset flatbuffers.UOffsetT) *ColumnKeys { + n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:]) + x := &ColumnKeys{} + x.Init(buf, n+offset+flatbuffers.SizeUint32) + return x +} + +func (rcv *ColumnKeys) Init(buf []byte, i flatbuffers.UOffsetT) { + rcv._tab.Bytes = buf + rcv._tab.Pos = i +} + +func (rcv *ColumnKeys) Table() flatbuffers.Table { + return rcv._tab +} + +func (rcv *ColumnKeys) ColumnKeys(obj *ColumnKey, j int) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + x := rcv._tab.Vector(o) + x += flatbuffers.UOffsetT(j) * 16 + obj.Init(rcv._tab.Bytes, x) + return true + } + return false +} + +func (rcv *ColumnKeys) ColumnKeysLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +func ColumnKeysStart(builder *flatbuffers.Builder) { + builder.StartObject(1) +} +func ColumnKeysAddColumnKeys(builder *flatbuffers.Builder, columnKeys flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(columnKeys), 0) +} +func ColumnKeysStartColumnKeysVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(16, numElems, 8) +} +func ColumnKeysEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { + return builder.EndObject() +} diff --git a/cmd/load_cnosdb/models/ColumnKeysWithRange.go b/cmd/load_cnosdb/models/ColumnKeysWithRange.go new file mode 100644 index 0000000..931e11b --- /dev/null +++ b/cmd/load_cnosdb/models/ColumnKeysWithRange.go @@ -0,0 +1,96 @@ +// Code generated by the FlatBuffers compiler. DO NOT EDIT. + +package models + +import ( + flatbuffers "github.com/google/flatbuffers/go" +) + +type ColumnKeysWithRange struct { + _tab flatbuffers.Table +} + +func GetRootAsColumnKeysWithRange(buf []byte, offset flatbuffers.UOffsetT) *ColumnKeysWithRange { + n := flatbuffers.GetUOffsetT(buf[offset:]) + x := &ColumnKeysWithRange{} + x.Init(buf, n+offset) + return x +} + +func GetSizePrefixedRootAsColumnKeysWithRange(buf []byte, offset flatbuffers.UOffsetT) *ColumnKeysWithRange { + n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:]) + x := &ColumnKeysWithRange{} + x.Init(buf, n+offset+flatbuffers.SizeUint32) + return x +} + +func (rcv *ColumnKeysWithRange) Init(buf []byte, i flatbuffers.UOffsetT) { + rcv._tab.Bytes = buf + rcv._tab.Pos = i +} + +func (rcv *ColumnKeysWithRange) Table() flatbuffers.Table { + return rcv._tab +} + +func (rcv *ColumnKeysWithRange) ColumnKeys(obj *ColumnKey, j int) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + x := rcv._tab.Vector(o) + x += flatbuffers.UOffsetT(j) * 16 + obj.Init(rcv._tab.Bytes, x) + return true + } + return false +} + +func (rcv *ColumnKeysWithRange) ColumnKeysLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +func (rcv *ColumnKeysWithRange) Min() int64 { + o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) + if o != 0 { + return rcv._tab.GetInt64(o + rcv._tab.Pos) + } + return 0 +} + +func (rcv *ColumnKeysWithRange) MutateMin(n int64) bool { + return rcv._tab.MutateInt64Slot(6, n) +} + +func (rcv *ColumnKeysWithRange) Max() int64 { + o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) + if o != 0 { + return rcv._tab.GetInt64(o + rcv._tab.Pos) + } + return 0 +} + +func (rcv *ColumnKeysWithRange) MutateMax(n int64) bool { + return rcv._tab.MutateInt64Slot(8, n) +} + +func ColumnKeysWithRangeStart(builder *flatbuffers.Builder) { + builder.StartObject(3) +} +func ColumnKeysWithRangeAddColumnKeys(builder *flatbuffers.Builder, columnKeys flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(columnKeys), 0) +} +func ColumnKeysWithRangeStartColumnKeysVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(16, numElems, 8) +} +func ColumnKeysWithRangeAddMin(builder *flatbuffers.Builder, min int64) { + builder.PrependInt64Slot(1, min, 0) +} +func ColumnKeysWithRangeAddMax(builder *flatbuffers.Builder, max int64) { + builder.PrependInt64Slot(2, max, 0) +} +func ColumnKeysWithRangeEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { + return builder.EndObject() +} diff --git a/cmd/load_cnosdb/models/Field.go b/cmd/load_cnosdb/models/Field.go new file mode 100644 index 0000000..ccb567b --- /dev/null +++ b/cmd/load_cnosdb/models/Field.go @@ -0,0 +1,136 @@ +// Code generated by the FlatBuffers compiler. DO NOT EDIT. + +package models + +import ( + flatbuffers "github.com/google/flatbuffers/go" +) + +type Field struct { + _tab flatbuffers.Table +} + +func GetRootAsField(buf []byte, offset flatbuffers.UOffsetT) *Field { + n := flatbuffers.GetUOffsetT(buf[offset:]) + x := &Field{} + x.Init(buf, n+offset) + return x +} + +func GetSizePrefixedRootAsField(buf []byte, offset flatbuffers.UOffsetT) *Field { + n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:]) + x := &Field{} + x.Init(buf, n+offset+flatbuffers.SizeUint32) + return x +} + +func (rcv *Field) Init(buf []byte, i flatbuffers.UOffsetT) { + rcv._tab.Bytes = buf + rcv._tab.Pos = i +} + +func (rcv *Field) Table() flatbuffers.Table { + return rcv._tab +} + +func (rcv *Field) Name(j int) byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1)) + } + return 0 +} + +func (rcv *Field) NameLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +func (rcv *Field) NameBytes() []byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + return rcv._tab.ByteVector(o + rcv._tab.Pos) + } + return nil +} + +func (rcv *Field) MutateName(j int, n byte) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.MutateByte(a+flatbuffers.UOffsetT(j*1), n) + } + return false +} + +func (rcv *Field) Type() FieldType { + o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) + if o != 0 { + return FieldType(rcv._tab.GetInt32(o + rcv._tab.Pos)) + } + return 0 +} + +func (rcv *Field) MutateType(n FieldType) bool { + return rcv._tab.MutateInt32Slot(6, int32(n)) +} + +func (rcv *Field) Value(j int) byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1)) + } + return 0 +} + +func (rcv *Field) ValueLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +func (rcv *Field) ValueBytes() []byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) + if o != 0 { + return rcv._tab.ByteVector(o + rcv._tab.Pos) + } + return nil +} + +func (rcv *Field) MutateValue(j int, n byte) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.MutateByte(a+flatbuffers.UOffsetT(j*1), n) + } + return false +} + +func FieldStart(builder *flatbuffers.Builder) { + builder.StartObject(3) +} +func FieldAddName(builder *flatbuffers.Builder, name flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(name), 0) +} +func FieldStartNameVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(1, numElems, 1) +} +func FieldAddType(builder *flatbuffers.Builder, type_ FieldType) { + builder.PrependInt32Slot(1, int32(type_), 0) +} +func FieldAddValue(builder *flatbuffers.Builder, value flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(2, flatbuffers.UOffsetT(value), 0) +} +func FieldStartValueVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(1, numElems, 1) +} +func FieldEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { + return builder.EndObject() +} diff --git a/cmd/load_cnosdb/models/FieldType.go b/cmd/load_cnosdb/models/FieldType.go new file mode 100644 index 0000000..e50d62f --- /dev/null +++ b/cmd/load_cnosdb/models/FieldType.go @@ -0,0 +1,41 @@ +// Code generated by the FlatBuffers compiler. DO NOT EDIT. + +package models + +import "strconv" + +type FieldType int32 + +const ( + FieldTypeUnknown FieldType = -1 + FieldTypeFloat FieldType = 0 + FieldTypeInteger FieldType = 1 + FieldTypeUnsigned FieldType = 2 + FieldTypeBoolean FieldType = 3 + FieldTypeString FieldType = 4 +) + +var EnumNamesFieldType = map[FieldType]string{ + FieldTypeUnknown: "Unknown", + FieldTypeFloat: "Float", + FieldTypeInteger: "Integer", + FieldTypeUnsigned: "Unsigned", + FieldTypeBoolean: "Boolean", + FieldTypeString: "String", +} + +var EnumValuesFieldType = map[string]FieldType{ + "Unknown": FieldTypeUnknown, + "Float": FieldTypeFloat, + "Integer": FieldTypeInteger, + "Unsigned": FieldTypeUnsigned, + "Boolean": FieldTypeBoolean, + "String": FieldTypeString, +} + +func (v FieldType) String() string { + if s, ok := EnumNamesFieldType[v]; ok { + return s + } + return "FieldType(" + strconv.FormatInt(int64(v), 10) + ")" +} diff --git a/cmd/load_cnosdb/models/PingBody.go b/cmd/load_cnosdb/models/PingBody.go new file mode 100644 index 0000000..4c2e040 --- /dev/null +++ b/cmd/load_cnosdb/models/PingBody.go @@ -0,0 +1,81 @@ +// Code generated by the FlatBuffers compiler. DO NOT EDIT. + +package models + +import ( + flatbuffers "github.com/google/flatbuffers/go" +) + +type PingBody struct { + _tab flatbuffers.Table +} + +func GetRootAsPingBody(buf []byte, offset flatbuffers.UOffsetT) *PingBody { + n := flatbuffers.GetUOffsetT(buf[offset:]) + x := &PingBody{} + x.Init(buf, n+offset) + return x +} + +func GetSizePrefixedRootAsPingBody(buf []byte, offset flatbuffers.UOffsetT) *PingBody { + n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:]) + x := &PingBody{} + x.Init(buf, n+offset+flatbuffers.SizeUint32) + return x +} + +func (rcv *PingBody) Init(buf []byte, i flatbuffers.UOffsetT) { + rcv._tab.Bytes = buf + rcv._tab.Pos = i +} + +func (rcv *PingBody) Table() flatbuffers.Table { + return rcv._tab +} + +func (rcv *PingBody) Payload(j int) byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1)) + } + return 0 +} + +func (rcv *PingBody) PayloadLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +func (rcv *PingBody) PayloadBytes() []byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + return rcv._tab.ByteVector(o + rcv._tab.Pos) + } + return nil +} + +func (rcv *PingBody) MutatePayload(j int, n byte) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.MutateByte(a+flatbuffers.UOffsetT(j*1), n) + } + return false +} + +func PingBodyStart(builder *flatbuffers.Builder) { + builder.StartObject(1) +} +func PingBodyAddPayload(builder *flatbuffers.Builder, payload flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(payload), 0) +} +func PingBodyStartPayloadVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(1, numElems, 1) +} +func PingBodyEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { + return builder.EndObject() +} diff --git a/cmd/load_cnosdb/models/Point.go b/cmd/load_cnosdb/models/Point.go new file mode 100644 index 0000000..c1feb0d --- /dev/null +++ b/cmd/load_cnosdb/models/Point.go @@ -0,0 +1,188 @@ +// Code generated by the FlatBuffers compiler. DO NOT EDIT. + +package models + +import ( + flatbuffers "github.com/google/flatbuffers/go" +) + +type Point struct { + _tab flatbuffers.Table +} + +func GetRootAsPoint(buf []byte, offset flatbuffers.UOffsetT) *Point { + n := flatbuffers.GetUOffsetT(buf[offset:]) + x := &Point{} + x.Init(buf, n+offset) + return x +} + +func GetSizePrefixedRootAsPoint(buf []byte, offset flatbuffers.UOffsetT) *Point { + n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:]) + x := &Point{} + x.Init(buf, n+offset+flatbuffers.SizeUint32) + return x +} + +func (rcv *Point) Init(buf []byte, i flatbuffers.UOffsetT) { + rcv._tab.Bytes = buf + rcv._tab.Pos = i +} + +func (rcv *Point) Table() flatbuffers.Table { + return rcv._tab +} + +func (rcv *Point) Db(j int) byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1)) + } + return 0 +} + +func (rcv *Point) DbLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +func (rcv *Point) DbBytes() []byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + return rcv._tab.ByteVector(o + rcv._tab.Pos) + } + return nil +} + +func (rcv *Point) MutateDb(j int, n byte) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.MutateByte(a+flatbuffers.UOffsetT(j*1), n) + } + return false +} + +//func (rcv *Point) Table(j int) byte { +// o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) +// if o != 0 { +// a := rcv._tab.Vector(o) +// return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1)) +// } +// return 0 +//} + +func (rcv *Point) TableLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +func (rcv *Point) TableBytes() []byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) + if o != 0 { + return rcv._tab.ByteVector(o + rcv._tab.Pos) + } + return nil +} + +func (rcv *Point) MutateTable(j int, n byte) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.MutateByte(a+flatbuffers.UOffsetT(j*1), n) + } + return false +} + +func (rcv *Point) Tags(obj *Tag, j int) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) + if o != 0 { + x := rcv._tab.Vector(o) + x += flatbuffers.UOffsetT(j) * 4 + x = rcv._tab.Indirect(x) + obj.Init(rcv._tab.Bytes, x) + return true + } + return false +} + +func (rcv *Point) TagsLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +func (rcv *Point) Fields(obj *Field, j int) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(10)) + if o != 0 { + x := rcv._tab.Vector(o) + x += flatbuffers.UOffsetT(j) * 4 + x = rcv._tab.Indirect(x) + obj.Init(rcv._tab.Bytes, x) + return true + } + return false +} + +func (rcv *Point) FieldsLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(10)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +func (rcv *Point) Timestamp() int64 { + o := flatbuffers.UOffsetT(rcv._tab.Offset(12)) + if o != 0 { + return rcv._tab.GetInt64(o + rcv._tab.Pos) + } + return 0 +} + +func (rcv *Point) MutateTimestamp(n int64) bool { + return rcv._tab.MutateInt64Slot(12, n) +} + +func PointStart(builder *flatbuffers.Builder) { + builder.StartObject(5) +} +func PointAddDb(builder *flatbuffers.Builder, db flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(db), 0) +} +func PointStartDbVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(1, numElems, 1) +} +func PointAddTable(builder *flatbuffers.Builder, table flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(table), 0) +} +func PointStartTableVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(1, numElems, 1) +} +func PointAddTags(builder *flatbuffers.Builder, tags flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(2, flatbuffers.UOffsetT(tags), 0) +} +func PointStartTagsVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(4, numElems, 4) +} +func PointAddFields(builder *flatbuffers.Builder, fields flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(3, flatbuffers.UOffsetT(fields), 0) +} +func PointStartFieldsVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(4, numElems, 4) +} +func PointAddTimestamp(builder *flatbuffers.Builder, timestamp int64) { + builder.PrependInt64Slot(4, timestamp, 0) +} +func PointEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { + return builder.EndObject() +} diff --git a/cmd/load_cnosdb/models/Points.go b/cmd/load_cnosdb/models/Points.go new file mode 100644 index 0000000..02ea046 --- /dev/null +++ b/cmd/load_cnosdb/models/Points.go @@ -0,0 +1,107 @@ +// Code generated by the FlatBuffers compiler. DO NOT EDIT. + +package models + +import ( + flatbuffers "github.com/google/flatbuffers/go" +) + +type Points struct { + _tab flatbuffers.Table +} + +func GetRootAsPoints(buf []byte, offset flatbuffers.UOffsetT) *Points { + n := flatbuffers.GetUOffsetT(buf[offset:]) + x := &Points{} + x.Init(buf, n+offset) + return x +} + +func GetSizePrefixedRootAsPoints(buf []byte, offset flatbuffers.UOffsetT) *Points { + n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:]) + x := &Points{} + x.Init(buf, n+offset+flatbuffers.SizeUint32) + return x +} + +func (rcv *Points) Init(buf []byte, i flatbuffers.UOffsetT) { + rcv._tab.Bytes = buf + rcv._tab.Pos = i +} + +func (rcv *Points) Table() flatbuffers.Table { + return rcv._tab +} + +func (rcv *Points) Database(j int) byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1)) + } + return 0 +} + +func (rcv *Points) DatabaseLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +func (rcv *Points) DatabaseBytes() []byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + return rcv._tab.ByteVector(o + rcv._tab.Pos) + } + return nil +} + +func (rcv *Points) MutateDatabase(j int, n byte) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.MutateByte(a+flatbuffers.UOffsetT(j*1), n) + } + return false +} + +func (rcv *Points) Points(obj *Point, j int) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) + if o != 0 { + x := rcv._tab.Vector(o) + x += flatbuffers.UOffsetT(j) * 4 + x = rcv._tab.Indirect(x) + obj.Init(rcv._tab.Bytes, x) + return true + } + return false +} + +func (rcv *Points) PointsLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +func PointsStart(builder *flatbuffers.Builder) { + builder.StartObject(2) +} +func PointsAddDatabase(builder *flatbuffers.Builder, database flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(database), 0) +} +func PointsStartDatabaseVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(1, numElems, 1) +} +func PointsAddPoints(builder *flatbuffers.Builder, points flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(points), 0) +} +func PointsStartPointsVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(4, numElems, 4) +} +func PointsEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { + return builder.EndObject() +} diff --git a/cmd/load_cnosdb/models/Row.go b/cmd/load_cnosdb/models/Row.go new file mode 100644 index 0000000..af4737e --- /dev/null +++ b/cmd/load_cnosdb/models/Row.go @@ -0,0 +1,83 @@ +// Code generated by the FlatBuffers compiler. DO NOT EDIT. + +package models + +import ( + flatbuffers "github.com/google/flatbuffers/go" +) + +type Row struct { + _tab flatbuffers.Table +} + +func GetRootAsRow(buf []byte, offset flatbuffers.UOffsetT) *Row { + n := flatbuffers.GetUOffsetT(buf[offset:]) + x := &Row{} + x.Init(buf, n+offset) + return x +} + +func GetSizePrefixedRootAsRow(buf []byte, offset flatbuffers.UOffsetT) *Row { + n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:]) + x := &Row{} + x.Init(buf, n+offset+flatbuffers.SizeUint32) + return x +} + +func (rcv *Row) Init(buf []byte, i flatbuffers.UOffsetT) { + rcv._tab.Bytes = buf + rcv._tab.Pos = i +} + +func (rcv *Row) Table() flatbuffers.Table { + return rcv._tab +} + +func (rcv *Row) Key(obj *RowKey) *RowKey { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + x := o + rcv._tab.Pos + if obj == nil { + obj = new(RowKey) + } + obj.Init(rcv._tab.Bytes, x) + return obj + } + return nil +} + +func (rcv *Row) Fields(obj *RowField, j int) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) + if o != 0 { + x := rcv._tab.Vector(o) + x += flatbuffers.UOffsetT(j) * 4 + x = rcv._tab.Indirect(x) + obj.Init(rcv._tab.Bytes, x) + return true + } + return false +} + +func (rcv *Row) FieldsLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +func RowStart(builder *flatbuffers.Builder) { + builder.StartObject(2) +} +func RowAddKey(builder *flatbuffers.Builder, key flatbuffers.UOffsetT) { + builder.PrependStructSlot(0, flatbuffers.UOffsetT(key), 0) +} +func RowAddFields(builder *flatbuffers.Builder, fields flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(fields), 0) +} +func RowStartFieldsVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(4, numElems, 4) +} +func RowEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { + return builder.EndObject() +} diff --git a/cmd/load_cnosdb/models/RowField.go b/cmd/load_cnosdb/models/RowField.go new file mode 100644 index 0000000..f2de44e --- /dev/null +++ b/cmd/load_cnosdb/models/RowField.go @@ -0,0 +1,111 @@ +// Code generated by the FlatBuffers compiler. DO NOT EDIT. + +package models + +import ( + flatbuffers "github.com/google/flatbuffers/go" +) + +type RowField struct { + _tab flatbuffers.Table +} + +func GetRootAsRowField(buf []byte, offset flatbuffers.UOffsetT) *RowField { + n := flatbuffers.GetUOffsetT(buf[offset:]) + x := &RowField{} + x.Init(buf, n+offset) + return x +} + +func GetSizePrefixedRootAsRowField(buf []byte, offset flatbuffers.UOffsetT) *RowField { + n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:]) + x := &RowField{} + x.Init(buf, n+offset+flatbuffers.SizeUint32) + return x +} + +func (rcv *RowField) Init(buf []byte, i flatbuffers.UOffsetT) { + rcv._tab.Bytes = buf + rcv._tab.Pos = i +} + +func (rcv *RowField) Table() flatbuffers.Table { + return rcv._tab +} + +func (rcv *RowField) FieldId() uint64 { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + return rcv._tab.GetUint64(o + rcv._tab.Pos) + } + return 0 +} + +func (rcv *RowField) MutateFieldId(n uint64) bool { + return rcv._tab.MutateUint64Slot(4, n) +} + +func (rcv *RowField) Type() FieldType { + o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) + if o != 0 { + return FieldType(rcv._tab.GetInt32(o + rcv._tab.Pos)) + } + return 0 +} + +func (rcv *RowField) MutateType(n FieldType) bool { + return rcv._tab.MutateInt32Slot(6, int32(n)) +} + +func (rcv *RowField) Value(j int) byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1)) + } + return 0 +} + +func (rcv *RowField) ValueLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +func (rcv *RowField) ValueBytes() []byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) + if o != 0 { + return rcv._tab.ByteVector(o + rcv._tab.Pos) + } + return nil +} + +func (rcv *RowField) MutateValue(j int, n byte) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.MutateByte(a+flatbuffers.UOffsetT(j*1), n) + } + return false +} + +func RowFieldStart(builder *flatbuffers.Builder) { + builder.StartObject(3) +} +func RowFieldAddFieldId(builder *flatbuffers.Builder, fieldId uint64) { + builder.PrependUint64Slot(0, fieldId, 0) +} +func RowFieldAddType(builder *flatbuffers.Builder, type_ FieldType) { + builder.PrependInt32Slot(1, int32(type_), 0) +} +func RowFieldAddValue(builder *flatbuffers.Builder, value flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(2, flatbuffers.UOffsetT(value), 0) +} +func RowFieldStartValueVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(1, numElems, 1) +} +func RowFieldEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { + return builder.EndObject() +} diff --git a/cmd/load_cnosdb/models/RowKey.go b/cmd/load_cnosdb/models/RowKey.go new file mode 100644 index 0000000..52ecef1 --- /dev/null +++ b/cmd/load_cnosdb/models/RowKey.go @@ -0,0 +1,41 @@ +// Code generated by the FlatBuffers compiler. DO NOT EDIT. + +package models + +import ( + flatbuffers "github.com/google/flatbuffers/go" +) + +type RowKey struct { + _tab flatbuffers.Struct +} + +func (rcv *RowKey) Init(buf []byte, i flatbuffers.UOffsetT) { + rcv._tab.Bytes = buf + rcv._tab.Pos = i +} + +func (rcv *RowKey) Table() flatbuffers.Table { + return rcv._tab.Table +} + +func (rcv *RowKey) SeriesId() uint64 { + return rcv._tab.GetUint64(rcv._tab.Pos + flatbuffers.UOffsetT(0)) +} +func (rcv *RowKey) MutateSeriesId(n uint64) bool { + return rcv._tab.MutateUint64(rcv._tab.Pos+flatbuffers.UOffsetT(0), n) +} + +func (rcv *RowKey) Timestamp() uint64 { + return rcv._tab.GetUint64(rcv._tab.Pos + flatbuffers.UOffsetT(8)) +} +func (rcv *RowKey) MutateTimestamp(n uint64) bool { + return rcv._tab.MutateUint64(rcv._tab.Pos+flatbuffers.UOffsetT(8), n) +} + +func CreateRowKey(builder *flatbuffers.Builder, seriesId uint64, timestamp uint64) flatbuffers.UOffsetT { + builder.Prep(8, 16) + builder.PrependUint64(timestamp) + builder.PrependUint64(seriesId) + return builder.Offset() +} diff --git a/cmd/load_cnosdb/models/Rows.go b/cmd/load_cnosdb/models/Rows.go new file mode 100644 index 0000000..7e1280f --- /dev/null +++ b/cmd/load_cnosdb/models/Rows.go @@ -0,0 +1,67 @@ +// Code generated by the FlatBuffers compiler. DO NOT EDIT. + +package models + +import ( + flatbuffers "github.com/google/flatbuffers/go" +) + +type Rows struct { + _tab flatbuffers.Table +} + +func GetRootAsRows(buf []byte, offset flatbuffers.UOffsetT) *Rows { + n := flatbuffers.GetUOffsetT(buf[offset:]) + x := &Rows{} + x.Init(buf, n+offset) + return x +} + +func GetSizePrefixedRootAsRows(buf []byte, offset flatbuffers.UOffsetT) *Rows { + n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:]) + x := &Rows{} + x.Init(buf, n+offset+flatbuffers.SizeUint32) + return x +} + +func (rcv *Rows) Init(buf []byte, i flatbuffers.UOffsetT) { + rcv._tab.Bytes = buf + rcv._tab.Pos = i +} + +func (rcv *Rows) Table() flatbuffers.Table { + return rcv._tab +} + +func (rcv *Rows) Rows(obj *Row, j int) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + x := rcv._tab.Vector(o) + x += flatbuffers.UOffsetT(j) * 4 + x = rcv._tab.Indirect(x) + obj.Init(rcv._tab.Bytes, x) + return true + } + return false +} + +func (rcv *Rows) RowsLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +func RowsStart(builder *flatbuffers.Builder) { + builder.StartObject(1) +} +func RowsAddRows(builder *flatbuffers.Builder, rows flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(rows), 0) +} +func RowsStartRowsVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(4, numElems, 4) +} +func RowsEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { + return builder.EndObject() +} diff --git a/cmd/load_cnosdb/models/Tag.go b/cmd/load_cnosdb/models/Tag.go new file mode 100644 index 0000000..285269e --- /dev/null +++ b/cmd/load_cnosdb/models/Tag.go @@ -0,0 +1,121 @@ +// Code generated by the FlatBuffers compiler. DO NOT EDIT. + +package models + +import ( + flatbuffers "github.com/google/flatbuffers/go" +) + +type Tag struct { + _tab flatbuffers.Table +} + +func GetRootAsTag(buf []byte, offset flatbuffers.UOffsetT) *Tag { + n := flatbuffers.GetUOffsetT(buf[offset:]) + x := &Tag{} + x.Init(buf, n+offset) + return x +} + +func GetSizePrefixedRootAsTag(buf []byte, offset flatbuffers.UOffsetT) *Tag { + n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:]) + x := &Tag{} + x.Init(buf, n+offset+flatbuffers.SizeUint32) + return x +} + +func (rcv *Tag) Init(buf []byte, i flatbuffers.UOffsetT) { + rcv._tab.Bytes = buf + rcv._tab.Pos = i +} + +func (rcv *Tag) Table() flatbuffers.Table { + return rcv._tab +} + +func (rcv *Tag) Key(j int) byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1)) + } + return 0 +} + +func (rcv *Tag) KeyLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +func (rcv *Tag) KeyBytes() []byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + return rcv._tab.ByteVector(o + rcv._tab.Pos) + } + return nil +} + +func (rcv *Tag) MutateKey(j int, n byte) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.MutateByte(a+flatbuffers.UOffsetT(j*1), n) + } + return false +} + +func (rcv *Tag) Value(j int) byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1)) + } + return 0 +} + +func (rcv *Tag) ValueLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +func (rcv *Tag) ValueBytes() []byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) + if o != 0 { + return rcv._tab.ByteVector(o + rcv._tab.Pos) + } + return nil +} + +func (rcv *Tag) MutateValue(j int, n byte) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.MutateByte(a+flatbuffers.UOffsetT(j*1), n) + } + return false +} + +func TagStart(builder *flatbuffers.Builder) { + builder.StartObject(2) +} +func TagAddKey(builder *flatbuffers.Builder, key flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(key), 0) +} +func TagStartKeyVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(1, numElems, 1) +} +func TagAddValue(builder *flatbuffers.Builder, value flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(value), 0) +} +func TagStartValueVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(1, numElems, 1) +} +func TagEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { + return builder.EndObject() +} diff --git a/cmd/load_cnosdb/process.go b/cmd/load_cnosdb/process.go index f6fcc79..4be0b2e 100644 --- a/cmd/load_cnosdb/process.go +++ b/cmd/load_cnosdb/process.go @@ -3,11 +3,9 @@ package main import ( "bytes" "fmt" - "time" - "github.com/cnosdb/tsdb-comparisons/pkg/targets" - "github.com/valyala/fasthttp" + "time" ) const backingOffChanCap = 100 @@ -55,12 +53,24 @@ func (p *processor) ProcessBatch(b targets.Batch, doLoad bool) (uint64, uint64) if useGzip { compressedBatch := bufPool.Get().(*bytes.Buffer) fasthttp.WriteGzip(compressedBatch, batch.buf.Bytes()) - _, err = p.httpWriter.WriteLineProtocol(compressedBatch.Bytes(), true) + //file, e := os.OpenFile("text.txt", os.O_CREATE, 0755) + //if e != nil { + // panic(fmt.Sprintf("open file error %s", e)) + //} + //t := batch.buf.Bytes() + //_, err := file.WriteString(*(*string)(unsafe.Pointer(&t))) + //if err != nil { + // panic(fmt.Sprintf("open file error %s", e.Error())) + //} + //fmt.Println(*(*string)(unsafe.Pointer(&t))) + points := parserLine(compressedBatch.Bytes()) + _, err = p.httpWriter.WriteLineProtocol(points, true) // Return the compressed batch buffer to the pool. compressedBatch.Reset() bufPool.Put(compressedBatch) } else { - _, err = p.httpWriter.WriteLineProtocol(batch.buf.Bytes(), false) + points := parserLine(batch.buf.Bytes()) + _, err = p.httpWriter.WriteLineProtocol(points, false) } if err == errBackoff { diff --git a/cmd/load_cnosdb/process_test.go b/cmd/load_cnosdb/process_test.go index dc53399..c87b5c7 100644 --- a/cmd/load_cnosdb/process_test.go +++ b/cmd/load_cnosdb/process_test.go @@ -8,7 +8,7 @@ import ( "sync/atomic" "testing" "time" - + "github.com/cnosdb/tsdb-comparisons/pkg/data" ) @@ -28,21 +28,21 @@ func TestProcessorInit(t *testing.T) { if got := p.httpWriter.c.Database; got != loader.DatabaseName() { t.Errorf("incorrect database: got %s want %s", got, loader.DatabaseName()) } - + p = &processor{} p.Init(1, false, false) p.Close(true) if got := p.httpWriter.c.Host; got != daemonURLs[1] { t.Errorf("incorrect host: got %s want %s", got, daemonURLs[1]) } - + p = &processor{} p.Init(len(daemonURLs), false, false) p.Close(true) if got := p.httpWriter.c.Host; got != daemonURLs[0] { t.Errorf("incorrect host: got %s want %s", got, daemonURLs[0]) } - + } func TestProcessorInitWithHTTPWriterConfig(t *testing.T) { @@ -60,7 +60,7 @@ func TestProcessorInitWithHTTPWriterConfig(t *testing.T) { w := NewHTTPWriter(testConf, testConsistency) p.initWithHTTPWriter(workerNum, w) p.Close(true) - + // Check p was initialized correctly with channels if got := cap(p.backingOffChan); got != backingOffChanCap { t.Errorf("backing off chan cap incorrect: got %d want %d", got, backingOffChanCap) @@ -68,13 +68,13 @@ func TestProcessorInitWithHTTPWriterConfig(t *testing.T) { if got := cap(p.backingOffDone); got != 0 { t.Errorf("backing off done chan cap not 0: got %d", got) } - + // Check p was initialized with correct writer given conf err := testWriterMatchesConfig(p.httpWriter, testConf, testConsistency) if err != nil { t.Error(err) } - + // Check that backoff successfully shut down if got := atomic.LoadInt64(&counter); got != 1 { t.Errorf("printFn called incorrect # of times: got %d want %d", got, 1) @@ -97,7 +97,7 @@ func TestProcessorProcessBatch(t *testing.T) { Data: []byte("tag1=tag1val,tag2=tag2val col1=0.0,col2=0.0 140"), } b.Append(pt) - + cases := []struct { doLoad bool useGzip bool @@ -126,7 +126,7 @@ func TestProcessorProcessBatch(t *testing.T) { shouldFatal: true, }, } - + for _, c := range cases { var ch chan struct{} fatalCalled := false @@ -141,10 +141,10 @@ func TestProcessorProcessBatch(t *testing.T) { } ch = launchHTTPServer() } - + p := &processor{} w := NewHTTPWriter(testConf, testConsistency) - + // If the case should backoff, we tell our dummy server to do so by // modifying the URL params. This should keep ProcessBatch in a loop // until it gets a response that is not a backoff (every other response from the server). @@ -152,7 +152,7 @@ func TestProcessorProcessBatch(t *testing.T) { normalURL := string(w.url) w.url = []byte(fmt.Sprintf("%s&%s=true", normalURL, shouldBackoffParam)) } - + p.initWithHTTPWriter(0, w) useGzip = c.useGzip mCnt, rCnt := p.ProcessBatch(b, c.doLoad) @@ -169,7 +169,7 @@ func TestProcessorProcessBatch(t *testing.T) { t.Errorf("process batch returned less rows than batch: got %d want %d", rCnt, b.rows) } p.Close(true) - + shutdownHTTPServer(ch) time.Sleep(50 * time.Millisecond) } @@ -190,7 +190,7 @@ func TestProcessorProcessBackoffMessages(t *testing.T) { p := &processor{} w := NewHTTPWriter(testConf, testConsistency) p.initWithHTTPWriter(workerNum, w) - + // Sending false at the beginning should do nothing p.backingOffChan <- false time.Sleep(50 * time.Millisecond) @@ -207,7 +207,7 @@ func TestProcessorProcessBackoffMessages(t *testing.T) { defer m.Unlock() t.Errorf("printFn called when not expected after second false: msg %s", string(b.Bytes())) } - + // Send true, should be no print p.backingOffChan <- true time.Sleep(50 * time.Millisecond) diff --git a/cmd/load_cnosdb/proto/kv_service.pb.go b/cmd/load_cnosdb/proto/kv_service.pb.go new file mode 100644 index 0000000..500b3e4 --- /dev/null +++ b/cmd/load_cnosdb/proto/kv_service.pb.go @@ -0,0 +1,1130 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc v3.21.5 +// source: kv_service.proto + +package __ + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type FieldType int32 + +const ( + FieldType_Float FieldType = 0 + FieldType_Integer FieldType = 1 + FieldType_Unsigned FieldType = 2 + FieldType_Boolean FieldType = 3 + FieldType_String FieldType = 5 +) + +// Enum value maps for FieldType. +var ( + FieldType_name = map[int32]string{ + 0: "Float", + 1: "Integer", + 2: "Unsigned", + 3: "Boolean", + 5: "String", + } + FieldType_value = map[string]int32{ + "Float": 0, + "Integer": 1, + "Unsigned": 2, + "Boolean": 3, + "String": 5, + } +) + +func (x FieldType) Enum() *FieldType { + p := new(FieldType) + *p = x + return p +} + +func (x FieldType) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (FieldType) Descriptor() protoreflect.EnumDescriptor { + return file_kv_service_proto_enumTypes[0].Descriptor() +} + +func (FieldType) Type() protoreflect.EnumType { + return &file_kv_service_proto_enumTypes[0] +} + +func (x FieldType) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use FieldType.Descriptor instead. +func (FieldType) EnumDescriptor() ([]byte, []int) { + return file_kv_service_proto_rawDescGZIP(), []int{0} +} + +type PingRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Version uint64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` + Body []byte `protobuf:"bytes,2,opt,name=body,proto3" json:"body,omitempty"` +} + +func (x *PingRequest) Reset() { + *x = PingRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_kv_service_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PingRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PingRequest) ProtoMessage() {} + +func (x *PingRequest) ProtoReflect() protoreflect.Message { + mi := &file_kv_service_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PingRequest.ProtoReflect.Descriptor instead. +func (*PingRequest) Descriptor() ([]byte, []int) { + return file_kv_service_proto_rawDescGZIP(), []int{0} +} + +func (x *PingRequest) GetVersion() uint64 { + if x != nil { + return x.Version + } + return 0 +} + +func (x *PingRequest) GetBody() []byte { + if x != nil { + return x.Body + } + return nil +} + +type PingResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Version uint64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` + Body []byte `protobuf:"bytes,2,opt,name=body,proto3" json:"body,omitempty"` +} + +func (x *PingResponse) Reset() { + *x = PingResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_kv_service_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PingResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PingResponse) ProtoMessage() {} + +func (x *PingResponse) ProtoReflect() protoreflect.Message { + mi := &file_kv_service_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PingResponse.ProtoReflect.Descriptor instead. +func (*PingResponse) Descriptor() ([]byte, []int) { + return file_kv_service_proto_rawDescGZIP(), []int{1} +} + +func (x *PingResponse) GetVersion() uint64 { + if x != nil { + return x.Version + } + return 0 +} + +func (x *PingResponse) GetBody() []byte { + if x != nil { + return x.Body + } + return nil +} + +type Tag struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` // tag key utf-8 bytes + Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` // tag value utf-8 bytes +} + +func (x *Tag) Reset() { + *x = Tag{} + if protoimpl.UnsafeEnabled { + mi := &file_kv_service_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Tag) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Tag) ProtoMessage() {} + +func (x *Tag) ProtoReflect() protoreflect.Message { + mi := &file_kv_service_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Tag.ProtoReflect.Descriptor instead. +func (*Tag) Descriptor() ([]byte, []int) { + return file_kv_service_proto_rawDescGZIP(), []int{2} +} + +func (x *Tag) GetKey() []byte { + if x != nil { + return x.Key + } + return nil +} + +func (x *Tag) GetValue() []byte { + if x != nil { + return x.Value + } + return nil +} + +type FieldInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + FieldType FieldType `protobuf:"varint,1,opt,name=field_type,json=fieldType,proto3,enum=kv_service.FieldType" json:"field_type,omitempty"` + Name []byte `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` // field name utf-8 bytes + Id uint64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *FieldInfo) Reset() { + *x = FieldInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_kv_service_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FieldInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FieldInfo) ProtoMessage() {} + +func (x *FieldInfo) ProtoReflect() protoreflect.Message { + mi := &file_kv_service_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FieldInfo.ProtoReflect.Descriptor instead. +func (*FieldInfo) Descriptor() ([]byte, []int) { + return file_kv_service_proto_rawDescGZIP(), []int{3} +} + +func (x *FieldInfo) GetFieldType() FieldType { + if x != nil { + return x.FieldType + } + return FieldType_Float +} + +func (x *FieldInfo) GetName() []byte { + if x != nil { + return x.Name + } + return nil +} + +func (x *FieldInfo) GetId() uint64 { + if x != nil { + return x.Id + } + return 0 +} + +type AddSeriesRpcRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Version uint64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` + SeriesId uint64 `protobuf:"varint,2,opt,name=series_id,json=seriesId,proto3" json:"series_id,omitempty"` + Tags []*Tag `protobuf:"bytes,3,rep,name=tags,proto3" json:"tags,omitempty"` + Fields []*FieldInfo `protobuf:"bytes,4,rep,name=fields,proto3" json:"fields,omitempty"` +} + +func (x *AddSeriesRpcRequest) Reset() { + *x = AddSeriesRpcRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_kv_service_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AddSeriesRpcRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddSeriesRpcRequest) ProtoMessage() {} + +func (x *AddSeriesRpcRequest) ProtoReflect() protoreflect.Message { + mi := &file_kv_service_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AddSeriesRpcRequest.ProtoReflect.Descriptor instead. +func (*AddSeriesRpcRequest) Descriptor() ([]byte, []int) { + return file_kv_service_proto_rawDescGZIP(), []int{4} +} + +func (x *AddSeriesRpcRequest) GetVersion() uint64 { + if x != nil { + return x.Version + } + return 0 +} + +func (x *AddSeriesRpcRequest) GetSeriesId() uint64 { + if x != nil { + return x.SeriesId + } + return 0 +} + +func (x *AddSeriesRpcRequest) GetTags() []*Tag { + if x != nil { + return x.Tags + } + return nil +} + +func (x *AddSeriesRpcRequest) GetFields() []*FieldInfo { + if x != nil { + return x.Fields + } + return nil +} + +type AddSeriesRpcResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Version uint64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` + SeriesId uint64 `protobuf:"varint,2,opt,name=series_id,json=seriesId,proto3" json:"series_id,omitempty"` + Tags []*Tag `protobuf:"bytes,3,rep,name=tags,proto3" json:"tags,omitempty"` + Fields []*FieldInfo `protobuf:"bytes,4,rep,name=fields,proto3" json:"fields,omitempty"` +} + +func (x *AddSeriesRpcResponse) Reset() { + *x = AddSeriesRpcResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_kv_service_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AddSeriesRpcResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddSeriesRpcResponse) ProtoMessage() {} + +func (x *AddSeriesRpcResponse) ProtoReflect() protoreflect.Message { + mi := &file_kv_service_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AddSeriesRpcResponse.ProtoReflect.Descriptor instead. +func (*AddSeriesRpcResponse) Descriptor() ([]byte, []int) { + return file_kv_service_proto_rawDescGZIP(), []int{5} +} + +func (x *AddSeriesRpcResponse) GetVersion() uint64 { + if x != nil { + return x.Version + } + return 0 +} + +func (x *AddSeriesRpcResponse) GetSeriesId() uint64 { + if x != nil { + return x.SeriesId + } + return 0 +} + +func (x *AddSeriesRpcResponse) GetTags() []*Tag { + if x != nil { + return x.Tags + } + return nil +} + +func (x *AddSeriesRpcResponse) GetFields() []*FieldInfo { + if x != nil { + return x.Fields + } + return nil +} + +type GetSeriesInfoRpcRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ProtocolVersion uint64 `protobuf:"varint,1,opt,name=protocol_version,json=protocolVersion,proto3" json:"protocol_version,omitempty"` + SeriesId uint64 `protobuf:"varint,2,opt,name=series_id,json=seriesId,proto3" json:"series_id,omitempty"` +} + +func (x *GetSeriesInfoRpcRequest) Reset() { + *x = GetSeriesInfoRpcRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_kv_service_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetSeriesInfoRpcRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetSeriesInfoRpcRequest) ProtoMessage() {} + +func (x *GetSeriesInfoRpcRequest) ProtoReflect() protoreflect.Message { + mi := &file_kv_service_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetSeriesInfoRpcRequest.ProtoReflect.Descriptor instead. +func (*GetSeriesInfoRpcRequest) Descriptor() ([]byte, []int) { + return file_kv_service_proto_rawDescGZIP(), []int{6} +} + +func (x *GetSeriesInfoRpcRequest) GetProtocolVersion() uint64 { + if x != nil { + return x.ProtocolVersion + } + return 0 +} + +func (x *GetSeriesInfoRpcRequest) GetSeriesId() uint64 { + if x != nil { + return x.SeriesId + } + return 0 +} + +type GetSeriesInfoRpcResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Version uint64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` + SeriesId uint64 `protobuf:"varint,2,opt,name=series_id,json=seriesId,proto3" json:"series_id,omitempty"` + Tags []*Tag `protobuf:"bytes,3,rep,name=tags,proto3" json:"tags,omitempty"` + Fields []*FieldInfo `protobuf:"bytes,4,rep,name=fields,proto3" json:"fields,omitempty"` +} + +func (x *GetSeriesInfoRpcResponse) Reset() { + *x = GetSeriesInfoRpcResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_kv_service_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetSeriesInfoRpcResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetSeriesInfoRpcResponse) ProtoMessage() {} + +func (x *GetSeriesInfoRpcResponse) ProtoReflect() protoreflect.Message { + mi := &file_kv_service_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetSeriesInfoRpcResponse.ProtoReflect.Descriptor instead. +func (*GetSeriesInfoRpcResponse) Descriptor() ([]byte, []int) { + return file_kv_service_proto_rawDescGZIP(), []int{7} +} + +func (x *GetSeriesInfoRpcResponse) GetVersion() uint64 { + if x != nil { + return x.Version + } + return 0 +} + +func (x *GetSeriesInfoRpcResponse) GetSeriesId() uint64 { + if x != nil { + return x.SeriesId + } + return 0 +} + +func (x *GetSeriesInfoRpcResponse) GetTags() []*Tag { + if x != nil { + return x.Tags + } + return nil +} + +func (x *GetSeriesInfoRpcResponse) GetFields() []*FieldInfo { + if x != nil { + return x.Fields + } + return nil +} + +type WriteRowsRpcRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Version uint64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` + Rows []byte `protobuf:"bytes,2,opt,name=rows,proto3" json:"rows,omitempty"` // flatbuffers bytes ( models::Rows ) +} + +func (x *WriteRowsRpcRequest) Reset() { + *x = WriteRowsRpcRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_kv_service_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *WriteRowsRpcRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WriteRowsRpcRequest) ProtoMessage() {} + +func (x *WriteRowsRpcRequest) ProtoReflect() protoreflect.Message { + mi := &file_kv_service_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use WriteRowsRpcRequest.ProtoReflect.Descriptor instead. +func (*WriteRowsRpcRequest) Descriptor() ([]byte, []int) { + return file_kv_service_proto_rawDescGZIP(), []int{8} +} + +func (x *WriteRowsRpcRequest) GetVersion() uint64 { + if x != nil { + return x.Version + } + return 0 +} + +func (x *WriteRowsRpcRequest) GetRows() []byte { + if x != nil { + return x.Rows + } + return nil +} + +type WriteRowsRpcResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Version uint64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` + Rows []byte `protobuf:"bytes,2,opt,name=rows,proto3" json:"rows,omitempty"` // flatbuffers bytes ( models::Rows ) +} + +func (x *WriteRowsRpcResponse) Reset() { + *x = WriteRowsRpcResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_kv_service_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *WriteRowsRpcResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WriteRowsRpcResponse) ProtoMessage() {} + +func (x *WriteRowsRpcResponse) ProtoReflect() protoreflect.Message { + mi := &file_kv_service_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use WriteRowsRpcResponse.ProtoReflect.Descriptor instead. +func (*WriteRowsRpcResponse) Descriptor() ([]byte, []int) { + return file_kv_service_proto_rawDescGZIP(), []int{9} +} + +func (x *WriteRowsRpcResponse) GetVersion() uint64 { + if x != nil { + return x.Version + } + return 0 +} + +func (x *WriteRowsRpcResponse) GetRows() []byte { + if x != nil { + return x.Rows + } + return nil +} + +type WritePointsRpcRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Version uint64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` + Points []byte `protobuf:"bytes,2,opt,name=points,proto3" json:"points,omitempty"` // flatbuffers bytes ( models::Points ) +} + +func (x *WritePointsRpcRequest) Reset() { + *x = WritePointsRpcRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_kv_service_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *WritePointsRpcRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WritePointsRpcRequest) ProtoMessage() {} + +func (x *WritePointsRpcRequest) ProtoReflect() protoreflect.Message { + mi := &file_kv_service_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use WritePointsRpcRequest.ProtoReflect.Descriptor instead. +func (*WritePointsRpcRequest) Descriptor() ([]byte, []int) { + return file_kv_service_proto_rawDescGZIP(), []int{10} +} + +func (x *WritePointsRpcRequest) GetVersion() uint64 { + if x != nil { + return x.Version + } + return 0 +} + +func (x *WritePointsRpcRequest) GetPoints() []byte { + if x != nil { + return x.Points + } + return nil +} + +type WritePointsRpcResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Version uint64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` + Points []byte `protobuf:"bytes,2,opt,name=points,proto3" json:"points,omitempty"` // flatbuffers bytes ( models::Points ) +} + +func (x *WritePointsRpcResponse) Reset() { + *x = WritePointsRpcResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_kv_service_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *WritePointsRpcResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WritePointsRpcResponse) ProtoMessage() {} + +func (x *WritePointsRpcResponse) ProtoReflect() protoreflect.Message { + mi := &file_kv_service_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use WritePointsRpcResponse.ProtoReflect.Descriptor instead. +func (*WritePointsRpcResponse) Descriptor() ([]byte, []int) { + return file_kv_service_proto_rawDescGZIP(), []int{11} +} + +func (x *WritePointsRpcResponse) GetVersion() uint64 { + if x != nil { + return x.Version + } + return 0 +} + +func (x *WritePointsRpcResponse) GetPoints() []byte { + if x != nil { + return x.Points + } + return nil +} + +var File_kv_service_proto protoreflect.FileDescriptor + +var file_kv_service_proto_rawDesc = []byte{ + 0x0a, 0x10, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x0a, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x22, 0x3b, + 0x0a, 0x0b, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, + 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x3c, 0x0a, 0x0c, 0x50, + 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x76, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x2d, 0x0a, 0x03, 0x54, 0x61, 0x67, + 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x6b, + 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x65, 0x0a, 0x09, 0x46, 0x69, 0x65, 0x6c, + 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x34, 0x0a, 0x0a, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x74, + 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x6b, 0x76, 0x5f, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x54, 0x79, 0x70, 0x65, + 0x52, 0x09, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, + 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x22, + 0xa0, 0x01, 0x0a, 0x13, 0x41, 0x64, 0x64, 0x53, 0x65, 0x72, 0x69, 0x65, 0x73, 0x52, 0x70, 0x63, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x65, 0x72, 0x69, 0x65, 0x73, 0x5f, 0x69, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x72, 0x69, 0x65, 0x73, 0x49, 0x64, 0x12, 0x23, + 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x6b, + 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x54, 0x61, 0x67, 0x52, 0x04, 0x74, + 0x61, 0x67, 0x73, 0x12, 0x2d, 0x0a, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x18, 0x04, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x06, 0x66, 0x69, 0x65, 0x6c, + 0x64, 0x73, 0x22, 0xa1, 0x01, 0x0a, 0x14, 0x41, 0x64, 0x64, 0x53, 0x65, 0x72, 0x69, 0x65, 0x73, + 0x52, 0x70, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x76, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x65, 0x72, 0x69, 0x65, 0x73, 0x5f, + 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x72, 0x69, 0x65, 0x73, + 0x49, 0x64, 0x12, 0x23, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x0f, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x54, 0x61, + 0x67, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x2d, 0x0a, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, + 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x06, + 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x22, 0x61, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, + 0x69, 0x65, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x70, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x29, 0x0a, 0x10, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x5f, 0x76, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, + 0x73, 0x65, 0x72, 0x69, 0x65, 0x73, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x08, 0x73, 0x65, 0x72, 0x69, 0x65, 0x73, 0x49, 0x64, 0x22, 0xa5, 0x01, 0x0a, 0x18, 0x47, 0x65, + 0x74, 0x53, 0x65, 0x72, 0x69, 0x65, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x70, 0x63, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x65, 0x72, 0x69, 0x65, 0x73, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x72, 0x69, 0x65, 0x73, 0x49, 0x64, 0x12, 0x23, 0x0a, + 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x6b, 0x76, + 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x54, 0x61, 0x67, 0x52, 0x04, 0x74, 0x61, + 0x67, 0x73, 0x12, 0x2d, 0x0a, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x18, 0x04, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, + 0x46, 0x69, 0x65, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, + 0x73, 0x22, 0x43, 0x0a, 0x13, 0x57, 0x72, 0x69, 0x74, 0x65, 0x52, 0x6f, 0x77, 0x73, 0x52, 0x70, + 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x77, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x04, 0x72, 0x6f, 0x77, 0x73, 0x22, 0x44, 0x0a, 0x14, 0x57, 0x72, 0x69, 0x74, 0x65, 0x52, + 0x6f, 0x77, 0x73, 0x52, 0x70, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, + 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x77, 0x73, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x72, 0x6f, 0x77, 0x73, 0x22, 0x49, 0x0a, 0x15, + 0x57, 0x72, 0x69, 0x74, 0x65, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x52, 0x70, 0x63, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, + 0x16, 0x0a, 0x06, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x06, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x22, 0x4a, 0x0a, 0x16, 0x57, 0x72, 0x69, 0x74, 0x65, + 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x52, 0x70, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x70, + 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x70, 0x6f, 0x69, + 0x6e, 0x74, 0x73, 0x2a, 0x4a, 0x0a, 0x09, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x54, 0x79, 0x70, 0x65, + 0x12, 0x09, 0x0a, 0x05, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x49, + 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x6e, 0x73, 0x69, + 0x67, 0x6e, 0x65, 0x64, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x42, 0x6f, 0x6f, 0x6c, 0x65, 0x61, + 0x6e, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x10, 0x05, 0x32, + 0xaa, 0x03, 0x0a, 0x0b, 0x54, 0x53, 0x4b, 0x56, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, + 0x39, 0x0a, 0x04, 0x50, 0x69, 0x6e, 0x67, 0x12, 0x17, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x18, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x50, 0x69, + 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x50, 0x0a, 0x09, 0x41, 0x64, + 0x64, 0x53, 0x65, 0x72, 0x69, 0x65, 0x73, 0x12, 0x1f, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x2e, 0x41, 0x64, 0x64, 0x53, 0x65, 0x72, 0x69, 0x65, 0x73, 0x52, 0x70, + 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x41, 0x64, 0x64, 0x53, 0x65, 0x72, 0x69, 0x65, 0x73, 0x52, + 0x70, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5c, 0x0a, 0x0d, + 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x69, 0x65, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x23, 0x2e, + 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, + 0x72, 0x69, 0x65, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x70, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, + 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x69, 0x65, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x70, 0x63, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x54, 0x0a, 0x09, 0x57, 0x72, + 0x69, 0x74, 0x65, 0x52, 0x6f, 0x77, 0x73, 0x12, 0x1f, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x2e, 0x57, 0x72, 0x69, 0x74, 0x65, 0x52, 0x6f, 0x77, 0x73, 0x52, 0x70, + 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x57, 0x72, 0x69, 0x74, 0x65, 0x52, 0x6f, 0x77, 0x73, 0x52, + 0x70, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, + 0x12, 0x5a, 0x0a, 0x0b, 0x57, 0x72, 0x69, 0x74, 0x65, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x12, + 0x21, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x57, 0x72, 0x69, + 0x74, 0x65, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x52, 0x70, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, + 0x57, 0x72, 0x69, 0x74, 0x65, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x52, 0x70, 0x63, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x42, 0x04, 0x5a, 0x02, + 0x2e, 0x2f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_kv_service_proto_rawDescOnce sync.Once + file_kv_service_proto_rawDescData = file_kv_service_proto_rawDesc +) + +func file_kv_service_proto_rawDescGZIP() []byte { + file_kv_service_proto_rawDescOnce.Do(func() { + file_kv_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_kv_service_proto_rawDescData) + }) + return file_kv_service_proto_rawDescData +} + +var file_kv_service_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_kv_service_proto_msgTypes = make([]protoimpl.MessageInfo, 12) +var file_kv_service_proto_goTypes = []interface{}{ + (FieldType)(0), // 0: kv_service.FieldType + (*PingRequest)(nil), // 1: kv_service.PingRequest + (*PingResponse)(nil), // 2: kv_service.PingResponse + (*Tag)(nil), // 3: kv_service.Tag + (*FieldInfo)(nil), // 4: kv_service.FieldInfo + (*AddSeriesRpcRequest)(nil), // 5: kv_service.AddSeriesRpcRequest + (*AddSeriesRpcResponse)(nil), // 6: kv_service.AddSeriesRpcResponse + (*GetSeriesInfoRpcRequest)(nil), // 7: kv_service.GetSeriesInfoRpcRequest + (*GetSeriesInfoRpcResponse)(nil), // 8: kv_service.GetSeriesInfoRpcResponse + (*WriteRowsRpcRequest)(nil), // 9: kv_service.WriteRowsRpcRequest + (*WriteRowsRpcResponse)(nil), // 10: kv_service.WriteRowsRpcResponse + (*WritePointsRpcRequest)(nil), // 11: kv_service.WritePointsRpcRequest + (*WritePointsRpcResponse)(nil), // 12: kv_service.WritePointsRpcResponse +} +var file_kv_service_proto_depIdxs = []int32{ + 0, // 0: kv_service.FieldInfo.field_type:type_name -> kv_service.FieldType + 3, // 1: kv_service.AddSeriesRpcRequest.tags:type_name -> kv_service.Tag + 4, // 2: kv_service.AddSeriesRpcRequest.fields:type_name -> kv_service.FieldInfo + 3, // 3: kv_service.AddSeriesRpcResponse.tags:type_name -> kv_service.Tag + 4, // 4: kv_service.AddSeriesRpcResponse.fields:type_name -> kv_service.FieldInfo + 3, // 5: kv_service.GetSeriesInfoRpcResponse.tags:type_name -> kv_service.Tag + 4, // 6: kv_service.GetSeriesInfoRpcResponse.fields:type_name -> kv_service.FieldInfo + 1, // 7: kv_service.TSKVService.Ping:input_type -> kv_service.PingRequest + 5, // 8: kv_service.TSKVService.AddSeries:input_type -> kv_service.AddSeriesRpcRequest + 7, // 9: kv_service.TSKVService.GetSeriesInfo:input_type -> kv_service.GetSeriesInfoRpcRequest + 9, // 10: kv_service.TSKVService.WriteRows:input_type -> kv_service.WriteRowsRpcRequest + 11, // 11: kv_service.TSKVService.WritePoints:input_type -> kv_service.WritePointsRpcRequest + 2, // 12: kv_service.TSKVService.Ping:output_type -> kv_service.PingResponse + 6, // 13: kv_service.TSKVService.AddSeries:output_type -> kv_service.AddSeriesRpcResponse + 8, // 14: kv_service.TSKVService.GetSeriesInfo:output_type -> kv_service.GetSeriesInfoRpcResponse + 10, // 15: kv_service.TSKVService.WriteRows:output_type -> kv_service.WriteRowsRpcResponse + 12, // 16: kv_service.TSKVService.WritePoints:output_type -> kv_service.WritePointsRpcResponse + 12, // [12:17] is the sub-list for method output_type + 7, // [7:12] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name +} + +func init() { file_kv_service_proto_init() } +func file_kv_service_proto_init() { + if File_kv_service_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_kv_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PingRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_kv_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PingResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_kv_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Tag); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_kv_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FieldInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_kv_service_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AddSeriesRpcRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_kv_service_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AddSeriesRpcResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_kv_service_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetSeriesInfoRpcRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_kv_service_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetSeriesInfoRpcResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_kv_service_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*WriteRowsRpcRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_kv_service_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*WriteRowsRpcResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_kv_service_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*WritePointsRpcRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_kv_service_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*WritePointsRpcResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_kv_service_proto_rawDesc, + NumEnums: 1, + NumMessages: 12, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_kv_service_proto_goTypes, + DependencyIndexes: file_kv_service_proto_depIdxs, + EnumInfos: file_kv_service_proto_enumTypes, + MessageInfos: file_kv_service_proto_msgTypes, + }.Build() + File_kv_service_proto = out.File + file_kv_service_proto_rawDesc = nil + file_kv_service_proto_goTypes = nil + file_kv_service_proto_depIdxs = nil +} diff --git a/cmd/load_cnosdb/proto/kv_service.proto b/cmd/load_cnosdb/proto/kv_service.proto new file mode 100644 index 0000000..1b9cf06 --- /dev/null +++ b/cmd/load_cnosdb/proto/kv_service.proto @@ -0,0 +1,90 @@ +syntax = "proto3"; +package kv_service; +option go_package = "proto"; + +message PingRequest { + uint64 version = 1; + bytes body = 2; +} + +message PingResponse { + uint64 version = 1; + bytes body = 2; +} + +message Tag { + bytes key = 1; // tag key utf-8 bytes + bytes value = 2; // tag value utf-8 bytes +} + +enum FieldType { + Float = 0; + Integer = 1; + Unsigned = 2; + Boolean = 3; + String = 5; +} + +message FieldInfo { + FieldType field_type = 1; + bytes name = 2; // field name utf-8 bytes + uint64 id = 3; +} + +message AddSeriesRpcRequest { + uint64 version = 1; + uint64 series_id = 2; + repeated Tag tags = 3; + repeated FieldInfo fields = 4; +} + +message AddSeriesRpcResponse { + uint64 version = 1; + uint64 series_id = 2; + repeated Tag tags = 3; + repeated FieldInfo fields = 4; +} + +message GetSeriesInfoRpcRequest { + uint64 protocol_version = 1; + uint64 series_id = 2; +} + +message GetSeriesInfoRpcResponse { + uint64 version = 1; + uint64 series_id = 2; + repeated Tag tags = 3; + repeated FieldInfo fields = 4; +} + +message WriteRowsRpcRequest { + uint64 version = 1; + bytes rows = 2; // flatbuffers bytes ( models::Rows ) +} + +message WriteRowsRpcResponse { + uint64 version = 1; + bytes rows = 2; // flatbuffers bytes ( models::Rows ) +} + +message WritePointsRpcRequest { + uint64 version = 1; + bytes points = 2; // flatbuffers bytes ( models::Points ) +} + +message WritePointsRpcResponse { + uint64 version = 1; + bytes points = 2; // flatbuffers bytes ( models::Points ) +} + +service TSKVService { + rpc Ping(PingRequest) returns (PingResponse); + + rpc AddSeries(AddSeriesRpcRequest) returns (AddSeriesRpcResponse) {}; + + rpc GetSeriesInfo(GetSeriesInfoRpcRequest) returns (GetSeriesInfoRpcResponse) {}; + + rpc WriteRows(stream WriteRowsRpcRequest) returns (stream WriteRowsRpcResponse) {}; + + rpc WritePoints(stream WritePointsRpcRequest) returns (stream WritePointsRpcResponse) {}; +} \ No newline at end of file diff --git a/cmd/load_cnosdb/proto/kv_service_grpc.pb.go b/cmd/load_cnosdb/proto/kv_service_grpc.pb.go new file mode 100644 index 0000000..3b44b59 --- /dev/null +++ b/cmd/load_cnosdb/proto/kv_service_grpc.pb.go @@ -0,0 +1,314 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v3.21.5 +// source: kv_service.proto + +package __ + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// TSKVServiceClient is the client API for TSKVService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type TSKVServiceClient interface { + Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PingResponse, error) + AddSeries(ctx context.Context, in *AddSeriesRpcRequest, opts ...grpc.CallOption) (*AddSeriesRpcResponse, error) + GetSeriesInfo(ctx context.Context, in *GetSeriesInfoRpcRequest, opts ...grpc.CallOption) (*GetSeriesInfoRpcResponse, error) + WriteRows(ctx context.Context, opts ...grpc.CallOption) (TSKVService_WriteRowsClient, error) + WritePoints(ctx context.Context, opts ...grpc.CallOption) (TSKVService_WritePointsClient, error) +} + +type tSKVServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewTSKVServiceClient(cc grpc.ClientConnInterface) TSKVServiceClient { + return &tSKVServiceClient{cc} +} + +func (c *tSKVServiceClient) Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PingResponse, error) { + out := new(PingResponse) + err := c.cc.Invoke(ctx, "/kv_service.TSKVService/Ping", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *tSKVServiceClient) AddSeries(ctx context.Context, in *AddSeriesRpcRequest, opts ...grpc.CallOption) (*AddSeriesRpcResponse, error) { + out := new(AddSeriesRpcResponse) + err := c.cc.Invoke(ctx, "/kv_service.TSKVService/AddSeries", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *tSKVServiceClient) GetSeriesInfo(ctx context.Context, in *GetSeriesInfoRpcRequest, opts ...grpc.CallOption) (*GetSeriesInfoRpcResponse, error) { + out := new(GetSeriesInfoRpcResponse) + err := c.cc.Invoke(ctx, "/kv_service.TSKVService/GetSeriesInfo", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *tSKVServiceClient) WriteRows(ctx context.Context, opts ...grpc.CallOption) (TSKVService_WriteRowsClient, error) { + stream, err := c.cc.NewStream(ctx, &TSKVService_ServiceDesc.Streams[0], "/kv_service.TSKVService/WriteRows", opts...) + if err != nil { + return nil, err + } + x := &tSKVServiceWriteRowsClient{stream} + return x, nil +} + +type TSKVService_WriteRowsClient interface { + Send(*WriteRowsRpcRequest) error + Recv() (*WriteRowsRpcResponse, error) + grpc.ClientStream +} + +type tSKVServiceWriteRowsClient struct { + grpc.ClientStream +} + +func (x *tSKVServiceWriteRowsClient) Send(m *WriteRowsRpcRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *tSKVServiceWriteRowsClient) Recv() (*WriteRowsRpcResponse, error) { + m := new(WriteRowsRpcResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *tSKVServiceClient) WritePoints(ctx context.Context, opts ...grpc.CallOption) (TSKVService_WritePointsClient, error) { + stream, err := c.cc.NewStream(ctx, &TSKVService_ServiceDesc.Streams[1], "/kv_service.TSKVService/WritePoints", opts...) + if err != nil { + return nil, err + } + x := &tSKVServiceWritePointsClient{stream} + return x, nil +} + +type TSKVService_WritePointsClient interface { + Send(*WritePointsRpcRequest) error + Recv() (*WritePointsRpcResponse, error) + grpc.ClientStream +} + +type tSKVServiceWritePointsClient struct { + grpc.ClientStream +} + +func (x *tSKVServiceWritePointsClient) Send(m *WritePointsRpcRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *tSKVServiceWritePointsClient) Recv() (*WritePointsRpcResponse, error) { + m := new(WritePointsRpcResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// TSKVServiceServer is the server API for TSKVService service. +// All implementations must embed UnimplementedTSKVServiceServer +// for forward compatibility +type TSKVServiceServer interface { + Ping(context.Context, *PingRequest) (*PingResponse, error) + AddSeries(context.Context, *AddSeriesRpcRequest) (*AddSeriesRpcResponse, error) + GetSeriesInfo(context.Context, *GetSeriesInfoRpcRequest) (*GetSeriesInfoRpcResponse, error) + WriteRows(TSKVService_WriteRowsServer) error + WritePoints(TSKVService_WritePointsServer) error + mustEmbedUnimplementedTSKVServiceServer() +} + +// UnimplementedTSKVServiceServer must be embedded to have forward compatible implementations. +type UnimplementedTSKVServiceServer struct { +} + +func (UnimplementedTSKVServiceServer) Ping(context.Context, *PingRequest) (*PingResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Ping not implemented") +} +func (UnimplementedTSKVServiceServer) AddSeries(context.Context, *AddSeriesRpcRequest) (*AddSeriesRpcResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddSeries not implemented") +} +func (UnimplementedTSKVServiceServer) GetSeriesInfo(context.Context, *GetSeriesInfoRpcRequest) (*GetSeriesInfoRpcResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetSeriesInfo not implemented") +} +func (UnimplementedTSKVServiceServer) WriteRows(TSKVService_WriteRowsServer) error { + return status.Errorf(codes.Unimplemented, "method WriteRows not implemented") +} +func (UnimplementedTSKVServiceServer) WritePoints(TSKVService_WritePointsServer) error { + return status.Errorf(codes.Unimplemented, "method WritePoints not implemented") +} +func (UnimplementedTSKVServiceServer) mustEmbedUnimplementedTSKVServiceServer() {} + +// UnsafeTSKVServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to TSKVServiceServer will +// result in compilation errors. +type UnsafeTSKVServiceServer interface { + mustEmbedUnimplementedTSKVServiceServer() +} + +func RegisterTSKVServiceServer(s grpc.ServiceRegistrar, srv TSKVServiceServer) { + s.RegisterService(&TSKVService_ServiceDesc, srv) +} + +func _TSKVService_Ping_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PingRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TSKVServiceServer).Ping(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kv_service.TSKVService/Ping", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TSKVServiceServer).Ping(ctx, req.(*PingRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _TSKVService_AddSeries_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AddSeriesRpcRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TSKVServiceServer).AddSeries(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kv_service.TSKVService/AddSeries", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TSKVServiceServer).AddSeries(ctx, req.(*AddSeriesRpcRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _TSKVService_GetSeriesInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetSeriesInfoRpcRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TSKVServiceServer).GetSeriesInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/kv_service.TSKVService/GetSeriesInfo", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TSKVServiceServer).GetSeriesInfo(ctx, req.(*GetSeriesInfoRpcRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _TSKVService_WriteRows_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(TSKVServiceServer).WriteRows(&tSKVServiceWriteRowsServer{stream}) +} + +type TSKVService_WriteRowsServer interface { + Send(*WriteRowsRpcResponse) error + Recv() (*WriteRowsRpcRequest, error) + grpc.ServerStream +} + +type tSKVServiceWriteRowsServer struct { + grpc.ServerStream +} + +func (x *tSKVServiceWriteRowsServer) Send(m *WriteRowsRpcResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *tSKVServiceWriteRowsServer) Recv() (*WriteRowsRpcRequest, error) { + m := new(WriteRowsRpcRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _TSKVService_WritePoints_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(TSKVServiceServer).WritePoints(&tSKVServiceWritePointsServer{stream}) +} + +type TSKVService_WritePointsServer interface { + Send(*WritePointsRpcResponse) error + Recv() (*WritePointsRpcRequest, error) + grpc.ServerStream +} + +type tSKVServiceWritePointsServer struct { + grpc.ServerStream +} + +func (x *tSKVServiceWritePointsServer) Send(m *WritePointsRpcResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *tSKVServiceWritePointsServer) Recv() (*WritePointsRpcRequest, error) { + m := new(WritePointsRpcRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// TSKVService_ServiceDesc is the grpc.ServiceDesc for TSKVService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var TSKVService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "kv_service.TSKVService", + HandlerType: (*TSKVServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Ping", + Handler: _TSKVService_Ping_Handler, + }, + { + MethodName: "AddSeries", + Handler: _TSKVService_AddSeries_Handler, + }, + { + MethodName: "GetSeriesInfo", + Handler: _TSKVService_GetSeriesInfo_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "WriteRows", + Handler: _TSKVService_WriteRows_Handler, + ServerStreams: true, + ClientStreams: true, + }, + { + StreamName: "WritePoints", + Handler: _TSKVService_WritePoints_Handler, + ServerStreams: true, + ClientStreams: true, + }, + }, + Metadata: "kv_service.proto", +} diff --git a/cmd/load_cnosdb/proto/model.fbs b/cmd/load_cnosdb/proto/model.fbs new file mode 100644 index 0000000..7997a29 --- /dev/null +++ b/cmd/load_cnosdb/proto/model.fbs @@ -0,0 +1,73 @@ +namespace models; + +table PingBody { + payload: [ubyte]; +} + +enum FieldType: int { + Unknown = -1, + Float, + Integer, + Unsigned, + Boolean, + String, +} + +struct RowKey { + series_id: uint64; + timestamp: uint64; +} + +table RowField { + field_id: uint64; + type: FieldType; + value: [ubyte]; +} + +table Row { + key: RowKey; + fields: [RowField]; +} + +table Rows { + rows: [Row]; +} + +table Tag { + key: [ubyte]; + value: [ubyte]; +} + +table Field { + name: [ubyte]; + type: FieldType; + value: [ubyte]; +} + +table Point { + db: [ubyte]; + table: [ubyte]; + tags: [Tag]; + fields: [Field]; + timestamp: int64; +} + +table Points { + database: [ubyte]; + points: [Point]; +} + +struct ColumnKey { + series_id: uint64; + field_id: uint64; +} + +table ColumnKeys { + column_keys: [ColumnKey]; +} + +table ColumnKeysWithRange { + column_keys: [ColumnKey]; + min: int64; + max: int64; +} diff --git a/cmd/load_cnosdb/scan.go b/cmd/load_cnosdb/scan.go index 642bf9a..4b8c22c 100644 --- a/cmd/load_cnosdb/scan.go +++ b/cmd/load_cnosdb/scan.go @@ -4,7 +4,7 @@ import ( "bufio" "bytes" "strings" - + "github.com/cnosdb/tsdb-comparisons/pkg/data" "github.com/cnosdb/tsdb-comparisons/pkg/data/usecases/common" "github.com/cnosdb/tsdb-comparisons/pkg/targets" @@ -53,7 +53,7 @@ func (b *batch) Append(item data.LoadedPoint) { return } b.metrics += uint64(len(strings.Split(args[1], ","))) - + b.buf.Write(that) b.buf.Write(newLine) } diff --git a/cmd/load_cnosdb/scan_test.go b/cmd/load_cnosdb/scan_test.go index 061d60c..df4ec99 100644 --- a/cmd/load_cnosdb/scan_test.go +++ b/cmd/load_cnosdb/scan_test.go @@ -6,7 +6,7 @@ import ( "fmt" "sync" "testing" - + "github.com/cnosdb/tsdb-comparisons/pkg/data" ) @@ -34,7 +34,7 @@ func TestBatch(t *testing.T) { if b.metrics != 2 { t.Errorf("batch metric count is not 2 after first append") } - + p = data.LoadedPoint{ Data: []byte("tag1=tag1val,tag2=tag2val col1=1.0,col2=1.0 190"), } @@ -48,7 +48,7 @@ func TestBatch(t *testing.T) { if b.metrics != 4 { t.Errorf("batch metric count is not 2 after first append") } - + p = data.LoadedPoint{ Data: []byte("bad_point"), } @@ -80,7 +80,7 @@ func TestFileDataSourceNextItem(t *testing.T) { result: []byte("cpu,tag1=tag1text,tag2=tag2text col1=0.0,col2=0.0 140"), }, } - + for _, c := range cases { br := bufio.NewReader(bytes.NewReader([]byte(c.input))) ds := &fileDataSource{scanner: bufio.NewScanner(br)} diff --git a/cmd/load_influx/http_writer.go b/cmd/load_influx/http_writer.go index fa0fbce..e744b43 100644 --- a/cmd/load_influx/http_writer.go +++ b/cmd/load_influx/http_writer.go @@ -7,7 +7,7 @@ import ( "fmt" "net/url" "time" - + "github.com/valyala/fasthttp" ) @@ -32,10 +32,10 @@ var ( type HTTPWriterConfig struct { // URL of the host, in form "http://example.com:8086" Host string - + // Name of the target database into which points will be written. Database string - + // Debug label for more informative errors. DebugInfo string } @@ -43,7 +43,7 @@ type HTTPWriterConfig struct { // HTTPWriter is a Writer that writes to an InfluxDB HTTP server. type HTTPWriter struct { client fasthttp.Client - + c HTTPWriterConfig url []byte } @@ -54,7 +54,7 @@ func NewHTTPWriter(c HTTPWriterConfig, consistency string) *HTTPWriter { client: fasthttp.Client{ Name: httpClientName, }, - + c: c, url: []byte(c.Host + "/write?consistency=" + consistency + "&db=" + url.QueryEscape(c.Database)), } @@ -97,10 +97,10 @@ func (w *HTTPWriter) WriteLineProtocol(body []byte, isGzip bool) (int64, error) req := fasthttp.AcquireRequest() defer fasthttp.ReleaseRequest(req) w.initializeReq(req, body, isGzip) - + resp := fasthttp.AcquireResponse() defer fasthttp.ReleaseResponse(resp) - + return w.executeReq(req, resp) } diff --git a/cmd/load_influx/main.go b/cmd/load_influx/main.go index a0884b0..0cbdf4c 100644 --- a/cmd/load_influx/main.go +++ b/cmd/load_influx/main.go @@ -12,7 +12,7 @@ import ( "strings" "sync" "time" - + "github.com/blagojts/viper" "github.com/cnosdb/tsdb-comparisons/internal/utils" "github.com/cnosdb/tsdb-comparisons/load" @@ -57,29 +57,29 @@ func init() { config.AddToFlagSet(pflag.CommandLine) target.TargetSpecificFlags("", pflag.CommandLine) var csvDaemonURLs string - + pflag.Parse() - + err := utils.SetupConfigFile() - + if err != nil { panic(fmt.Errorf("fatal error config file: %s", err)) } - + if err := viper.Unmarshal(&config); err != nil { panic(fmt.Errorf("unable to decode config: %s", err)) } - + csvDaemonURLs = viper.GetString("urls") replicationFactor = viper.GetInt("replication-factor") consistency = viper.GetString("consistency") backoff = viper.GetDuration("backoff") useGzip = viper.GetBool("gzip") - + if _, ok := consistencyChoices[consistency]; !ok { log.Fatalf("invalid consistency settings") } - + daemonURLs = strings.Split(csvDaemonURLs, ",") if len(daemonURLs) == 0 { log.Fatal("missing 'urls' flag") @@ -116,6 +116,6 @@ func main() { return bytes.NewBuffer(make([]byte, 0, 4*1024*1024)) }, } - + loader.RunBenchmark(&benchmark{}) } diff --git a/cmd/load_influx/process.go b/cmd/load_influx/process.go index 9fd15ef..2ba3669 100644 --- a/cmd/load_influx/process.go +++ b/cmd/load_influx/process.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/cnosdb/tsdb-comparisons/pkg/targets" "time" - + "github.com/valyala/fasthttp" ) @@ -45,7 +45,7 @@ func (p *processor) Close(_ bool) { func (p *processor) ProcessBatch(b targets.Batch, doLoad bool) (uint64, uint64) { batch := b.(*batch) - + // Write the batch: try until backoff is not needed. if doLoad { var err error @@ -60,7 +60,7 @@ func (p *processor) ProcessBatch(b targets.Batch, doLoad bool) (uint64, uint64) } else { _, err = p.httpWriter.WriteLineProtocol(batch.buf.Bytes(), false) } - + if err == errBackoff { p.backingOffChan <- true time.Sleep(backoff) @@ -75,7 +75,7 @@ func (p *processor) ProcessBatch(b targets.Batch, doLoad bool) (uint64, uint64) } metricCnt := batch.metrics rowCnt := batch.rows - + // Return the batch buffer to the pool. batch.buf.Reset() bufPool.Put(batch.buf) diff --git a/cmd/load_influx/process_test.go b/cmd/load_influx/process_test.go index dc53399..c87b5c7 100644 --- a/cmd/load_influx/process_test.go +++ b/cmd/load_influx/process_test.go @@ -8,7 +8,7 @@ import ( "sync/atomic" "testing" "time" - + "github.com/cnosdb/tsdb-comparisons/pkg/data" ) @@ -28,21 +28,21 @@ func TestProcessorInit(t *testing.T) { if got := p.httpWriter.c.Database; got != loader.DatabaseName() { t.Errorf("incorrect database: got %s want %s", got, loader.DatabaseName()) } - + p = &processor{} p.Init(1, false, false) p.Close(true) if got := p.httpWriter.c.Host; got != daemonURLs[1] { t.Errorf("incorrect host: got %s want %s", got, daemonURLs[1]) } - + p = &processor{} p.Init(len(daemonURLs), false, false) p.Close(true) if got := p.httpWriter.c.Host; got != daemonURLs[0] { t.Errorf("incorrect host: got %s want %s", got, daemonURLs[0]) } - + } func TestProcessorInitWithHTTPWriterConfig(t *testing.T) { @@ -60,7 +60,7 @@ func TestProcessorInitWithHTTPWriterConfig(t *testing.T) { w := NewHTTPWriter(testConf, testConsistency) p.initWithHTTPWriter(workerNum, w) p.Close(true) - + // Check p was initialized correctly with channels if got := cap(p.backingOffChan); got != backingOffChanCap { t.Errorf("backing off chan cap incorrect: got %d want %d", got, backingOffChanCap) @@ -68,13 +68,13 @@ func TestProcessorInitWithHTTPWriterConfig(t *testing.T) { if got := cap(p.backingOffDone); got != 0 { t.Errorf("backing off done chan cap not 0: got %d", got) } - + // Check p was initialized with correct writer given conf err := testWriterMatchesConfig(p.httpWriter, testConf, testConsistency) if err != nil { t.Error(err) } - + // Check that backoff successfully shut down if got := atomic.LoadInt64(&counter); got != 1 { t.Errorf("printFn called incorrect # of times: got %d want %d", got, 1) @@ -97,7 +97,7 @@ func TestProcessorProcessBatch(t *testing.T) { Data: []byte("tag1=tag1val,tag2=tag2val col1=0.0,col2=0.0 140"), } b.Append(pt) - + cases := []struct { doLoad bool useGzip bool @@ -126,7 +126,7 @@ func TestProcessorProcessBatch(t *testing.T) { shouldFatal: true, }, } - + for _, c := range cases { var ch chan struct{} fatalCalled := false @@ -141,10 +141,10 @@ func TestProcessorProcessBatch(t *testing.T) { } ch = launchHTTPServer() } - + p := &processor{} w := NewHTTPWriter(testConf, testConsistency) - + // If the case should backoff, we tell our dummy server to do so by // modifying the URL params. This should keep ProcessBatch in a loop // until it gets a response that is not a backoff (every other response from the server). @@ -152,7 +152,7 @@ func TestProcessorProcessBatch(t *testing.T) { normalURL := string(w.url) w.url = []byte(fmt.Sprintf("%s&%s=true", normalURL, shouldBackoffParam)) } - + p.initWithHTTPWriter(0, w) useGzip = c.useGzip mCnt, rCnt := p.ProcessBatch(b, c.doLoad) @@ -169,7 +169,7 @@ func TestProcessorProcessBatch(t *testing.T) { t.Errorf("process batch returned less rows than batch: got %d want %d", rCnt, b.rows) } p.Close(true) - + shutdownHTTPServer(ch) time.Sleep(50 * time.Millisecond) } @@ -190,7 +190,7 @@ func TestProcessorProcessBackoffMessages(t *testing.T) { p := &processor{} w := NewHTTPWriter(testConf, testConsistency) p.initWithHTTPWriter(workerNum, w) - + // Sending false at the beginning should do nothing p.backingOffChan <- false time.Sleep(50 * time.Millisecond) @@ -207,7 +207,7 @@ func TestProcessorProcessBackoffMessages(t *testing.T) { defer m.Unlock() t.Errorf("printFn called when not expected after second false: msg %s", string(b.Bytes())) } - + // Send true, should be no print p.backingOffChan <- true time.Sleep(50 * time.Millisecond) diff --git a/cmd/load_influx/scan.go b/cmd/load_influx/scan.go index b9c3be6..09fe9dd 100644 --- a/cmd/load_influx/scan.go +++ b/cmd/load_influx/scan.go @@ -4,7 +4,7 @@ import ( "bufio" "bytes" "strings" - + "github.com/cnosdb/tsdb-comparisons/pkg/data" "github.com/cnosdb/tsdb-comparisons/pkg/data/usecases/common" "github.com/cnosdb/tsdb-comparisons/pkg/targets" @@ -53,7 +53,7 @@ func (b *batch) Append(item data.LoadedPoint) { return } b.metrics += uint64(len(strings.Split(args[1], ","))) - + b.buf.Write(that) b.buf.Write(newLine) } diff --git a/cmd/load_influx/scan_test.go b/cmd/load_influx/scan_test.go index 061d60c..df4ec99 100644 --- a/cmd/load_influx/scan_test.go +++ b/cmd/load_influx/scan_test.go @@ -6,7 +6,7 @@ import ( "fmt" "sync" "testing" - + "github.com/cnosdb/tsdb-comparisons/pkg/data" ) @@ -34,7 +34,7 @@ func TestBatch(t *testing.T) { if b.metrics != 2 { t.Errorf("batch metric count is not 2 after first append") } - + p = data.LoadedPoint{ Data: []byte("tag1=tag1val,tag2=tag2val col1=1.0,col2=1.0 190"), } @@ -48,7 +48,7 @@ func TestBatch(t *testing.T) { if b.metrics != 4 { t.Errorf("batch metric count is not 2 after first append") } - + p = data.LoadedPoint{ Data: []byte("bad_point"), } @@ -80,7 +80,7 @@ func TestFileDataSourceNextItem(t *testing.T) { result: []byte("cpu,tag1=tag1text,tag2=tag2text col1=0.0,col2=0.0 140"), }, } - + for _, c := range cases { br := bufio.NewReader(bytes.NewReader([]byte(c.input))) ds := &fileDataSource{scanner: bufio.NewScanner(br)} diff --git a/cmd/load_timescaledb/main.go b/cmd/load_timescaledb/main.go index 15ebf38..fbb857b 100644 --- a/cmd/load_timescaledb/main.go +++ b/cmd/load_timescaledb/main.go @@ -6,13 +6,13 @@ package main import ( "fmt" "sync" - + "github.com/blagojts/viper" - "github.com/spf13/pflag" "github.com/cnosdb/tsdb-comparisons/internal/utils" "github.com/cnosdb/tsdb-comparisons/load" "github.com/cnosdb/tsdb-comparisons/pkg/data/source" "github.com/cnosdb/tsdb-comparisons/pkg/targets/timescaledb" + "github.com/spf13/pflag" ) // Parse args: @@ -22,13 +22,13 @@ func initProgramOptions() (*timescaledb.LoadingOptions, load.BenchmarkRunner, *l loaderConf.AddToFlagSet(pflag.CommandLine) target.TargetSpecificFlags("", pflag.CommandLine) pflag.Parse() - + err := utils.SetupConfigFile() - + if err != nil { panic(fmt.Errorf("fatal error config file: %s", err)) } - + if err := viper.Unmarshal(&loaderConf); err != nil { panic(fmt.Errorf("unable to decode config: %s", err)) } @@ -41,17 +41,17 @@ func initProgramOptions() (*timescaledb.LoadingOptions, load.BenchmarkRunner, *l opts.Pass = viper.GetString("pass") opts.ConnDB = viper.GetString("admin-db-name") opts.LogBatches = viper.GetBool("log-batches") - + opts.UseHypertable = viper.GetBool("use-hypertable") opts.ChunkTime = viper.GetDuration("chunk-time") - + opts.UseJSON = viper.GetBool("use-jsonb-tags") - + // This must be set to 'true' if you are going to test // distributed hypertable queries and insert. Replication // factor must also be set to true for distributed hypertables opts.InTableTag = viper.GetBool("in-table-partition-tag") - + // We currently use `create_hypertable` for all variations. When // `replication-factor`>=1, we automatically create a distributed // hypertable. @@ -59,39 +59,39 @@ func initProgramOptions() (*timescaledb.LoadingOptions, load.BenchmarkRunner, *l // Currently ignored for distributed hypertables. We assume all // data nodes will be used based on the partition-column above opts.NumberPartitions = viper.GetInt("partitions") - + opts.TimeIndex = viper.GetBool("time-index") opts.TimePartitionIndex = viper.GetBool("time-partition-index") opts.PartitionIndex = viper.GetBool("partition-index") opts.FieldIndex = viper.GetString("field-index") opts.FieldIndexCount = viper.GetInt("field-index-count") - + opts.ProfileFile = viper.GetString("write-profile") opts.ReplicationStatsFile = viper.GetString("write-replication-stats") opts.CreateMetricsTable = viper.GetBool("create-metrics-table") - + opts.ForceTextFormat = viper.GetBool("force-text-format") opts.UseInsert = viper.GetBool("use-insert") - + loader := load.GetBenchmarkRunner(loaderConf) return &opts, loader, &loaderConf } func main() { opts, loader, loaderConf := initProgramOptions() - + // If specified, generate a performance profile if len(opts.ProfileFile) > 0 { go profileCPUAndMem(opts.ProfileFile) } - + var replicationStatsWaitGroup sync.WaitGroup if len(opts.ReplicationStatsFile) > 0 { go OutputReplicationStats( opts.GetConnectString(loader.DatabaseName()), opts.ReplicationStatsFile, &replicationStatsWaitGroup, ) } - + benchmark, err := timescaledb.NewBenchmark(loaderConf.DBName, opts, &source.DataSourceConfig{ Type: source.FileDataSourceType, File: &source.FileDataSourceConfig{Location: loaderConf.FileName}, @@ -100,7 +100,7 @@ func main() { panic(err) } loader.RunBenchmark(benchmark) - + if len(opts.ReplicationStatsFile) > 0 { replicationStatsWaitGroup.Wait() } diff --git a/cmd/run_queries_cnosdb/http_client.go b/cmd/run_queries_cnosdb/http_client.go index d608777..c6a289b 100644 --- a/cmd/run_queries_cnosdb/http_client.go +++ b/cmd/run_queries_cnosdb/http_client.go @@ -9,7 +9,7 @@ import ( "os" "sync" "time" - + "github.com/cnosdb/tsdb-comparisons/pkg/query" ) @@ -68,13 +68,13 @@ func (w *HTTPClient) Do(q *query.HTTP, opts *HTTPClientDoOptions) (lag float64, s := fmt.Sprintf("&chunked=true&chunk_size=%d", opts.chunkSize) w.uri = append(w.uri, []byte(s)...) } - + // populate a request with data from the Query: req, err := http.NewRequest(string(q.Method), string(w.uri), nil) if err != nil { panic(err) } - + // Perform the request while tracking latency: start := time.Now() resp, err := w.client.Do(req) @@ -85,16 +85,16 @@ func (w *HTTPClient) Do(q *query.HTTP, opts *HTTPClientDoOptions) (lag float64, if resp.StatusCode != http.StatusOK { panic("http request did not return status 200 OK") } - + var body []byte body, err = ioutil.ReadAll(resp.Body) - + if err != nil { panic(err) } - + lag = float64(time.Since(start).Nanoseconds()) / 1e6 // milliseconds - + if opts != nil { // Print debug messages, if applicable: switch opts.Debug { @@ -111,12 +111,12 @@ func (w *HTTPClient) Do(q *query.HTTP, opts *HTTPClientDoOptions) (lag float64, fmt.Fprintf(os.Stderr, "debug: response: %s\n", string(body)) default: } - + // Pretty print JSON responses, if applicable: if opts.PrettyPrintResponses { // Assumes the response is JSON! This holds for Influx // and Elastic. - + prefix := fmt.Sprintf("ID %d: ", q.GetID()) var v interface{} var line []byte @@ -131,6 +131,6 @@ func (w *HTTPClient) Do(q *query.HTTP, opts *HTTPClientDoOptions) (lag float64, fmt.Println(string(line) + "\n") } } - + return lag, err } diff --git a/cmd/run_queries_cnosdb/main.go b/cmd/run_queries_cnosdb/main.go index fdb30a3..08683df 100644 --- a/cmd/run_queries_cnosdb/main.go +++ b/cmd/run_queries_cnosdb/main.go @@ -9,7 +9,7 @@ import ( "fmt" "log" "strings" - + "github.com/blagojts/viper" "github.com/cnosdb/tsdb-comparisons/internal/utils" "github.com/cnosdb/tsdb-comparisons/pkg/query" @@ -32,30 +32,30 @@ func init() { var config query.BenchmarkRunnerConfig config.AddToFlagSet(pflag.CommandLine) var csvDaemonUrls string - + pflag.String("urls", "http://localhost:8086", "Daemon URLs, comma-separated. Will be used in a round-robin fashion.") pflag.Uint64("chunk-response-size", 0, "Number of series to chunk results into. 0 means no chunking.") - + pflag.Parse() - + err := utils.SetupConfigFile() - + if err != nil { panic(fmt.Errorf("fatal error config file: %s", err)) } - + if err := viper.Unmarshal(&config); err != nil { panic(fmt.Errorf("unable to decode config: %s", err)) } - + csvDaemonUrls = viper.GetString("urls") chunkSize = viper.GetUint64("chunk-response-size") - + daemonUrls = strings.Split(csvDaemonUrls, ",") if len(daemonUrls) == 0 { log.Fatal("missing 'urls' flag") } - + runner = query.NewBenchmarkRunner(config) } diff --git a/cmd/run_queries_influx/http_client.go b/cmd/run_queries_influx/http_client.go index d608777..c6a289b 100644 --- a/cmd/run_queries_influx/http_client.go +++ b/cmd/run_queries_influx/http_client.go @@ -9,7 +9,7 @@ import ( "os" "sync" "time" - + "github.com/cnosdb/tsdb-comparisons/pkg/query" ) @@ -68,13 +68,13 @@ func (w *HTTPClient) Do(q *query.HTTP, opts *HTTPClientDoOptions) (lag float64, s := fmt.Sprintf("&chunked=true&chunk_size=%d", opts.chunkSize) w.uri = append(w.uri, []byte(s)...) } - + // populate a request with data from the Query: req, err := http.NewRequest(string(q.Method), string(w.uri), nil) if err != nil { panic(err) } - + // Perform the request while tracking latency: start := time.Now() resp, err := w.client.Do(req) @@ -85,16 +85,16 @@ func (w *HTTPClient) Do(q *query.HTTP, opts *HTTPClientDoOptions) (lag float64, if resp.StatusCode != http.StatusOK { panic("http request did not return status 200 OK") } - + var body []byte body, err = ioutil.ReadAll(resp.Body) - + if err != nil { panic(err) } - + lag = float64(time.Since(start).Nanoseconds()) / 1e6 // milliseconds - + if opts != nil { // Print debug messages, if applicable: switch opts.Debug { @@ -111,12 +111,12 @@ func (w *HTTPClient) Do(q *query.HTTP, opts *HTTPClientDoOptions) (lag float64, fmt.Fprintf(os.Stderr, "debug: response: %s\n", string(body)) default: } - + // Pretty print JSON responses, if applicable: if opts.PrettyPrintResponses { // Assumes the response is JSON! This holds for Influx // and Elastic. - + prefix := fmt.Sprintf("ID %d: ", q.GetID()) var v interface{} var line []byte @@ -131,6 +131,6 @@ func (w *HTTPClient) Do(q *query.HTTP, opts *HTTPClientDoOptions) (lag float64, fmt.Println(string(line) + "\n") } } - + return lag, err } diff --git a/cmd/run_queries_influx/main.go b/cmd/run_queries_influx/main.go index 68e8048..3a8c97a 100644 --- a/cmd/run_queries_influx/main.go +++ b/cmd/run_queries_influx/main.go @@ -9,11 +9,11 @@ import ( "fmt" "log" "strings" - + "github.com/blagojts/viper" - "github.com/spf13/pflag" "github.com/cnosdb/tsdb-comparisons/internal/utils" "github.com/cnosdb/tsdb-comparisons/pkg/query" + "github.com/spf13/pflag" ) // Program option vars: @@ -32,30 +32,30 @@ func init() { var config query.BenchmarkRunnerConfig config.AddToFlagSet(pflag.CommandLine) var csvDaemonUrls string - + pflag.String("urls", "http://localhost:8086", "Daemon URLs, comma-separated. Will be used in a round-robin fashion.") pflag.Uint64("chunk-response-size", 0, "Number of series to chunk results into. 0 means no chunking.") - + pflag.Parse() - + err := utils.SetupConfigFile() - + if err != nil { panic(fmt.Errorf("fatal error config file: %s", err)) } - + if err := viper.Unmarshal(&config); err != nil { panic(fmt.Errorf("unable to decode config: %s", err)) } - + csvDaemonUrls = viper.GetString("urls") chunkSize = viper.GetUint64("chunk-response-size") - + daemonUrls = strings.Split(csvDaemonUrls, ",") if len(daemonUrls) == 0 { log.Fatal("missing 'urls' flag") } - + runner = query.NewBenchmarkRunner(config) } diff --git a/cmd/run_queries_timescaledb/main.go b/cmd/run_queries_timescaledb/main.go index 39f456c..36930c4 100644 --- a/cmd/run_queries_timescaledb/main.go +++ b/cmd/run_queries_timescaledb/main.go @@ -12,14 +12,14 @@ import ( "regexp" "strings" "time" - + "github.com/blagojts/viper" + "github.com/cnosdb/tsdb-comparisons/internal/utils" + "github.com/cnosdb/tsdb-comparisons/pkg/query" _ "github.com/jackc/pgx/v4/stdlib" _ "github.com/lib/pq" "github.com/pkg/errors" "github.com/spf13/pflag" - "github.com/cnosdb/tsdb-comparisons/internal/utils" - "github.com/cnosdb/tsdb-comparisons/pkg/query" ) const pgxDriver = "pgx" // default driver @@ -46,29 +46,29 @@ var ( func init() { var config query.BenchmarkRunnerConfig config.AddToFlagSet(pflag.CommandLine) - + pflag.String("postgres", "host=postgres user=postgres sslmode=disable", "String of additional PostgreSQL connection parameters, e.g., 'sslmode=disable'. Parameters for host and database will be ignored.") pflag.String("hosts", "localhost", "Comma separated list of PostgreSQL hosts (pass multiple values for sharding reads on a multi-node setup)") pflag.String("user", "postgres", "User to connect to PostgreSQL as") pflag.String("pass", "", "Password for the user connecting to PostgreSQL (leave blank if not password protected)") pflag.String("port", "5432", "Which port to connect to on the database host") - + pflag.Bool("show-explain", false, "Print out the EXPLAIN output for sample query") pflag.Bool("force-text-format", false, "Send/receive data in text format") - + pflag.Parse() - + err := utils.SetupConfigFile() - + if err != nil { panic(fmt.Errorf("fatal error config file: %s", err)) } - + if err := viper.Unmarshal(&config); err != nil { panic(fmt.Errorf("unable to decode config: %s", err)) } - + postgresConnect = viper.GetString("postgres") hosts := viper.GetString("hosts") user = viper.GetString("user") @@ -76,19 +76,19 @@ func init() { port = viper.GetString("port") showExplain = viper.GetBool("show-explain") forceTextFormat = viper.GetBool("force-text-format") - + runner = query.NewBenchmarkRunner(config) - + if showExplain { runner.SetLimit(1) } - + if forceTextFormat { driver = pqDriver } else { driver = pgxDriver } - + // Parse comma separated string of hosts and put in a slice (for multi-node setups) for _, host := range strings.Split(hosts, ",") { hostList = append(hostList, host) @@ -109,11 +109,11 @@ func getConnectString(workerNumber int) string { // multi host configuration. Same for dbname= and user=. This sanitizes that. re := regexp.MustCompile(`(host|dbname|user)=\S*\b`) connectString := re.ReplaceAllString(postgresConnect, "") - + // Round robin the host/worker assignment by assigning a host based on workerNumber % totalNumberOfHosts host := hostList[workerNumber%len(hostList)] connectString = fmt.Sprintf("host=%s dbname=%s user=%s %s", host, runner.DatabaseName(), user, connectString) - + // For optional parameters, ensure they exist then interpolate them into the connectString if len(port) > 0 { connectString = fmt.Sprintf("%s port=%s", connectString, port) @@ -124,7 +124,7 @@ func getConnectString(workerNumber int) string { if forceTextFormat { connectString = fmt.Sprintf("%s disable_prepared_binary_result=yes binary_parameters=no", connectString) } - + return connectString } @@ -135,12 +135,12 @@ func prettyPrintResponse(rows *sql.Rows, q *query.TimescaleDB) { resp := make(map[string]interface{}) resp["query"] = string(q.SqlQuery) resp["results"] = mapRows(rows) - + line, err := json.MarshalIndent(resp, "", " ") if err != nil { panic(err) } - + fmt.Println(string(line) + "\n") } @@ -153,12 +153,12 @@ func mapRows(r *sql.Rows) []map[string]interface{} { for i := range values { values[i] = new(interface{}) } - + err := r.Scan(values...) if err != nil { panic(errors.Wrap(err, "error while reading values")) } - + for i, column := range cols { row[column] = *values[i].(*interface{}) } @@ -199,7 +199,7 @@ func (p *processor) ProcessQuery(q query.Query, isWarm bool) ([]*query.Stat, err return nil, nil } tq := q.(*query.TimescaleDB) - + start := time.Now() qry := string(tq.SqlQuery) if showExplain { @@ -209,7 +209,7 @@ func (p *processor) ProcessQuery(q query.Query, isWarm bool) ([]*query.Stat, err if err != nil { return nil, err } - + if p.opts.debug { fmt.Println(qry) } @@ -236,6 +236,6 @@ func (p *processor) ProcessQuery(q query.Query, isWarm bool) ([]*query.Stat, err took := float64(time.Since(start).Nanoseconds()) / 1e6 stat := query.GetStat() stat.Init(q.HumanLabelName(), took) - + return []*query.Stat{stat}, err } diff --git a/go.mod b/go.mod index 35f8d1e..5023323 100644 --- a/go.mod +++ b/go.mod @@ -10,6 +10,7 @@ require ( github.com/blagojts/viper v1.6.3-0.20200313094124-068f44cf5e69 github.com/go-ole/go-ole v1.2.4 // indirect github.com/go-sql-driver/mysql v1.5.0 // indirect + github.com/google/flatbuffers v22.9.24+incompatible github.com/google/go-cmp v0.5.7 github.com/jackc/pgx/v4 v4.8.0 github.com/jmoiron/sqlx v1.2.1-0.20190826204134-d7d95172beb5 @@ -29,6 +30,8 @@ require ( github.com/valyala/fasthttp v1.15.1 golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a // indirect golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e + google.golang.org/grpc v1.49.0 + google.golang.org/protobuf v1.27.1 gopkg.in/yaml.v2 v2.3.0 gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect ) diff --git a/go.sum b/go.sum index 5153892..d0f032e 100644 --- a/go.sum +++ b/go.sum @@ -29,6 +29,7 @@ github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNg github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= github.com/andybalholm/brotli v1.0.0 h1:7UCwP93aiSfvWpapti8g88vVVGp2qqtGyePsSuDafo4= github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= +github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apache/iotdb-client-go v0.12.0 h1:Cq9k2ndylXhRPZLO6ovQOU8CJ5UhC/RyYUdwxL2D0IE= github.com/apache/iotdb-client-go v0.12.0/go.mod h1:oUQAIsitLK9aaQdWP0jkOybLtD9iI3QH7IFcbjl3VBQ= github.com/apache/thrift v0.13.0 h1:5hryIiq9gtn+MiLVn0wP37kb/uTeRZgN08WoCsAhIhI= @@ -44,8 +45,16 @@ github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJm github.com/blagojts/viper v1.6.3-0.20200313094124-068f44cf5e69 h1:RGlt9vq4UTJ7s6W4CKMqqeyHacjaUcwpfXS+l871hy0= github.com/blagojts/viper v1.6.3-0.20200313094124-068f44cf5e69/go.mod h1:RkC82z9memLnYkjBKikrukCMt4mYeYRRA8xBbLFe4L4= github.com/bombsimon/wsl/v3 v3.1.0/go.mod h1:st10JtZYLE4D5sC7b8xV4zTKZwAQjCH/Hy2Pm1FNZIc= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= +github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= @@ -66,6 +75,12 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/denis-tingajkin/go-header v0.3.1/go.mod h1:sq/2IxMhaZX+RRcgHfCRx/m0M5na0fBt4/CRe7Lrji0= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= @@ -109,12 +124,18 @@ github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFU github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2/go.mod h1:k9Qvh+8juN+UKMCS/3jFtGICgW8O96FVaZsaxdzDkR4= github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a/go.mod h1:ryS0uhF+x9jgbj/N71xsEqODy9BN81/GonCZiOzirOk= github.com/golangci/errcheck v0.0.0-20181223084120-ef45e06d44b6/go.mod h1:DbHgvLiFKX1Sh2T1w8Q/h4NAI8MHIpzCdnBUDTXU3I0= @@ -132,12 +153,16 @@ github.com/golangci/revgrep v0.0.0-20180526074752-d9c87f5ffaf0/go.mod h1:qOQCunE github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4/go.mod h1:Izgrg8RkN3rCIMLGE9CyYmU9pY2Jer6DgANEnZ/L/cQ= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/flatbuffers v22.9.24+incompatible h1:UumnDKj7eRT7QUb/Y4bkc6Yvx2c0GfL92cJ/UoIePXA= +github.com/google/flatbuffers v22.9.24+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= @@ -145,6 +170,7 @@ github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OI github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gookit/color v1.2.5/go.mod h1:AhIE+pS6D4Ql0SQWbBeXPHw7gY0/sjHoA4s/n1KB7xg= @@ -157,6 +183,7 @@ github.com/gostaticanalysis/analysisutil v0.0.3/go.mod h1:eEOZF4jCKGi+aprrirO9e7 github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -333,6 +360,7 @@ github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXP github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= @@ -342,6 +370,7 @@ github.com/quasilyte/go-consistent v0.0.0-20190521200055-c6f3937de18c/go.mod h1: github.com/quasilyte/go-ruleguard v0.2.0/go.mod h1:2RT/tf0Ce0UDj5y243iWKosQogJd8+1G3Rs2fxmlYnw= github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95/go.mod h1:rlzQ04UMyJXu/aOvhd8qT+hvDrFpiwqp8MRXDY9szc0= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= +github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.0/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= @@ -439,6 +468,7 @@ github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxt go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= +go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= @@ -502,9 +532,13 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -540,6 +574,8 @@ golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa h1:ZYxPR6aca/uhfRJyaOAtflSHjJYiktO7QnJC5ut7iY4= golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -567,6 +603,7 @@ golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= @@ -618,16 +655,33 @@ google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98 google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.49.0 h1:WTLtQzmQori5FUH25Pq4WT22oCsv8USpQ+F6rqtsmxw= +google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= +google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -644,6 +698,7 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= @@ -654,6 +709,7 @@ gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.5/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= mvdan.cc/gofumpt v0.0.0-20200709182408-4fd085cb6d5f/go.mod h1:9VQ397fNXEnF84t90W4r4TRCQK+pg9f8ugVfyj+S26w= diff --git a/internal/inputs/generator_data_test.go b/internal/inputs/generator_data_test.go index 9f94dca..12e29d8 100644 --- a/internal/inputs/generator_data_test.go +++ b/internal/inputs/generator_data_test.go @@ -8,7 +8,7 @@ import ( "os" "testing" "time" - + "github.com/blagojts/viper" "github.com/cnosdb/tsdb-comparisons/pkg/data" "github.com/cnosdb/tsdb-comparisons/pkg/data/serialize" @@ -35,7 +35,7 @@ func TestDataGeneratorInit(t *testing.T) { } else if got := err.Error(); got != ErrNoConfig { t.Errorf("incorrect error: got\n%s\nwant\n%s", got, ErrNoConfig) } - + // Test that wrong type of config fails err = dg.init(&common.BaseConfig{}) if err == nil { @@ -43,13 +43,13 @@ func TestDataGeneratorInit(t *testing.T) { } else if got := err.Error(); got != ErrInvalidDataConfig { t.Errorf("incorrect error: got\n%s\nwant\n%s", got, ErrInvalidDataConfig) } - + // Test that empty, invalid config fails err = dg.init(&common.DataGeneratorConfig{}) if err == nil { t.Errorf("unexpected lack of error with empty DataGeneratorConfig") } - + c := &common.DataGeneratorConfig{ BaseConfig: common.BaseConfig{ Format: constants.FormatTimescaleDB, @@ -59,7 +59,7 @@ func TestDataGeneratorInit(t *testing.T) { LogInterval: time.Second, InterleavedNumGroups: 1, } - + // Test that Out is set to os.Stdout if unset err = dg.init(c) if err != nil { @@ -67,7 +67,7 @@ func TestDataGeneratorInit(t *testing.T) { } else if dg.Out != os.Stdout { t.Errorf("Out not set to Stdout") } - + // Test that Out is same if set var buf bytes.Buffer dg.Out = &buf @@ -91,7 +91,7 @@ func TestDataGeneratorGenerate(t *testing.T) { if err == nil { t.Errorf("unexpected lack of error with empty DataGeneratorConfig") } - + c = &common.DataGeneratorConfig{ BaseConfig: common.BaseConfig{ Seed: 123, @@ -165,7 +165,7 @@ func (s *testSerializer) Serialize(p *data.Point, w io.Writer) error { if s.shouldError { return fmt.Errorf("erroring") } - + w.Write(keyIteration) w.Write([]byte("=")) str := fmt.Sprintf("%d", p.GetFieldValue(keyIteration).(uint64)) @@ -256,7 +256,7 @@ func TestRunSimulator(t *testing.T) { shouldWriteLimit: c.shouldWriteLimit, } serializer := &testSerializer{shouldError: c.shouldError} - + err := g.runSimulator(sim, serializer, dgc) if c.shouldError && err == nil { t.Errorf("%s: unexpected lack of error", c.desc) @@ -300,12 +300,12 @@ func TestGetSerializer(t *testing.T) { g := &DataGenerator{ config: dgc, } - + scfg, err := usecases.GetSimulatorConfig(dgc) if err != nil { t.Errorf("unexpected error creating scfg: %v", err) } - + sim := scfg.NewSimulator(dgc.LogInterval, 0) checkWriteHeader := func(format string, shouldWriteHeader bool) { var buf bytes.Buffer @@ -329,7 +329,7 @@ func TestGetSerializer(t *testing.T) { t.Errorf("unexpected header for format %s", format) } } - + checkWriteHeader(constants.FormatInflux, false) checkWriteHeader(constants.FormatTimescaleDB, true) } diff --git a/internal/inputs/generator_queries.go b/internal/inputs/generator_queries.go index 3fb333e..d084d01 100644 --- a/internal/inputs/generator_queries.go +++ b/internal/inputs/generator_queries.go @@ -9,7 +9,7 @@ import ( "os" "sort" "time" - + queryUtils "github.com/cnosdb/tsdb-comparisons/cmd/generate_queries/utils" internalUtils "github.com/cnosdb/tsdb-comparisons/internal/utils" "github.com/cnosdb/tsdb-comparisons/pkg/data/usecases/common" @@ -47,7 +47,7 @@ type QueryGenerator struct { // DebugOut is where non-generated messages should be written. If nil, it // will be os.Stderr. DebugOut io.Writer - + conf *config.QueryGeneratorConfig useCaseMatrix map[string]map[string]queryUtils.QueryFillerMaker // factories contains all the database implementations which can create @@ -55,7 +55,7 @@ type QueryGenerator struct { factories map[string]interface{} tsStart time.Time tsEnd time.Time - + // bufOut represents the buffered writer that should actually be passed to // any operations that write out data. bufOut *bufio.Writer @@ -76,14 +76,14 @@ func (g *QueryGenerator) Generate(config common.GeneratorConfig) error { if err != nil { return err } - + useGen, err := g.getUseCaseGenerator(g.conf) if err != nil { return err } - + filler := g.useCaseMatrix[g.conf.Use][g.conf.QueryType](useGen) - + return g.runQueryGeneration(useGen, filler, g.conf) } @@ -97,24 +97,24 @@ func (g *QueryGenerator) init(conf common.GeneratorConfig) error { return fmt.Errorf(ErrInvalidDataConfig) } g.conf = conf.(*config.QueryGeneratorConfig) - + err := g.conf.Validate() if err != nil { return err } - + if err := g.initFactories(); err != nil { return err } - + if _, ok := g.useCaseMatrix[g.conf.Use]; !ok { return fmt.Errorf(errBadUseFmt, g.conf.Use) } - + if _, ok := g.useCaseMatrix[g.conf.Use][g.conf.QueryType]; !ok { return fmt.Errorf(errBadQueryTypeFmt, g.conf.Use, g.conf.QueryType) } - + g.tsStart, err = internalUtils.ParseUTCTime(g.conf.TimeStart) if err != nil { return fmt.Errorf(errCannotParseTimeFmt, g.conf.TimeStart, err) @@ -123,7 +123,7 @@ func (g *QueryGenerator) init(conf common.GeneratorConfig) error { if err != nil { return fmt.Errorf(errCannotParseTimeFmt, g.conf.TimeEnd, err) } - + if g.Out == nil { g.Out = os.Stdout } @@ -131,11 +131,11 @@ func (g *QueryGenerator) init(conf common.GeneratorConfig) error { if err != nil { return err } - + if g.DebugOut == nil { g.DebugOut = os.Stderr } - + return nil } @@ -151,18 +151,18 @@ func (g *QueryGenerator) initFactories() error { func (g *QueryGenerator) addFactory(database string, factory interface{}) error { validFactory := false - + switch factory.(type) { case IoTGeneratorMaker: validFactory = true } - + if !validFactory { return fmt.Errorf(errInvalidFactory, database) } - + g.factories[database] = factory - + return nil } @@ -170,19 +170,19 @@ func (g *QueryGenerator) getUseCaseGenerator(c *config.QueryGeneratorConfig) (qu scale := int(c.Scale) // TODO: make all the Devops constructors use a uint64 var factory interface{} var ok bool - + if factory, ok = g.factories[c.Format]; !ok { return nil, fmt.Errorf(errUnknownFormatFmt, c.Format) } - + switch c.Use { case common.UseCaseIoT: iotFactory, ok := factory.(IoTGeneratorMaker) - + if !ok { return nil, fmt.Errorf(errUseCaseNotImplementedFmt, c.Use, c.Format) } - + return iotFactory.NewIoT(g.tsStart, g.tsEnd, scale) default: return nil, fmt.Errorf(errUnknownUseCaseFmt, c.Use) @@ -194,7 +194,7 @@ func (g *QueryGenerator) runQueryGeneration(useGen queryUtils.QueryGenerator, fi currentGroup := uint(0) enc := gob.NewEncoder(g.bufOut) defer g.bufOut.Flush() - + rand.Seed(g.conf.Seed) // fmt.Println(g.config.Seed) if g.conf.Debug > 0 { @@ -203,18 +203,18 @@ func (g *QueryGenerator) runQueryGeneration(useGen queryUtils.QueryGenerator, fi return fmt.Errorf(errCouldNotDebugFmt, err) } } - + for i := 0; i < int(c.Limit); i++ { q := useGen.GenerateEmptyQuery() q = filler.Fill(q) - + if currentGroup == c.InterleavedGroupID { err := enc.Encode(q) if err != nil { return fmt.Errorf(errCouldNotEncodeQueryFmt, err) } stats[string(q.HumanLabelName())]++ - + if c.Debug > 0 { var debugMsg string if c.Debug == 1 { @@ -224,7 +224,7 @@ func (g *QueryGenerator) runQueryGeneration(useGen queryUtils.QueryGenerator, fi } else if c.Debug >= 3 { debugMsg = q.String() } - + _, err = fmt.Fprintf(g.DebugOut, debugMsg+"\n") if err != nil { return fmt.Errorf(errCouldNotDebugFmt, err) @@ -232,13 +232,13 @@ func (g *QueryGenerator) runQueryGeneration(useGen queryUtils.QueryGenerator, fi } } q.Release() - + currentGroup++ if currentGroup == c.InterleavedNumGroups { currentGroup = 0 } } - + // Print stats: keys := []string{} for k := range stats { diff --git a/internal/inputs/generator_queries_test.go b/internal/inputs/generator_queries_test.go index 6323543..d249133 100644 --- a/internal/inputs/generator_queries_test.go +++ b/internal/inputs/generator_queries_test.go @@ -12,9 +12,9 @@ import ( "strings" "testing" "time" - + "github.com/cnosdb/tsdb-comparisons/cmd/generate_queries/databases/influx" - + "github.com/cnosdb/tsdb-comparisons/cmd/generate_queries/databases/timescaledb" queryUtils "github.com/cnosdb/tsdb-comparisons/cmd/generate_queries/utils" internalUtils "github.com/cnosdb/tsdb-comparisons/internal/utils" @@ -41,20 +41,20 @@ func TestQueryGeneratorConfigValidate(t *testing.T) { InterleavedGroupID: 0, InterleavedNumGroups: 1, } - + // Test base validation err := c.Validate() if err != nil { t.Errorf("unexpected error for correct config: %v", err) } - + c.Format = "bad format" err = c.Validate() if err == nil { t.Errorf("unexpected lack of error for bad format") } c.Format = constants.FormatTimescaleDB - + // Test QueryType validation c.QueryType = "" err = c.Validate() @@ -62,7 +62,7 @@ func TestQueryGeneratorConfigValidate(t *testing.T) { t.Errorf("unexpected lack of error for empty query type") } c.QueryType = "foo" - + // Test groups validation c.InterleavedNumGroups = 0 err = c.Validate() @@ -72,7 +72,7 @@ func TestQueryGeneratorConfigValidate(t *testing.T) { t.Errorf("incorrect error for 0 groups: got\n%s\nwant\n%s", got, errTotalGroupsZero) } c.InterleavedNumGroups = 1 - + c.InterleavedGroupID = 2 err = c.Validate() if err == nil { @@ -118,7 +118,7 @@ func TestQueryGeneratorInit(t *testing.T) { } else if got := err.Error(); got != ErrNoConfig { t.Errorf("incorrect error: got\n%s\nwant\n%s", got, ErrNoConfig) } - + // Test that wrong type of config fails err = g.init(&common.BaseConfig{}) if err == nil { @@ -126,13 +126,13 @@ func TestQueryGeneratorInit(t *testing.T) { } else if got := err.Error(); got != ErrInvalidDataConfig { t.Errorf("incorrect error: got\n%s\nwant\n%s", got, ErrInvalidDataConfig) } - + // Test that empty, invalid config fails err = g.init(&config.QueryGeneratorConfig{}) if err == nil { t.Errorf("unexpected lack of error with empty QueryGeneratorConfig") } - + c := &config.QueryGeneratorConfig{ BaseConfig: common.BaseConfig{ Format: constants.FormatTimescaleDB, @@ -142,7 +142,7 @@ func TestQueryGeneratorInit(t *testing.T) { QueryType: "unknown query type", InterleavedNumGroups: 1, } - + // Test use case not in matrix err = g.init(c) want := fmt.Sprintf(errBadUseFmt, common.UseCaseIoT) @@ -152,7 +152,7 @@ func TestQueryGeneratorInit(t *testing.T) { t.Errorf("incorrect error for bad use case:\ngot\n%s\nwant\n%s", got, want) } c.Use = common.UseCaseIoT - + // Test unknown query type err = g.init(c) want = fmt.Sprintf(errBadQueryTypeFmt, common.UseCaseIoT, "unknown query type") @@ -162,9 +162,9 @@ func TestQueryGeneratorInit(t *testing.T) { t.Errorf("incorrect error for bad query type:\ngot\n%s\nwant\n%s", got, want) } c.QueryType = okQueryType - + const errTimePrefix = "cannot parse time from string" - + // Test incorrect time format for start c.TimeStart = "2006 Jan 2" err = g.init(c) @@ -174,7 +174,7 @@ func TestQueryGeneratorInit(t *testing.T) { t.Errorf("unexpected error for bad start date: got\n%s", got) } c.TimeStart = defaultTimeStart - + // Test incorrect time format for end c.TimeEnd = "Jan 3rd 2016" err = g.init(c) @@ -184,7 +184,7 @@ func TestQueryGeneratorInit(t *testing.T) { t.Errorf("unexpected error for bad end date: got\n%s", got) } c.TimeEnd = defaultTimeEnd - + // Test that Out is set to os.Stdout if unset err = g.init(c) if err != nil { @@ -192,7 +192,7 @@ func TestQueryGeneratorInit(t *testing.T) { } else if g.Out != os.Stdout { t.Errorf("Out not set to Stdout") } - + // Test that Out is same if set var buf bytes.Buffer g.Out = &buf @@ -202,7 +202,7 @@ func TestQueryGeneratorInit(t *testing.T) { } else if g.Out != &buf { t.Errorf("Out not set to explicit io.Writer") } - + // Test that DebugOut is set to os.Stderr if unset err = g.init(c) if err != nil { @@ -235,7 +235,7 @@ func TestGetUseCaseGenerator(t *testing.T) { factories: make(map[string]interface{}), useCaseMatrix: useCaseMatrix, } - + checkType := func(format string, want queryUtils.QueryGenerator) queryUtils.QueryGenerator { wantType := reflect.TypeOf(want) c.Format = format @@ -243,11 +243,11 @@ func TestGetUseCaseGenerator(t *testing.T) { c.QueryType = "lastpoint" c.InterleavedNumGroups = 1 err := g.init(c) - + if err != nil { t.Fatalf("Error initializing query generator: %s", err) } - + useGen, err := g.getUseCaseGenerator(c) if err != nil { t.Errorf("unexpected error with format '%s': %v", format, err) @@ -255,20 +255,20 @@ func TestGetUseCaseGenerator(t *testing.T) { if got := reflect.TypeOf(useGen); got != wantType { t.Errorf("format '%s' does not give right use case gen: got %v want %v", format, got, wantType) } - + return useGen } - + bi := influx.BaseGenerator{} indb, err := bi.NewDevops(tsStart, tsEnd, scale) if err != nil { t.Fatalf("Error creating influx query generator") } checkType(constants.FormatInflux, indb) - + bt := timescaledb.BaseGenerator{} ts, err := bt.NewDevops(tsStart, tsEnd, scale) - + checkType(constants.FormatTimescaleDB, ts) if got := ts.(*timescaledb.Devops).UseTags; got != c.TimescaleUseTags { t.Errorf("timescaledb UseTags not set correctly: got %v want %v", got, c.TimescaleUseTags) @@ -279,7 +279,7 @@ func TestGetUseCaseGenerator(t *testing.T) { if got := ts.(*timescaledb.Devops).UseTimeBucket; got != c.TimescaleUseTimeBucket { t.Errorf("timescaledb UseTimeBucket not set correctly: got %v want %v", got, c.TimescaleUseTimeBucket) } - + bt.UseJSON = true bt.UseTags = true bt.UseTimeBucket = true @@ -297,7 +297,7 @@ func TestGetUseCaseGenerator(t *testing.T) { if got := tts.(*timescaledb.Devops).UseTimeBucket; got != c.TimescaleUseTimeBucket { t.Errorf("timescaledb UseTimeBucket not set correctly: got %v want %v", got, c.TimescaleUseTimeBucket) } - + // Test error condition c.Format = "bad format" useGen, err := g.getUseCaseGenerator(c) @@ -376,7 +376,7 @@ func getTestConfigAndGenerator() (*config.QueryGeneratorConfig, *QueryGenerator) DebugOut: os.Stderr, factories: make(map[string]interface{}), } - + return c, g } @@ -445,7 +445,7 @@ func TestQueryGeneratorRunQueryGeneration(t *testing.T) { }, }, } - + for _, c := range cases { config, g := getTestConfigAndGenerator() config.Debug = c.level @@ -453,25 +453,25 @@ func TestQueryGeneratorRunQueryGeneration(t *testing.T) { if err != nil { t.Fatalf("Error initializing query generator: %s", err) } - + var buf bytes.Buffer g.bufOut = bufio.NewWriter(&buf) var debug bytes.Buffer g.DebugOut = &debug - + useGen, err := g.getUseCaseGenerator(config) if err != nil { t.Fatalf("could not get use case gen: %v", err) } filler := g.useCaseMatrix[config.Use][config.QueryType](useGen) - + err = g.runQueryGeneration(useGen, filler, config) if err != nil { t.Errorf("unexpected error: got %v", err) } - + checkGeneratedOutput(t, &buf) - + // Check that the proper debug output was written wantDebug := strings.TrimSpace(strings.Join(c.wantDebug, "\n")) if got := strings.TrimSpace(debug.String()); got != wantDebug { @@ -498,13 +498,13 @@ func TestQueryGeneratorRunQueryGenerationErrors(t *testing.T) { var buf bytes.Buffer g.bufOut = bufio.NewWriter(&buf) g.init(c) - + useGen, err := g.getUseCaseGenerator(c) if err != nil { t.Fatalf("could not get use case gen: %v", err) } filler := g.useCaseMatrix[c.Use][c.QueryType](useGen) - + checkErr := func(want string) { err = g.runQueryGeneration(useGen, filler, c) if err == nil { @@ -513,24 +513,24 @@ func TestQueryGeneratorRunQueryGenerationErrors(t *testing.T) { t.Errorf("incorrect error for output query stats:\ngot\n%s\nwant\n%s", got, want) } } - + // Test error condition when printing stats g.DebugOut = &badWriter{} want := fmt.Sprintf(errCouldNotQueryStatsFmt, "error writing") checkErr(want) - + // Test error condition when printing seed c.Debug = 1 want = fmt.Sprintf(errCouldNotDebugFmt, "error writing") checkErr(want) - + // Test error condition inside loop; first debug is success g.DebugOut = &badWriter{when: 1} checkErr(want) - + g.DebugOut = &badWriter{when: 2} checkErr(want) - + // Test error on encoding g.DebugOut = &badWriter{when: 10000} g.bufOut = bufio.NewWriterSize(&badWriter{}, 8) // small buffer forces it to write to underlying @@ -542,14 +542,14 @@ func TestQueryGeneratorGenerate(t *testing.T) { g := &QueryGenerator{ factories: make(map[string]interface{}), } - + // Test that an invalid config fails c := &config.QueryGeneratorConfig{} err := g.Generate(c) if err == nil { t.Errorf("unexpected lack of error with empty QueryGeneratorConfig") } - + c, g = getTestConfigAndGenerator() var buf bytes.Buffer g.Out = &buf diff --git a/internal/inputs/generator_test.go b/internal/inputs/generator_test.go index 58e9514..93b4604 100644 --- a/internal/inputs/generator_test.go +++ b/internal/inputs/generator_test.go @@ -3,7 +3,7 @@ package inputs import ( "fmt" "testing" - + "github.com/cnosdb/tsdb-comparisons/pkg/data/usecases/common" "github.com/cnosdb/tsdb-comparisons/pkg/targets/constants" ) @@ -19,13 +19,13 @@ func TestBaseConfigValidate(t *testing.T) { Format: constants.FormatTimescaleDB, Use: common.UseCaseIoT, } - + // Test Scale validation err := c.Validate() if err != nil { t.Errorf("unexpected error with scale 1: %v", err) } - + c.Scale = 0 err = c.Validate() if err == nil { @@ -34,7 +34,7 @@ func TestBaseConfigValidate(t *testing.T) { t.Errorf("incorrect error for scale of 0: got\n%s\nwant\n%s", got, common.ErrScaleIsZero) } c.Scale = 1 - + // Test Seed validation err = c.Validate() if err != nil { @@ -43,7 +43,7 @@ func TestBaseConfigValidate(t *testing.T) { if c.Seed != 123 { t.Errorf("seed was not 123 after validation") } - + c.Seed = 0 err = c.Validate() if err != nil { @@ -52,9 +52,9 @@ func TestBaseConfigValidate(t *testing.T) { if c.Seed == 0 { t.Errorf("seed was not set to nanosecond when 0") } - + // Test Format validation - + c.Format = "unknown type" err = c.Validate() if err == nil { @@ -66,14 +66,14 @@ func TestBaseConfigValidate(t *testing.T) { } } c.Format = constants.FormatTimescaleDB - + // Test Use validation c.Use = common.UseCaseIoT err = c.Validate() if err != nil { t.Errorf("unexpected error with Use '%s': %v", common.UseCaseIoT, err) } - + c.Use = "bad use" err = c.Validate() if err == nil { diff --git a/internal/inputs/utils_test.go b/internal/inputs/utils_test.go index 7d4050c..7e5224d 100644 --- a/internal/inputs/utils_test.go +++ b/internal/inputs/utils_test.go @@ -9,7 +9,7 @@ import ( func TestIsIn(t *testing.T) { arr := []string{"foo", "bar", "baz"} arr2 := []string{"oof", "foo ", "nada", "123"} - + // Test positive cases for _, s := range arr { if !utils.IsIn(s, arr) { @@ -21,7 +21,7 @@ func TestIsIn(t *testing.T) { t.Errorf("%s not found in %v incorrectly", s, arr) } } - + // Test negative cases for _, s := range arr { if utils.IsIn(s, arr2) { @@ -33,7 +33,7 @@ func TestIsIn(t *testing.T) { t.Errorf("%s found in %v incorrectly", s, arr) } } - + } const ( @@ -50,7 +50,7 @@ func TestParseUTCTime(t *testing.T) { } else if parsedTime != correctTime { t.Errorf("did not get correct time back: got %v want %v", parsedTime, correctTime) } - + _, err = utils.ParseUTCTime(incorrectTimeStr) if err == nil { t.Errorf("unexpected lack of error") diff --git a/load/loader-no-flow-control.go b/load/loader-no-flow-control.go index fc66083..49a1142 100644 --- a/load/loader-no-flow-control.go +++ b/load/loader-no-flow-control.go @@ -13,7 +13,7 @@ type noFlowBenchmarkRunner struct { func (l *noFlowBenchmarkRunner) RunBenchmark(b targets.Benchmark) { wg, start := l.preRun(b) - + var numChannels uint if l.HashWorkers { numChannels = l.Workers @@ -21,7 +21,7 @@ func (l *noFlowBenchmarkRunner) RunBenchmark(b targets.Benchmark) { numChannels = 1 } channels := l.createChannels(numChannels, l.ChannelCapacity) - + // Launch all worker processes in background for i := uint(0); i < l.Workers; i++ { go l.work(b, wg, channels[i%numChannels], i) @@ -50,7 +50,7 @@ func (l *noFlowBenchmarkRunner) work(b targets.Benchmark, wg *sync.WaitGroup, c // Prepare processor proc := b.GetProcessor() proc.Init(int(workerNum), l.DoLoad, l.HashWorkers) - + // Process batches coming from the incoming queue (c) for batch := range c { startedWorkAt := time.Now() @@ -59,12 +59,12 @@ func (l *noFlowBenchmarkRunner) work(b targets.Benchmark, wg *sync.WaitGroup, c atomic.AddUint64(&l.rowCnt, rowCnt) l.timeToSleep(workerNum, startedWorkAt) } - + // Close proc if necessary switch c := proc.(type) { case targets.ProcessorCloser: c.Close(l.DoLoad) } - + wg.Done() } diff --git a/load/loader_test.go b/load/loader_test.go index 508d890..545d611 100644 --- a/load/loader_test.go +++ b/load/loader_test.go @@ -32,7 +32,7 @@ type testCreator struct { exists bool errRemove bool errCreate bool - + initCalled bool createCalled bool removeCalled bool @@ -120,7 +120,7 @@ func TestUseDBCreator(t *testing.T) { doCreate bool doPost bool doClose bool - + shouldPanic bool errRemove bool errCreate bool @@ -175,7 +175,7 @@ func TestUseDBCreator(t *testing.T) { errRemove: true, shouldPanic: true, }, - + { desc: "createDB errs, should panic", doLoad: true, @@ -206,7 +206,7 @@ func TestUseDBCreator(t *testing.T) { errCreate: c.errCreate, errRemove: c.errRemove, } - + // Decide whether to decorate the core DBCreator var dbc targets.DBCreator if c.doPost { @@ -216,15 +216,15 @@ func TestUseDBCreator(t *testing.T) { } else { dbc = &core } - + if c.shouldPanic { testPanic(r, dbc, c.desc) continue } - + deferFn := r.useDBCreator(dbc) deferFn() - + // Recover the core if decorated if c.doPost { core = dbc.(*testCreatorPost).testCreator @@ -257,7 +257,7 @@ func TestUseDBCreator(t *testing.T) { } else if !core.initCalled { t.Errorf("%s: doLoad is false but Init not called", c.desc) } - + // Test closing function is set or not set if c.doClose != core.closedCalled { t.Errorf("%s: close condition not equal: got %v want %v", c.desc, core.closedCalled, c.doClose) @@ -323,23 +323,23 @@ func TestWork(t *testing.T) { <-c.toScanner c.close() wg.Wait() - + if got := b.processors[0].worker; got != 0 { t.Errorf("TestWork: processor 0 has wrong worker id: got %d want %d", got, 0) } - + if got := b.processors[1].worker; got != 1 { t.Errorf("TestWork: processor 0 has wrong worker id: got %d want %d", got, 1) } - + if got := br.metricCnt; got != 2 { t.Errorf("TestWork: invalid metric count: got %d want %d", got, 2) } - + if !b.processors[0].closed { t.Errorf("TestWork: processor 0 not closed") } - + if !b.processors[1].closed { t.Errorf("TestWork: processor 1 not closed") } @@ -359,19 +359,19 @@ func TestWorkWithSleep(t *testing.T) { <-c.toScanner c.close() wg.Wait() - + if got := b.processors[0].worker; got != 0 { t.Errorf("processor 0 has wrong worker id: got %d want %d", got, 0) } - + if got := br.metricCnt; got != 1 { t.Errorf("invalid metric count: got %d want %d", got, 1) } - + if !b.processors[0].closed { t.Errorf("processor 0 not closed") } - + numTimesSleepRegulatorCalled := br.sleepRegulator.(*testSleepRegulator).calledTimes if numTimesSleepRegulatorCalled != 1 { t.Errorf("sleep regulator called %d times instead of 1", numTimesSleepRegulatorCalled) @@ -415,7 +415,7 @@ func TestSummary(t *testing.T) { want: "\nSummary:\nloaded 10 metrics in 1.000sec with 0 workers (mean rate 10.00 metrics/sec)\nloaded 1 rows in 1.000sec with 0 workers (mean rate 1.00 rows/sec)\n", }, } - + for _, c := range cases { br := &CommonBenchmarkRunner{} br.metricCnt = c.metrics @@ -444,17 +444,17 @@ func TestReport(t *testing.T) { br := &CommonBenchmarkRunner{} duration := 200 * time.Millisecond go br.report(duration) - + time.Sleep(25 * time.Millisecond) if got := atomic.LoadInt64(&counter); got != 1 { t.Errorf("TestReport: header count check incorrect: got %d want %d", got, 1) } - + time.Sleep(duration) if got := atomic.LoadInt64(&counter); got != 2 { t.Errorf("TestReport: counter check incorrect (1): got %d want %d", got, 2) } - + time.Sleep(duration) if got := atomic.LoadInt64(&counter); got != 3 { t.Errorf("TestReport: counter check incorrect (2): got %d want %d", got, 3) @@ -465,7 +465,7 @@ func TestReport(t *testing.T) { if end[len(end)-1:len(end)] != "-" { t.Errorf("TestReport: non-row report does not end in -") } - + // update row count so line is different atomic.StoreUint64(&br.rowCnt, 1) time.Sleep(duration) diff --git a/load/scan_no_flow_control.go b/load/scan_no_flow_control.go index 7318a0f..e08f22f 100644 --- a/load/scan_no_flow_control.go +++ b/load/scan_no_flow_control.go @@ -34,16 +34,16 @@ func scanWithoutFlowControl( break } itemsRead++ - + idx := indexer.GetIndex(item) batches[idx].Append(item) - + if batches[idx].Len() >= batchSize { channels[idx] <- batches[idx] batches[idx] = factory.New() } } - + for idx, unfilledBatch := range batches { if unfilledBatch.Len() > 0 { channels[idx] <- unfilledBatch diff --git a/load/scan_no_flow_control_test.go b/load/scan_no_flow_control_test.go index eeb1fa6..75ef01f 100644 --- a/load/scan_no_flow_control_test.go +++ b/load/scan_no_flow_control_test.go @@ -6,14 +6,14 @@ import ( "sync" "testing" "time" - + "github.com/cnosdb/tsdb-comparisons/pkg/data" "github.com/cnosdb/tsdb-comparisons/pkg/targets" ) func TestScanWithoutFlowControl(t *testing.T) { testData := []byte{0x00, 0x01, 0x02} - + cases := []struct { desc string batchSize uint diff --git a/load/scan_with_flow_control.go b/load/scan_with_flow_control.go index 87ac968..879be29 100644 --- a/load/scan_with_flow_control.go +++ b/load/scan_with_flow_control.go @@ -2,7 +2,7 @@ package load import ( "reflect" - + "github.com/cnosdb/tsdb-comparisons/pkg/targets" ) @@ -48,29 +48,29 @@ func scanWithFlowControl( ) uint64 { var itemsRead uint64 numChannels := len(channels) - + if batchSize < 1 { panic("--batch-size cannot be less than 1") } - + // Batches details // 1. fillingBatches contains batches that are being filled with items from scanner. // As soon a batch has batchSize items in it, or there is no more items to come, batch moves to unsentBatches. // 2. unsentBatches contains batches ready to be sent to a worker. // As soon as a worker's chan is available (i.e., not blocking), the batch is placed onto that worker's chan. - + // Current batches (per channel) that are being filled with items from scanner fillingBatches := make([]targets.Batch, numChannels) for i := range fillingBatches { fillingBatches[i] = factory.New() } - + // Batches that are ready to be set when space on a channel opens unsentBatches := make([][]targets.Batch, numChannels) for i := range unsentBatches { unsentBatches[i] = []targets.Batch{} } - + // We use Select via reflection to either select an acknowledged channel so // that we can potentially send another batch, or if none are ready to continue // on scanning. However, when we reach a limit of outstanding (unsent) batches, @@ -87,31 +87,31 @@ func scanWithFlowControl( cases[numChannels] = reflect.SelectCase{ Dir: reflect.SelectDefault, } - + // Keep track of how many batches are outstanding (ocnt), // so we don't go over a limit (olimit), in order to slow down the scanner so it doesn't starve the workers ocnt := 0 olimit := numChannels * cap(channels[0].toWorker) * 3 for { - + // Check whether incoming items limit reached. // We do not want to process more items than specified. if limit > 0 && itemsRead == limit { break } - + caseLimit := len(cases) if ocnt >= olimit { // We have too many outstanding batches, wait until one finishes (i.e. no default) caseLimit-- } - + // Only receive an 'ok' when it's from a channel, default does not return 'ok' chosen, _, ok := reflect.Select(cases[:caseLimit]) if ok { unsentBatches[chosen] = ackAndMaybeSend(channels[chosen], &ocnt, unsentBatches[chosen]) } - + // Prepare new batch - decode new item and append it to batch item := ds.NextItem() if item.Data == nil { @@ -120,11 +120,11 @@ func scanWithFlowControl( break } itemsRead++ - + // Append new item to batch idx := indexer.GetIndex(item) fillingBatches[idx].Append(item) - + if fillingBatches[idx].Len() >= batchSize { // Batch is full (contains at least batchSize items) - ready to be sent to worker, // or moved to outstanding, in case no workers available atm. @@ -133,7 +133,7 @@ func scanWithFlowControl( fillingBatches[idx] = factory.New() } } - + // Finished reading input - no more items to come // Make sure last batch goes out - it may be smaller than batchSize requested - there is not more items for idx, b := range fillingBatches { @@ -142,7 +142,7 @@ func scanWithFlowControl( unsentBatches[idx] = sendOrQueueBatch(channels[idx], &ocnt, fillingBatches[idx], unsentBatches[idx]) } } - + // Wait until all the outstanding batches get acknowledged, // so we don't prematurely close the acknowledge channels for { @@ -150,13 +150,13 @@ func scanWithFlowControl( // No outstanding batches any more break } - + // Try to send batches to workers chosen, _, ok := reflect.Select(cases[:len(cases)-1]) if ok { unsentBatches[chosen] = ackAndMaybeSend(channels[chosen], &ocnt, unsentBatches[chosen]) } } - + return itemsRead } diff --git a/load/scan_with_flow_control_test.go b/load/scan_with_flow_control_test.go index e8158ee..254ba54 100644 --- a/load/scan_with_flow_control_test.go +++ b/load/scan_with_flow_control_test.go @@ -5,7 +5,7 @@ import ( "bytes" "io" "testing" - + "github.com/cnosdb/tsdb-comparisons/pkg/data" "github.com/cnosdb/tsdb-comparisons/pkg/data/usecases/common" "github.com/cnosdb/tsdb-comparisons/pkg/targets" @@ -147,14 +147,14 @@ func TestNewPoint(t *testing.T) { t.Errorf("NewPoint did not have right data: got %v want %d", p.Data, x) } } - + // with a byte arr byteArr := []byte("test") p := data.NewLoadedPoint(byteArr) if !bytes.Equal(p.Data.([]byte), byteArr) { t.Errorf("NewPoint did not have right byte arr: got %v want %v", p.Data, byteArr) } - + // with a struct batch := &testBatch{id: 101, len: 500} p = data.NewLoadedPoint(batch) @@ -179,7 +179,7 @@ func (d *testDataSource) NextItem() data.LoadedPoint { } ret.Data = b d.called++ - + return ret } @@ -210,7 +210,7 @@ func _boringWorker(c *duplexChannel) { func TestScanWithIndexer(t *testing.T) { testData := []byte{0x00, 0x01, 0x02} - + cases := []struct { desc string batchSize uint @@ -236,7 +236,7 @@ func TestScanWithIndexer(t *testing.T) { limit: 4, wantCalls: uint64(len(testData)), }, - + { desc: "scan w/ leftover batches", batchSize: 2, diff --git a/pkg/data/source/config_test.go b/pkg/data/source/config_test.go index beb1a2b..73f8a38 100644 --- a/pkg/data/source/config_test.go +++ b/pkg/data/source/config_test.go @@ -27,20 +27,20 @@ func TestDataGeneratorConfigValidate(t *testing.T) { InterleavedGroupID: 0, InterleavedNumGroups: 1, } - + // Test base validation err := c.Validate() if err != nil { t.Errorf("unexpected error for correct config: %v", err) } - + c.Format = "bad format" err = c.Validate() if err == nil { t.Errorf("unexpected lack of error for bad format") } c.Format = constants.FormatTimescaleDB - + // Test InitialScale validation c.InitialScale = 0 err = c.Validate() @@ -50,7 +50,7 @@ func TestDataGeneratorConfigValidate(t *testing.T) { if c.InitialScale != c.Scale { t.Errorf("InitialScale not set correctly for 0: got %d want %d", c.InitialScale, c.Scale) } - + c.InitialScale = 5 err = c.Validate() if err != nil { @@ -59,7 +59,7 @@ func TestDataGeneratorConfigValidate(t *testing.T) { if c.InitialScale != 5 { t.Errorf("InitialScale not set correctly for 0: got %d want %d", c.InitialScale, 5) } - + // Test LogInterval validation c.LogInterval = 0 err = c.Validate() @@ -69,7 +69,7 @@ func TestDataGeneratorConfigValidate(t *testing.T) { t.Errorf("incorrect error for 0 log interval: got\n%s\nwant\n%s", got, errLogIntervalZero) } c.LogInterval = time.Second - + // Test groups validation c.InterleavedNumGroups = 0 err = c.Validate() @@ -79,7 +79,7 @@ func TestDataGeneratorConfigValidate(t *testing.T) { t.Errorf("incorrect error for 0 groups: got\n%s\nwant\n%s", got, errTotalGroupsZero) } c.InterleavedNumGroups = 1 - + c.InterleavedGroupID = 2 err = c.Validate() if err == nil { diff --git a/pkg/data/usecases/common/generator.go b/pkg/data/usecases/common/generator.go index 5ab6667..3d6e879 100644 --- a/pkg/data/usecases/common/generator.go +++ b/pkg/data/usecases/common/generator.go @@ -48,17 +48,17 @@ func (c *DataGeneratorConfig) Validate() error { if err != nil { return err } - + if c.InitialScale == 0 { c.InitialScale = c.BaseConfig.Scale } - + if c.LogInterval == 0 { return fmt.Errorf(errLogIntervalZero) } - + err = utils.ValidateGroups(c.InterleavedGroupID, c.InterleavedNumGroups) - + return err } @@ -67,7 +67,7 @@ func (c *DataGeneratorConfig) AddToFlagSet(fs *pflag.FlagSet) { fs.Uint64("max-data-points", 0, "Limit the number of data points to generate, 0 = no limit") fs.Uint64("initial-scale", 0, "Initial scaling variable specific to the use case (e.g., devices in 'devops'). 0 means to use -scale value") fs.Duration("log-interval", defaultLogInterval, "Duration between data points") - + fs.Uint("interleaved-generation-group-id", 0, "Group (0-indexed) to perform round-robin serialization within. Use this to scale up data generation to multiple processes.") fs.Uint("interleaved-generation-groups", 1, @@ -100,12 +100,12 @@ type GeneratorConfig interface { type BaseConfig struct { Format string `yaml:"format,omitempty" mapstructure:"format,omitempty"` Use string `yaml:"use-case" mapstructure:"use-case"` - + Scale uint64 - + TimeStart string `yaml:"timestamp-start" mapstructure:"timestamp-start"` TimeEnd string `yaml:"timestamp-end" mapstructure:"timestamp-end"` - + Seed int64 Debug int `yaml:"debug,omitempty" mapstructure:"debug,omitempty"` File string `yaml:"file,omitempty" mapstructure:"file,omitempty"` @@ -114,12 +114,12 @@ type BaseConfig struct { func (c *BaseConfig) AddToFlagSet(fs *pflag.FlagSet) { fs.String("format", "", fmt.Sprintf("Format to generate. (choices: %s)", strings.Join(constants.SupportedFormats(), ", "))) fs.String("use-case", "", fmt.Sprintf("Use case to generate.")) - + fs.Uint64("scale", 1, "Scaling value specific to use case (e.g., devices in 'devops').") - + fs.String("timestamp-start", defaultTimeStart, "Beginning timestamp (RFC3339).") fs.String("timestamp-end", defaultTimeEnd, "Ending timestamp (RFC3339).") - + fs.Int64("seed", 0, "PRNG seed (default: 0, which uses the current timestamp)") fs.Int("debug", 0, "Control level of debug output") fs.String("file", "", "Write the output to this path") @@ -129,19 +129,19 @@ func (c *BaseConfig) Validate() error { if c.Scale == 0 { return fmt.Errorf(ErrScaleIsZero) } - + if c.Seed == 0 { c.Seed = int64(time.Now().Nanosecond()) } - + if !utils.IsIn(c.Format, constants.SupportedFormats()) { return fmt.Errorf(errBadFormatFmt, c.Format) } - + if !utils.IsIn(c.Use, UseCaseChoices) { return fmt.Errorf(errBadUseFmt, c.Use) } - + return nil } diff --git a/pkg/data/usecases/common/measurement.go b/pkg/data/usecases/common/measurement.go index 9ba44b2..cce4ea5 100644 --- a/pkg/data/usecases/common/measurement.go +++ b/pkg/data/usecases/common/measurement.go @@ -41,7 +41,7 @@ func (m *SubsystemMeasurement) Tick(d time.Duration) { func (m *SubsystemMeasurement) ToPoint(p *data.Point, measurementName []byte, labels []LabeledDistributionMaker) { p.SetMeasurementName(measurementName) p.SetTimestamp(&m.Timestamp) - + for i, d := range m.Distributions { p.AppendField(labels[i].Label, d.Get()) } @@ -54,7 +54,7 @@ func (m *SubsystemMeasurement) ToPoint(p *data.Point, measurementName []byte, la func (m *SubsystemMeasurement) ToPointAllInt64(p *data.Point, measurementName []byte, labels []LabeledDistributionMaker) { p.SetMeasurementName(measurementName) p.SetTimestamp(&m.Timestamp) - + for i, d := range m.Distributions { p.AppendField(labels[i].Label, int64(d.Get())) } diff --git a/pkg/data/usecases/common/measurement_test.go b/pkg/data/usecases/common/measurement_test.go index 350a28d..34cd1a2 100644 --- a/pkg/data/usecases/common/measurement_test.go +++ b/pkg/data/usecases/common/measurement_test.go @@ -47,7 +47,7 @@ func TestNewSubsystemMeasurement(t *testing.T) { numDistros: 3, }, } - + for _, c := range cases { now := time.Now() m := NewSubsystemMeasurement(now, c.numDistros) @@ -70,11 +70,11 @@ func TestNewSubsystemMeasurementWithDistributionMakers(t *testing.T) { if !m.Timestamp.Equal(now) { t.Errorf("incorrect timestamp set: got %v want %v", m.Timestamp, now) } - + if got := len(m.Distributions); got != len(makers) { t.Errorf("incorrect number of distros: got %d want %d", got, len(makers)) } - + for i := 0; i < 2; i++ { md := m.Distributions[i].(*monotonicDistribution) if got := md.state; got != float64(i) { @@ -136,7 +136,7 @@ func testCommonToPoint(t *testing.T, p *data.Point, fieldVal float64) { if got := string(p.MeasurementName()); got != toPointLabel { t.Errorf("measurement name incorrect: got %s want %s", got, toPointLabel) } - + for _, pointFieldVal := range p.FieldValues() { switch pointFieldVal.(type) { case int64: diff --git a/pkg/data/usecases/common/simulator.go b/pkg/data/usecases/common/simulator.go index a0120b2..7716860 100644 --- a/pkg/data/usecases/common/simulator.go +++ b/pkg/data/usecases/common/simulator.go @@ -35,7 +35,7 @@ func (sc *BaseSimulatorConfig) NewSimulator(interval time.Duration, limit uint64 for i := 0; i < len(generators); i++ { generators[i] = sc.GeneratorConstructor(i, sc.Start) } - + epochs := calculateEpochs(sc.End.Sub(sc.Start), interval) maxPoints := epochs * sc.GeneratorScale * uint64(len(generators[0].Measurements())) if limit > 0 && limit < maxPoints { @@ -45,10 +45,10 @@ func (sc *BaseSimulatorConfig) NewSimulator(interval time.Duration, limit uint64 sim := &BaseSimulator{ madePoints: 0, maxPoints: maxPoints, - + generatorIndex: 0, generators: generators, - + epoch: 0, epochs: epochs, epochGenerators: sc.InitGeneratorScale, @@ -56,10 +56,10 @@ func (sc *BaseSimulatorConfig) NewSimulator(interval time.Duration, limit uint64 timestampStart: sc.Start, timestampEnd: sc.End, interval: interval, - + simulatedMeasurementIndex: 0, } - + return sim } @@ -83,19 +83,19 @@ type Simulator interface { type BaseSimulator struct { madePoints uint64 maxPoints uint64 - + generatorIndex uint64 generators []Generator - + epoch uint64 epochs uint64 epochGenerators uint64 initGenerators uint64 - + timestampStart time.Time timestampEnd time.Time interval time.Duration - + simulatedMeasurementIndex int } @@ -110,27 +110,27 @@ func (s *BaseSimulator) Next(p *data.Point) bool { s.generatorIndex = 0 s.simulatedMeasurementIndex++ } - + if s.simulatedMeasurementIndex == len(s.generators[0].Measurements()) { s.simulatedMeasurementIndex = 0 - + for i := 0; i < len(s.generators); i++ { s.generators[i].TickAll(s.interval) } - + s.adjustNumHostsForEpoch() } - + generator := s.generators[s.generatorIndex] - + // Populate the Generator tags. for _, tag := range generator.Tags() { p.AppendTag(tag.Key, tag.Value) } - + // Populate measurement-specific tags and fields: generator.Measurements()[s.simulatedMeasurementIndex].ToPoint(p) - + ret := s.generatorIndex < s.epochGenerators s.madePoints++ s.generatorIndex++ @@ -142,7 +142,7 @@ func (s *BaseSimulator) Fields() map[string][]string { if len(s.generators) <= 0 { panic("cannot get fields because no Generators added") } - + toReturn := make(map[string][]string, len(s.generators)) for _, sm := range s.generators[0].Measurements() { point := data.NewPoint() @@ -154,7 +154,7 @@ func (s *BaseSimulator) Fields() map[string][]string { } toReturn[string(point.MeasurementName())] = fieldKeysAsStr } - + return toReturn } @@ -163,13 +163,13 @@ func (s *BaseSimulator) TagKeys() []string { if len(s.generators) <= 0 { panic("cannot get tag keys because no Generators added") } - + tags := s.generators[0].Tags() tagKeys := make([]string, len(tags)) for i, tag := range tags { tagKeys[i] = string(tag.Key) } - + return tagKeys } @@ -178,13 +178,13 @@ func (s *BaseSimulator) TagTypes() []string { if len(s.generators) <= 0 { panic("cannot get tag types because no Generators added") } - + tags := s.generators[0].Tags() types := make([]string, len(tags)) for i, tag := range tags { types[i] = reflect.TypeOf(tag.Value).String() } - + return types } diff --git a/pkg/data/usecases/common/simulator_test.go b/pkg/data/usecases/common/simulator_test.go index 9d563bc..12cf326 100644 --- a/pkg/data/usecases/common/simulator_test.go +++ b/pkg/data/usecases/common/simulator_test.go @@ -37,22 +37,22 @@ type dummyGenerator struct{} func (d dummyGenerator) Measurements() []SimulatedMeasurement { sm := make([]SimulatedMeasurement, dummyGeneratorMeasurementCount) - + for i := range sm { sm[i] = &dummyMeasurement{} } - + return sm } func (d dummyGenerator) Tags() []Tag { tags := make([]Tag, 1) - + tags[0] = Tag{ Key: []byte("key"), Value: "value", } - + return tags } @@ -70,7 +70,7 @@ func TestBaseSimulatorNext(t *testing.T) { writtenIdx := []int{10, 55, 100} p := data.NewPoint() totalPerRun := testGeneratorScale * dummyGeneratorMeasurementCount - + runFn := func(run int) { for i := 0; i < totalPerRun; i++ { write := s.Next(p) @@ -83,13 +83,13 @@ func TestBaseSimulatorNext(t *testing.T) { } else if generatorIdx >= writtenIdx[run-1] && write { t.Errorf("run %d: should not write point at i = %d, but am", run, i) } - + if got := int(s.epoch); got != run-1 { t.Errorf("run %d: epoch prematurely turned over", run) } } } - + // First run through: runFn(1) // Second run through, should wrap around and do hosts again @@ -100,13 +100,13 @@ func TestBaseSimulatorNext(t *testing.T) { func TestBaseSimulatorTagKeys(t *testing.T) { s := testBaseConf.NewSimulator(time.Second, 0).(*BaseSimulator) - + tagKeys := s.TagKeys() - + if got := len(tagKeys); got != 1 { t.Fatalf("tag key count incorrect, got %d want 1", got) } - + if got := string(tagKeys[0]); got != "key" { t.Errorf("tag key incorrect, got %s want key", got) } @@ -119,22 +119,22 @@ func TestBaseSimulatorTagKeysPanic(t *testing.T) { t.Errorf("did not panic when should") } }() - + s := BaseSimulator{} s.TagKeys() - + t.Fatalf("test should have stopped at this point") } func TestBaseSimulatorTagTypes(t *testing.T) { s := testBaseConf.NewSimulator(time.Second, 0).(*BaseSimulator) - + tagTypes := s.TagTypes() - + if got := len(tagTypes); got != 1 { t.Fatalf("tag key count incorrect, got %d want 1", got) } - + if got := tagTypes[0]; got != "string" { t.Errorf("tag type incorrect, got %s want string", got) } @@ -147,32 +147,32 @@ func TestBaseSimulatorTagTypesPanic(t *testing.T) { t.Errorf("did not panic when should") } }() - + s := BaseSimulator{} s.TagTypes() - + t.Fatalf("test should have stopped at this point") } func TestBaseSimulatorFields(t *testing.T) { s := testBaseConf.NewSimulator(time.Second, 0).(*BaseSimulator) - + fields := s.Fields() - + if got := len(fields); got != 1 { t.Fatalf("fields count incorrect, got %d want 1", got) } - + got, ok := fields[string(dummyMeasurementName)] - + if !ok { t.Fatalf("field key not set, want %s", string(dummyMeasurementName)) } - + if len(got) != 1 { t.Fatalf("field count incorrect, got %d want 1", len(got)) } - + if string(got[0]) != string(dummyFieldLabel) { t.Errorf("unexpected field value, got %s want %s", string(got[0]), string(dummyFieldLabel)) } @@ -185,10 +185,10 @@ func TestBaseSimulatorFieldsPanic(t *testing.T) { t.Errorf("did not panic when should") } }() - + s := BaseSimulator{} s.Fields() - + t.Fatalf("test should have stopped at this point") } @@ -206,7 +206,7 @@ func TestBaseSimulatorConfigNewSimulator(t *testing.T) { GeneratorConstructor: dummyGeneratorConstructor, } cases := []uint64{0, 5, 10} - + for _, limit := range cases { t.Run(fmt.Sprintf("limit %d", limit), func(t *testing.T) { sim := conf.NewSimulator(duration, limit).(*BaseSimulator) diff --git a/pkg/data/usecases/iot/diagnostics_test.go b/pkg/data/usecases/iot/diagnostics_test.go index 0e6620e..82312ff 100644 --- a/pkg/data/usecases/iot/diagnostics_test.go +++ b/pkg/data/usecases/iot/diagnostics_test.go @@ -12,13 +12,13 @@ func TestDiagnosticsMeasurementToPoint(t *testing.T) { m := NewDiagnosticsMeasurement(now) duration := time.Second m.Tick(duration) - + p := data.NewPoint() m.ToPoint(p) if got := string(p.MeasurementName()); got != string(labelDiagnostics) { t.Errorf("incorrect measurement name: got %s want %s", got, labelReadings) } - + for _, ldm := range diagnosticsFields { if got := p.GetFieldValue(ldm.Label); got == nil { t.Errorf("field %s returned a nil value unexpectedly", ldm.Label) @@ -30,30 +30,30 @@ func TestCustomFuelDistribution(t *testing.T) { testCount := 5 fuelMin, fuelMax := 10.0, 100.0 fuelStep := &common.ConstantDistribution{State: -1} - + clampedDist := common.CWD(fuelStep, fuelMin, fuelMax, fuelMax) clampedCopy := *clampedDist - + fuelDist := &customFuelDistribution{&clampedCopy} - + for i := 0; i < testCount; i++ { for clampedDist.Get() > fuelMin { clampedDist.Advance() fuelDist.Advance() - + if clampedDist.Get() != fuelDist.Get() { - + if clampedDist.Get() == fuelMin { if fuelDist.Get() != fuelMax { t.Fatalf("expected fuel to be refilled when state hits minimum") } break } - + t.Fatalf("distributions don't match when they are supposed to") } } - + // Resetting the distribution and running another test. clampedDist = common.CWD(fuelStep, fuelMin, fuelMax, fuelMax) } diff --git a/pkg/data/usecases/iot/readings_test.go b/pkg/data/usecases/iot/readings_test.go index f91bc29..5f02d5f 100644 --- a/pkg/data/usecases/iot/readings_test.go +++ b/pkg/data/usecases/iot/readings_test.go @@ -11,13 +11,13 @@ func TestReadingsMeasurementToPoint(t *testing.T) { m := NewReadingsMeasurement(now) duration := time.Second m.Tick(duration) - + p := data.NewPoint() m.ToPoint(p) if got := string(p.MeasurementName()); got != string(labelReadings) { t.Errorf("incorrect measurement name: got %s want %s", got, labelReadings) } - + for _, ldm := range readingsFields { if got := p.GetFieldValue(ldm.Label); got == nil { t.Errorf("field %s returned a nil value unexpectedly", ldm.Label) diff --git a/pkg/data/usecases/iot/simulator.go b/pkg/data/usecases/iot/simulator.go index ae66d7d..bb1f20d 100644 --- a/pkg/data/usecases/iot/simulator.go +++ b/pkg/data/usecases/iot/simulator.go @@ -19,15 +19,15 @@ type SimulatorConfig common.BaseSimulatorConfig // config over the specified interval and points limit. func (sc *SimulatorConfig) NewSimulator(interval time.Duration, limit uint64) common.Simulator { s := (*common.BaseSimulatorConfig)(sc).NewSimulator(interval, limit) - + maxFieldCount := 0 - + for _, fields := range s.Fields() { if len(fields) > maxFieldCount { maxFieldCount = len(fields) } } - + return &Simulator{ base: s, batchSize: defaultBatchSize, @@ -46,7 +46,7 @@ type Simulator struct { configGenerator func(outOfOrderBatchCount, outOfOrderEntryCount, fieldCount, tagCount int) *batchConfig // maxFieldCount is the maximum amount of fields an entry can have maxFieldCount int - + // Mutable state. currBatch []*data.Point outOfOrderBatches [][]*data.Point @@ -83,13 +83,13 @@ func (s *Simulator) Next(p *data.Point) bool { if s.batchSize == 0 { return s.base.Next(p) } - + if len(s.currBatch) > 0 || s.simulateNextBatch() { p.Copy(s.currBatch[0]) s.currBatch = s.currBatch[1:] return true } - + return false } @@ -117,21 +117,21 @@ func (s *Simulator) batchPending() []*data.Point { s.outOfOrderBatches = s.outOfOrderBatches[1:] return batch } - + pendingEntries := len(s.outOfOrderEntries) - + if pendingEntries > 0 { if pendingEntries > int(s.batchSize) { batch = s.outOfOrderEntries[:s.batchSize] s.outOfOrderEntries = s.outOfOrderEntries[s.batchSize:] return batch } - + batch = s.outOfOrderEntries s.outOfOrderEntries = s.outOfOrderEntries[:0] return batch } - + return batch } @@ -142,12 +142,12 @@ func (s *Simulator) simulateNextBatch() bool { s.currBatch = s.batchPending() return true } - + return false } - + bc := s.configGenerator(len(s.outOfOrderBatches), len(s.outOfOrderEntries), s.maxFieldCount, len(s.TagKeys())) - + if bc.InsertPrevious { if len(s.outOfOrderBatches) == 0 { panic("trying to insert an out of order batch when there are no out of order batches") @@ -156,25 +156,25 @@ func (s *Simulator) simulateNextBatch() bool { s.outOfOrderBatches = s.outOfOrderBatches[1:] return true } - + if bc.Missing { s.flushBatch() return s.simulateNextBatch() } - + if bc.OutOfOrder { s.generateOutOfOrderBatch(bc) return s.simulateNextBatch() } - + s.currBatch = s.generateBatch(bc) - + // Edge case where we hit the finish of the base simulator but there are // still pending out of order items. if len(s.currBatch) == 0 { return s.simulateNextBatch() } - + return len(s.currBatch) > 0 } @@ -183,20 +183,20 @@ func (s *Simulator) simulateNextBatch() bool { func (s *Simulator) generateBatch(bc *batchConfig) []*data.Point { batch := make([]*data.Point, s.batchSize) s.offset = 0 - + for i := range batch { if s.base.Finished() { batch = batch[:i] break } - + entry, valid := s.getNextEntry(i, bc) - + if !valid { batch = batch[:i] break } - + if index, ok := bc.ZeroFields[i]; ok { keys := entry.FieldKeys() if index >= len(keys) { @@ -204,7 +204,7 @@ func (s *Simulator) generateBatch(bc *batchConfig) []*data.Point { } entry.ClearFieldValue(keys[index]) } - + if index, ok := bc.ZeroTags[i]; ok { keys := entry.TagKeys() if len(keys) < index { @@ -212,10 +212,10 @@ func (s *Simulator) generateBatch(bc *batchConfig) []*data.Point { } entry.ClearTagValue(keys[index]) } - + batch[i] = entry } - + return batch } @@ -227,7 +227,7 @@ func (s *Simulator) generateBatch(bc *batchConfig) []*data.Point { func (s *Simulator) getNextEntry(index int, bc *batchConfig) (*data.Point, bool) { var result, entry *data.Point valid := true - + for result == nil { if bc.InsertPreviousEntry[index+s.offset] { if len(s.outOfOrderEntries) == 0 { @@ -237,33 +237,33 @@ func (s *Simulator) getNextEntry(index int, bc *batchConfig) (*data.Point, bool) s.outOfOrderEntries = s.outOfOrderEntries[1:] } else { entry = data.NewPoint() - + if valid = s.base.Next(entry); !valid { break } } - + if bc.MissingEntries[index+s.offset] { s.offset++ continue } - + if bc.OutOfOrderEntries[index+s.offset] { s.outOfOrderEntries = append(s.outOfOrderEntries, entry) s.offset++ continue } - + result = entry } - + return result, valid } // generateOutOfOrderBatch creates a batch and sends it straight to out-of-order batches. func (s *Simulator) generateOutOfOrderBatch(bc *batchConfig) { batch := s.generateBatch(bc) - + if len(batch) > 0 { s.outOfOrderBatches = append(s.outOfOrderBatches, batch) } diff --git a/pkg/data/usecases/iot/simulator_test.go b/pkg/data/usecases/iot/simulator_test.go index 58948f9..0171f38 100644 --- a/pkg/data/usecases/iot/simulator_test.go +++ b/pkg/data/usecases/iot/simulator_test.go @@ -35,7 +35,7 @@ func (m *mockBaseSimulator) Next(p *data.Point) bool { } p.Copy(m.pending[m.current]) m.current++ - + return true } @@ -63,37 +63,37 @@ func newMockBaseSimulator() *mockBaseSimulator { fieldKeys := make([][]byte, fieldCount) tagKeys := make([][]byte, tagCount) pending := make([]*data.Point, pointCount) - + for i := 0; i < fieldCount; i++ { fieldKeys[i] = []byte(fmt.Sprintf("field_key_%d", i)) } - + for i := 0; i < fieldCount; i++ { fields[fmt.Sprintf("measurement_%d", i)] = fieldKeys } - + for i := 0; i < tagCount; i++ { tagKeys[i] = []byte(fmt.Sprintf("tag_key_%d", i)) } - + now := time.Now() - + for i := 0; i < pointCount; i++ { pending[i] = data.NewPoint() pending[i].SetTimestamp(&now) pending[i].SetMeasurementName([]byte(fmt.Sprintf("measurement_%d", i%fieldCount))) - + for j := 0; j < tagCount; j++ { pending[i].AppendTag(tagKeys[j], []byte(fmt.Sprintf("tag_value_%d_%d", i, j))) } - + fieldKey := fields[fmt.Sprintf("measurement_%d", i%fieldCount)] - + for j := 0; j < fieldCount; j++ { pending[i].AppendField(fieldKey[j], fmt.Sprintf("field_value_%d_%d", i, j)) } } - + fieldsAsStr := make(map[string][]string, fieldCount) for k := range fields { fieldValsAsBytes := fields[k] @@ -123,12 +123,12 @@ func checkResults(initial []*data.Point, results []*data.Point, expectedOrder [] if initial[expected] == nil { return i, false } - + if !pointsEqual(initial[expected], results[i]) { return i, false } } - + return 0, true } func pointsEqual(one *data.Point, two *data.Point) bool { @@ -492,7 +492,7 @@ func TestSimulatorNext(t *testing.T) { }, }, } - + for _, c := range cases { t.Run(c.desc, func(t *testing.T) { for batchSize, result := range c.resultsPerBatchSize { @@ -503,9 +503,9 @@ func TestSimulatorNext(t *testing.T) { batchSize: uint(batchSize), configGenerator: c.config(batchSize), } - + results := make([]*data.Point, 0) - + for i := 0; i < pointCount; i++ { point := data.NewPoint() valid := s.Next(point) @@ -514,15 +514,15 @@ func TestSimulatorNext(t *testing.T) { } results = append(results, point) } - + if !s.Finished() { t.Errorf("simulator not finished, should be done") } - + if len(result) != len(results) { t.Fatalf("simulator didn't return correct number of points, got %d want %d", len(results), len(result)) } - + // If we are checking zeros, we cannot check for equality since // a zero field or a zero tag will create a difference. if c.zeroFieldsResults[batchSize] != nil || c.zeroTagsResults[batchSize] != nil { @@ -535,16 +535,16 @@ func TestSimulatorNext(t *testing.T) { if zeroFields != nil && i < len(zeroFields) && zeroFields[i] >= 0 { got.ClearFieldValue(fieldKeys[zeroFields[i]]) } - + if zeroTags != nil && i < len(zeroTags) && zeroTags[i] >= 0 { got.ClearTagValue(tagKeys[zeroTags[i]]) } - + if !pointsEqual(got, results[i]) { t.Errorf("result entry at index %d has wrong zero field and/or zero tag:\ngot\n%v\nwant\n%v", i, got, results[i]) } } - + } else { if i, ok := checkResults(m.pending, results, result); !ok { t.Errorf("results not as expected at index %d:\ngot\n%v\nwant\n%v", i, results[i], m.pending[result[i]]) @@ -554,14 +554,14 @@ func TestSimulatorNext(t *testing.T) { } }) } - + } func TestSimulatorTagTypes(t *testing.T) { sc := &SimulatorConfig{ Start: time.Now(), End: time.Now(), - + InitGeneratorScale: 1, GeneratorScale: 1, GeneratorConstructor: NewTruck, diff --git a/pkg/data/usecases/iot/truck_test.go b/pkg/data/usecases/iot/truck_test.go index 167b4c8..8048a72 100644 --- a/pkg/data/usecases/iot/truck_test.go +++ b/pkg/data/usecases/iot/truck_test.go @@ -22,19 +22,19 @@ func (m *testMeasurement) ToPoint(_ *data.Point) {} func TestNewTruckMeasurements(t *testing.T) { start := time.Now() - + measurements := newTruckMeasurements(start) - + if got := len(measurements); got != 2 { t.Errorf("incorrect number of measurements: got %d want %d", got, 2) } - + // Cast each measurement to its type; will panic if wrong types readings := measurements[0].(*ReadingsMeasurement) if got := readings.Timestamp; got != start { t.Errorf("incorrect readings measurement timestamp: got %v want %v", got, start) } - + diagnostics := measurements[1].(*DiagnosticsMeasurement) if got := diagnostics.Timestamp; got != start { t.Errorf("incorrect diagnostics measurement timestamp: got %v want %v", got, start) @@ -44,13 +44,13 @@ func TestNewTruckMeasurements(t *testing.T) { func TestNewTruck(t *testing.T) { start := time.Now() generator := NewTruck(1, start) - + truck := generator.(*Truck) - + if got := len(truck.Measurements()); got != 2 { t.Errorf("incorrect truck measurement count: got %v want %v", got, 2) } - + if got := len(truck.Tags()); got != 8 { t.Errorf("incorrect truck tag count: got %v want %v", got, 8) } diff --git a/pkg/data/usecases/usecases.go b/pkg/data/usecases/usecases.go index 53f66af..e08dfd6 100644 --- a/pkg/data/usecases/usecases.go +++ b/pkg/data/usecases/usecases.go @@ -20,14 +20,14 @@ func GetSimulatorConfig(dgc *common.DataGeneratorConfig) (common.SimulatorConfig if err != nil { return nil, fmt.Errorf(errCannotParseTimeFmt, dgc.TimeEnd, err) } - + switch dgc.Use { - + case common.UseCaseIoT: ret = &iot.SimulatorConfig{ Start: tsStart, End: tsEnd, - + InitGeneratorScale: dgc.InitialScale, GeneratorScale: dgc.Scale, GeneratorConstructor: iot.NewTruck, diff --git a/pkg/data/usecases/usecases_test.go b/pkg/data/usecases/usecases_test.go index 5dbe7d2..9adb965 100644 --- a/pkg/data/usecases/usecases_test.go +++ b/pkg/data/usecases/usecases_test.go @@ -20,7 +20,7 @@ func TestGetSimulatorConfig(t *testing.T) { InitialScale: 1, LogInterval: defaultLogInterval, } - + checkType := func(use string, want common.SimulatorConfig) { wantType := reflect.TypeOf(want) dgc.Use = use @@ -32,9 +32,9 @@ func TestGetSimulatorConfig(t *testing.T) { t.Errorf("use '%s' does not give right scfg: got %v want %v", use, got, wantType) } } - + checkType(common.UseCaseIoT, &iot.SimulatorConfig{}) - + dgc.Use = "bogus use case" _, err := GetSimulatorConfig(dgc) if err == nil { diff --git a/pkg/query/config/config.go b/pkg/query/config/config.go index 7273ea6..c2dac25 100644 --- a/pkg/query/config/config.go +++ b/pkg/query/config/config.go @@ -2,9 +2,9 @@ package config import ( "fmt" - "github.com/spf13/pflag" "github.com/cnosdb/tsdb-comparisons/internal/utils" "github.com/cnosdb/tsdb-comparisons/pkg/data/usecases/common" + "github.com/spf13/pflag" ) const ErrEmptyQueryType = "query type cannot be empty" @@ -19,12 +19,12 @@ type QueryGeneratorConfig struct { QueryType string `mapstructure:"query-type"` InterleavedGroupID uint `mapstructure:"interleaved-generation-group-id"` InterleavedNumGroups uint `mapstructure:"interleaved-generation-groups"` - + // TODO - I think this needs some rethinking, but a simple, elegant solution escapes me right now TimescaleUseJSON bool `mapstructure:"timescale-use-json"` TimescaleUseTags bool `mapstructure:"timescale-use-tags"` TimescaleUseTimeBucket bool `mapstructure:"timescale-use-time-bucket"` - + DbName string `mapstructure:"db-name"` } @@ -34,11 +34,11 @@ func (c *QueryGeneratorConfig) Validate() error { if err != nil { return err } - + if c.QueryType == "" { return fmt.Errorf(ErrEmptyQueryType) } - + err = utils.ValidateGroups(c.InterleavedGroupID, c.InterleavedNumGroups) return err } @@ -47,15 +47,15 @@ func (c *QueryGeneratorConfig) AddToFlagSet(fs *pflag.FlagSet) { c.BaseConfig.AddToFlagSet(fs) fs.Uint64("queries", 1000, "Number of queries to generate.") fs.String("query-type", "", "Query type. (Choices are in the use case matrix.)") - + fs.Uint("interleaved-generation-group-id", 0, "Group (0-indexed) to perform round-robin serialization within. Use this to scale up data generation to multiple processes.") fs.Uint("interleaved-generation-groups", 1, "The number of round-robin serialization groups. Use this to scale up data generation to multiple processes.") - + fs.Bool("timescale-use-json", false, "TimescaleDB only: Use separate JSON tags table when querying") fs.Bool("timescale-use-tags", true, "TimescaleDB only: Use separate tags table when querying") fs.Bool("timescale-use-time-bucket", true, "TimescaleDB only: Use time bucket. Set to false to test on native PostgreSQL") - + fs.String("db-name", "benchmark", "Specify database name. Timestream requires it in order to generate the queries") } diff --git a/pkg/query/timescaledb.go b/pkg/query/timescaledb.go index 3ad7a37..d046652 100644 --- a/pkg/query/timescaledb.go +++ b/pkg/query/timescaledb.go @@ -10,7 +10,7 @@ import ( type TimescaleDB struct { HumanLabel []byte HumanDescription []byte - + Hypertable []byte // e.g. "cpu" SqlQuery []byte id uint64 @@ -63,9 +63,9 @@ func (q *TimescaleDB) Release() { q.HumanLabel = q.HumanLabel[:0] q.HumanDescription = q.HumanDescription[:0] q.id = 0 - + q.Hypertable = q.Hypertable[:0] q.SqlQuery = q.SqlQuery[:0] - + TimescaleDBPool.Put(q) } diff --git a/pkg/targets/cnosdb/serializer.go b/pkg/targets/cnosdb/serializer.go index c6ef4f4..b273d52 100644 --- a/pkg/targets/cnosdb/serializer.go +++ b/pkg/targets/cnosdb/serializer.go @@ -20,7 +20,7 @@ type Serializer struct{} func (s *Serializer) Serialize(p *data.Point, w io.Writer) (err error) { buf := make([]byte, 0, 1024) buf = append(buf, p.MeasurementName()...) - + fakeTags := make([]int, 0) tagKeys := p.TagKeys() tagValues := p.TagValues() @@ -52,7 +52,7 @@ func (s *Serializer) Serialize(p *data.Point, w io.Writer) (err error) { firstFieldFormatted = true buf = appendField(buf, tagKeys[tagIndex], tagValues[tagIndex]) } - + fieldValues := p.FieldValues() for i := 0; i < len(fieldKeys); i++ { value := fieldValues[i] @@ -66,7 +66,7 @@ func (s *Serializer) Serialize(p *data.Point, w io.Writer) (err error) { firstFieldFormatted = true buf = appendField(buf, fieldKeys[i], value) } - + // first field wasn't formatted, because all the fields were nil, CnosDBwill reject the insert if !firstFieldFormatted { return nil @@ -75,21 +75,21 @@ func (s *Serializer) Serialize(p *data.Point, w io.Writer) (err error) { buf = serialize.FastFormatAppend(p.Timestamp().UTC().UnixNano(), buf) buf = append(buf, '\n') _, err = w.Write(buf) - + return err } func appendField(buf, key []byte, v interface{}) []byte { buf = append(buf, key...) buf = append(buf, '=') - + buf = serialize.FastFormatAppend(v, buf) - + // Influx uses 'i' to indicate integers: switch v.(type) { case int, int64: buf = append(buf, 'i') } - + return buf } diff --git a/pkg/targets/cnosdb/serializer_test.go b/pkg/targets/cnosdb/serializer_test.go index ee9a293..922d4b0 100644 --- a/pkg/targets/cnosdb/serializer_test.go +++ b/pkg/targets/cnosdb/serializer_test.go @@ -36,6 +36,6 @@ func TestInfluxSerializerSerialize(t *testing.T) { Output: "cpu usage_guest_nice=38.24311829 1451606400000000000\n", }, } - + serialize.SerializerTest(t, cases, &Serializer{}) } diff --git a/pkg/targets/influx/serializer.go b/pkg/targets/influx/serializer.go index b16399e..c6589bf 100644 --- a/pkg/targets/influx/serializer.go +++ b/pkg/targets/influx/serializer.go @@ -20,7 +20,7 @@ type Serializer struct{} func (s *Serializer) Serialize(p *data.Point, w io.Writer) (err error) { buf := make([]byte, 0, 1024) buf = append(buf, p.MeasurementName()...) - + fakeTags := make([]int, 0) tagKeys := p.TagKeys() tagValues := p.TagValues() @@ -52,7 +52,7 @@ func (s *Serializer) Serialize(p *data.Point, w io.Writer) (err error) { firstFieldFormatted = true buf = appendField(buf, tagKeys[tagIndex], tagValues[tagIndex]) } - + fieldValues := p.FieldValues() for i := 0; i < len(fieldKeys); i++ { value := fieldValues[i] @@ -66,7 +66,7 @@ func (s *Serializer) Serialize(p *data.Point, w io.Writer) (err error) { firstFieldFormatted = true buf = appendField(buf, fieldKeys[i], value) } - + // first field wasn't formatted, because all the fields were nil, InfluxDB will reject the insert if !firstFieldFormatted { return nil @@ -75,16 +75,16 @@ func (s *Serializer) Serialize(p *data.Point, w io.Writer) (err error) { buf = serialize.FastFormatAppend(p.Timestamp().UTC().UnixNano(), buf) buf = append(buf, '\n') _, err = w.Write(buf) - + return err } func appendField(buf, key []byte, v interface{}) []byte { buf = append(buf, key...) buf = append(buf, '=') - + buf = serialize.FastFormatAppend(v, buf) - + // Influx uses 'i' to indicate integers: switch v.(type) { case int, int64: diff --git a/pkg/targets/influx/serializer_test.go b/pkg/targets/influx/serializer_test.go index aaa78ee..c49232f 100644 --- a/pkg/targets/influx/serializer_test.go +++ b/pkg/targets/influx/serializer_test.go @@ -36,6 +36,6 @@ func TestInfluxSerializerSerialize(t *testing.T) { Output: "cpu usage_guest_nice=38.24311829 1451606400000000000\n", }, } - + serialize.SerializerTest(t, cases, &Serializer{}) } diff --git a/pkg/targets/targets.go b/pkg/targets/targets.go index 75e2589..b2bf0be 100644 --- a/pkg/targets/targets.go +++ b/pkg/targets/targets.go @@ -2,11 +2,11 @@ package targets import ( "github.com/blagojts/viper" - "github.com/spf13/pflag" "github.com/cnosdb/tsdb-comparisons/pkg/data" "github.com/cnosdb/tsdb-comparisons/pkg/data/serialize" "github.com/cnosdb/tsdb-comparisons/pkg/data/source" "github.com/cnosdb/tsdb-comparisons/pkg/data/usecases/common" + "github.com/spf13/pflag" ) type ImplementedTarget interface { @@ -57,16 +57,16 @@ type BatchFactory interface { type Benchmark interface { // GetDataSource returns the DataSource to use for this Benchmark GetDataSource() DataSource - + // GetBatchFactory returns the BatchFactory to use for this Benchmark GetBatchFactory() BatchFactory - + // GetPointIndexer returns the PointIndexer to use for this Benchmark GetPointIndexer(maxPartitions uint) PointIndexer - + // GetProcessor returns the Processor to use for this Benchmark GetProcessor() Processor - + // GetDBCreator returns the DBCreator to use for this Benchmark GetDBCreator() DBCreator } diff --git a/pkg/targets/timescaledb/benchmark.go b/pkg/targets/timescaledb/benchmark.go index 7bfd4dd..7ac157f 100644 --- a/pkg/targets/timescaledb/benchmark.go +++ b/pkg/targets/timescaledb/benchmark.go @@ -21,7 +21,7 @@ func NewBenchmark(dbName string, opts *LoadingOptions, dataSourceConfig *source. } ds = newSimulationDataSource(simulator) } - + return &benchmark{ opts: opts, ds: ds, diff --git a/pkg/targets/timescaledb/creator.go b/pkg/targets/timescaledb/creator.go index f78b9c3..7eacb32 100644 --- a/pkg/targets/timescaledb/creator.go +++ b/pkg/targets/timescaledb/creator.go @@ -7,9 +7,9 @@ import ( "regexp" "strings" "time" - + "github.com/cnosdb/tsdb-comparisons/pkg/targets" - + _ "github.com/jackc/pgx/v4/stdlib" ) @@ -42,7 +42,7 @@ func (d *dbCreator) initConnectString() { // Needed to connect to user's database in order to drop/create db-name database re := regexp.MustCompile(`(dbname)=\S*\b`) d.connStr = strings.TrimSpace(re.ReplaceAllString(d.connStr, "")) - + if d.connDB != "" { d.connStr = fmt.Sprintf("dbname=%s %s", d.connDB, d.connStr) } @@ -82,7 +82,7 @@ func (d *dbCreator) CreateDB(dbName string) error { func (d *dbCreator) PostCreateDB(dbName string) error { dbBench := MustConnect(d.driver, d.opts.GetConnectString(dbName)) defer dbBench.Close() - + headers := d.ds.Headers() tagNames := headers.TagKeys tagTypes := headers.TagTypes @@ -93,7 +93,7 @@ func (d *dbCreator) PostCreateDB(dbName string) error { tableCols[tagsKey] = tagNames // tagTypes holds the type of each tag value (as strings from Go types (string, float32...)) d.opts.TagColumnTypes = tagTypes - + // Each table is defined in the dbCreator 'cols' list. The definition consists of a // comma separated list of the table name followed by its columns. Iterate over each // definition to update our global cache and create the requisite tables and indexes @@ -128,14 +128,14 @@ func (d *dbCreator) getFieldAndIndexDefinitions(tableName string, columns []stri var fieldDefs []string var indexDefs []string var allCols []string - + partitioningField := tableCols[tagsKey][0] // If the user has specified that we should partition on the primary tags key, we // add that to the list of columns to create if d.opts.InTableTag { allCols = append(allCols, partitioningField) } - + allCols = append(allCols, columns...) extraCols := 0 // set to 1 when hostname is kept in-table for idx, field := range allCols { @@ -152,7 +152,7 @@ func (d *dbCreator) getFieldAndIndexDefinitions(tableName string, columns []stri idxType = "" extraCols = 1 } - + fieldDefs = append(fieldDefs, fmt.Sprintf("%s %s", field, fieldType)) // If the user specifies indexes on additional fields, add them to // our index definitions until we've reached the desired number of indexes @@ -171,17 +171,17 @@ func (d *dbCreator) createTableAndIndexes(dbBench *sql.DB, tableName string, fie // testing. For distributed queries, pushdown of JOINs is not yet // supported. var partitionColumn string = "tags_id" - + if d.opts.InTableTag { partitionColumn = tableCols[tagsKey][0] } - + MustExec(dbBench, fmt.Sprintf("DROP TABLE IF EXISTS %s", tableName)) MustExec(dbBench, fmt.Sprintf("CREATE TABLE %s (time timestamptz, tags_id integer, %s, additional_tags JSONB DEFAULT NULL)", tableName, strings.Join(fieldDefs, ","))) if d.opts.PartitionIndex { MustExec(dbBench, fmt.Sprintf("CREATE INDEX ON %s(%s, \"time\" DESC)", tableName, partitionColumn)) } - + // Only allow one or the other, it's probably never right to have both. // Experimentation suggests (so far) that for 100k devices it is better to // use --time-partition-index for reduced index lock contention. @@ -190,17 +190,17 @@ func (d *dbCreator) createTableAndIndexes(dbBench *sql.DB, tableName string, fie } else if d.opts.TimeIndex { MustExec(dbBench, fmt.Sprintf("CREATE INDEX ON %s(\"time\" DESC)", tableName)) } - + for _, indexDef := range indexDefs { MustExec(dbBench, indexDef) } - + if d.opts.UseHypertable { var creationCommand string = "create_hypertable" var partitionsOption string = "replication_factor => NULL" - + MustExec(dbBench, "CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE") - + // Replication factor determines whether we create a distributed hypertable // or not. If it is unset or zero, then we will create a regular // hypertable with no partitions. @@ -209,19 +209,19 @@ func (d *dbCreator) createTableAndIndexes(dbBench *sql.DB, tableName string, fie // data nodes. We currently use `create_hypertable` for both statements, the // default behavior is to create a distributed hypertable if `replication_factor` // is >= 1 - + // We assume a single partition hypertable. This provides an option to test // partitioning on regular hypertables if d.opts.NumberPartitions > 0 { partitionsOption = fmt.Sprintf("partitioning_column => '%s'::name, number_partitions => %v::smallint", partitionColumn, d.opts.NumberPartitions) } - + if d.opts.ReplicationFactor > 0 { // This gives us a future option of testing the impact of // multi-node replication across data nodes partitionsOption = fmt.Sprintf("partitioning_column => '%s'::name, replication_factor => %v::smallint", partitionColumn, d.opts.ReplicationFactor) } - + MustExec(dbBench, fmt.Sprintf("SELECT %s('%s'::regclass, 'time'::name, %s, chunk_time_interval => %d, create_default_indexes=>FALSE)", creationCommand, tableName, partitionsOption, d.opts.ChunkTime.Nanoseconds()/1000)) @@ -234,7 +234,7 @@ func (d *dbCreator) getCreateIndexOnFieldCmds(hypertable, field, idxType string) if idx == "" { continue } - + indexDef := "" if idx == TimeValueIdx { indexDef = fmt.Sprintf("(time DESC, %s)", field) @@ -243,7 +243,7 @@ func (d *dbCreator) getCreateIndexOnFieldCmds(hypertable, field, idxType string) } else { fatal("Unknown index type %v", idx) } - + ret = append(ret, fmt.Sprintf("CREATE INDEX ON %s %s", hypertable, indexDef)) } return ret @@ -257,7 +257,7 @@ func createTagsTable(db *sql.DB, tagNames, tagTypes []string, useJSON bool) { MustExec(db, "CREATE INDEX idxginp ON tags USING gin (tagset jsonb_path_ops);") return } - + MustExec(db, generateTagsTableQuery(tagNames, tagTypes)) MustExec(db, fmt.Sprintf("CREATE UNIQUE INDEX uniq1 ON tags(%s)", strings.Join(tagNames, ","))) MustExec(db, fmt.Sprintf("CREATE INDEX ON tags(%s)", tagNames[0])) @@ -269,7 +269,7 @@ func generateTagsTableQuery(tagNames, tagTypes []string) string { pgType := serializedTypeToPgType(tagTypes[i]) tagColumnDefinitions[i] = fmt.Sprintf("%s %s", tagName, pgType) } - + cols := strings.Join(tagColumnDefinitions, ", ") return fmt.Sprintf("CREATE TABLE tags(id SERIAL PRIMARY KEY, %s)", cols) } @@ -285,7 +285,7 @@ func extractTagNamesAndTypes(tags []string) ([]string, []string) { tagNames[i] = tagAndType[0] tagTypes[i] = tagAndType[1] } - + return tagNames, tagTypes } diff --git a/pkg/targets/timescaledb/file_data_source.go b/pkg/targets/timescaledb/file_data_source.go index 5335674..5c645e8 100644 --- a/pkg/targets/timescaledb/file_data_source.go +++ b/pkg/targets/timescaledb/file_data_source.go @@ -3,7 +3,7 @@ package timescaledb import ( "bufio" "strings" - + "github.com/cnosdb/tsdb-comparisons/load" "github.com/cnosdb/tsdb-comparisons/pkg/data" "github.com/cnosdb/tsdb-comparisons/pkg/data/usecases/common" @@ -54,7 +54,7 @@ func (d *fileDataSource) Headers() *common.GeneratedDataHeaders { } i++ } - + tagsarr := strings.Split(tags, ",") if tagsarr[0] != tagsKey { fatal("input header in wrong format. got '%s', expected 'tags'", tags[0]) @@ -88,7 +88,7 @@ func (d *fileDataSource) NextItem() data.LoadedPoint { fatal("scan error: %v", d.scanner.Err()) return data.LoadedPoint{} } - + // The first line is a CSV line of tags with the first element being "tags" parts := strings.SplitN(d.scanner.Text(), ",", 2) // prefix & then rest of line prefix := parts[0] @@ -97,7 +97,7 @@ func (d *fileDataSource) NextItem() data.LoadedPoint { return data.LoadedPoint{} } newPoint.tags = parts[1] - + // Scan again to get the data line ok = d.scanner.Scan() if !ok { @@ -107,7 +107,7 @@ func (d *fileDataSource) NextItem() data.LoadedPoint { parts = strings.SplitN(d.scanner.Text(), ",", 2) // prefix & then rest of line prefix = parts[0] newPoint.fields = parts[1] - + return data.NewLoadedPoint(&point{ hypertable: prefix, row: newPoint, diff --git a/pkg/targets/timescaledb/implemented_target.go b/pkg/targets/timescaledb/implemented_target.go index 09c6b11..49e86bf 100644 --- a/pkg/targets/timescaledb/implemented_target.go +++ b/pkg/targets/timescaledb/implemented_target.go @@ -2,13 +2,13 @@ package timescaledb import ( "time" - + "github.com/blagojts/viper" - "github.com/spf13/pflag" "github.com/cnosdb/tsdb-comparisons/pkg/data/serialize" "github.com/cnosdb/tsdb-comparisons/pkg/data/source" "github.com/cnosdb/tsdb-comparisons/pkg/targets" "github.com/cnosdb/tsdb-comparisons/pkg/targets/constants" + "github.com/spf13/pflag" ) func NewTarget() targets.ImplementedTarget { @@ -45,27 +45,27 @@ func (t *timescaleTarget) TargetSpecificFlags(flagPrefix string, flagSet *pflag. flagSet.String(flagPrefix+"admin-db-name", "postgres", "Database to connect to in order to create additional benchmark databases.\n"+ "By default this is the same as the `user` (i.e., `postgres` if neither is set),\n"+ "but sometimes a user does not have its own database.") - + flagSet.Bool(flagPrefix+"log-batches", false, "Whether to time individual batches.") - + flagSet.Bool(flagPrefix+"use-hypertable", true, "Whether to make the table a hypertable. Set this flag to false to check input write speed against regular PostgreSQL.") flagSet.Bool(flagPrefix+"use-jsonb-tags", false, "Whether tags should be stored as JSONB (instead of a separate table with schema)") flagSet.Bool(flagPrefix+"in-table-partition-tag", false, "Whether the partition key (e.g. hostname) should also be in the metrics hypertable") - + flagSet.Int(flagPrefix+"replication-factor", 0, "Setting replication factor >= 1 will create a distributed hypertable") flagSet.Int(flagPrefix+"partitions", 0, "Number of partitions") flagSet.Duration(flagPrefix+"chunk-time", 12*time.Hour, "Duration that each chunk should represent, e.g., 12h") - + flagSet.Bool(flagPrefix+"time-index", true, "Whether to build an index on the time dimension") flagSet.Bool(flagPrefix+"time-partition-index", false, "Whether to build an index on the time dimension, compounded with partition") flagSet.Bool(flagPrefix+"partition-index", true, "Whether to build an index on the partition key") flagSet.String(flagPrefix+"field-index", ValueTimeIdx, "index types for tags (comma delimited)") flagSet.Int(flagPrefix+"field-index-count", 0, "Number of indexed fields (-1 for all)") - + flagSet.String(flagPrefix+"write-profile", "", "File to output CPU/memory profile to") flagSet.String(flagPrefix+"write-replication-stats", "", "File to output replication stats to") flagSet.Bool(flagPrefix+"create-metrics-table", true, "Drops existing and creates new metrics table. Can be used for both regular and hypertable") - + flagSet.Bool(flagPrefix+"use-insert", false, "Provides the option to test data inserts with batched INSERT commands rather than the preferred COPY function") flagSet.Bool(flagPrefix+"force-text-format", false, "Send/receive data in text format") } diff --git a/pkg/targets/timescaledb/process.go b/pkg/targets/timescaledb/process.go index 3ea9a42..6a6a973 100644 --- a/pkg/targets/timescaledb/process.go +++ b/pkg/targets/timescaledb/process.go @@ -12,9 +12,9 @@ import ( "strings" "sync" "time" - + "github.com/cnosdb/tsdb-comparisons/pkg/targets" - + "github.com/jackc/pgx/v4" "github.com/jackc/pgx/v4/stdlib" "github.com/lib/pq" @@ -88,7 +88,7 @@ func (p *processor) insertTags(db *sql.DB, tagRows [][]string) map[string]int64 if err != nil { panic(err) } - + ret := p.sqlTagsToCacheLine(res, err, tagCols) return ret } @@ -107,7 +107,7 @@ func (p *processor) sqlTagsToCacheLine(res *sql.Rows, err error, tagCols []strin if err != nil { panic(err) } - + var key string if p.opts.UseJSON { decodedTagset := map[string]string{} @@ -131,7 +131,7 @@ func (p *processor) splitTagsAndMetrics(rows []*insertData, dataCols int) ([][]s dataRows := make([][]interface{}, 0, len(rows)) numMetrics := uint64(0) commonTagsLen := len(tableCols[tagsKey]) - + for _, data := range rows { // Split the tags into individual common tags and an extra bit leftover // for non-common tags that need to be added separately. For each of @@ -141,21 +141,21 @@ func (p *processor) splitTagsAndMetrics(rows []*insertData, dataCols int) ([][]s for i := 0; i < commonTagsLen; i++ { tags[i] = strings.Split(tags[i], "=")[1] } - + var json interface{} if len(tags) > commonTagsLen { json = subsystemTagsToJSON(strings.Split(tags[commonTagsLen], ",")) } - + metrics := strings.Split(data.fields, ",") numMetrics += uint64(len(metrics) - 1) // 1 field is timestamp - + timeInt, err := strconv.ParseInt(metrics[0], 10, 64) if err != nil { panic(err) } ts := time.Unix(0, timeInt) - + // use nil at 2nd position as placeholder for tagKey r := make([]interface{}, 3, dataCols) r[0], r[1], r[2] = ts, nil, json @@ -167,19 +167,19 @@ func (p *processor) splitTagsAndMetrics(rows []*insertData, dataCols int) ([][]s r = append(r, nil) continue } - + num, err := strconv.ParseFloat(v, 64) if err != nil { panic(err) } - + r = append(r, num) } - + dataRows = append(dataRows, r) tagRows = append(tagRows, tags[:commonTagsLen]) } - + return tagRows, dataRows, numMetrics } @@ -189,7 +189,7 @@ func (p *processor) processCSI(hypertable string, rows []*insertData) uint64 { colLen++ } tagRows, dataRows, numMetrics := p.splitTagsAndMetrics(rows, colLen) - + // Check if any of these tags has yet to be inserted newTags := make([][]string, 0, len(rows)) p._csi.mutex.RLock() @@ -207,28 +207,28 @@ func (p *processor) processCSI(hypertable string, rows []*insertData) uint64 { } p._csi.mutex.Unlock() } - + p._csi.mutex.RLock() for i := range dataRows { tagKey := tagRows[i][0] dataRows[i][1] = p._csi.m[tagKey] } p._csi.mutex.RUnlock() - + cols := make([]string, 0, colLen) cols = append(cols, "time", "tags_id", "additional_tags") if p.opts.InTableTag { cols = append(cols, tableCols[tagsKey][0]) } cols = append(cols, tableCols[hypertable]...) - + if p.opts.ForceTextFormat { tx := MustBegin(p._db) stmt, err := tx.Prepare(pq.CopyIn(hypertable, cols...)) if err != nil { panic(err) } - + for _, r := range dataRows { stmt.Exec(r...) } @@ -236,12 +236,12 @@ func (p *processor) processCSI(hypertable string, rows []*insertData) uint64 { if err != nil { panic(err) } - + err = stmt.Close() if err != nil { panic(err) } - + err = tx.Commit() if err != nil { panic(err) @@ -250,11 +250,11 @@ func (p *processor) processCSI(hypertable string, rows []*insertData) uint64 { if !p.opts.UseInsert { rows := pgx.CopyFromRows(dataRows) inserted, err := p._pgxConn.CopyFrom(context.Background(), pgx.Identifier{hypertable}, cols, rows) - + if err != nil { panic(err) } - + if inserted != int64(len(dataRows)) { fmt.Fprintf(os.Stderr, "Failed to insert all the data! Expected: %d, Got: %d", len(dataRows), inserted) os.Exit(1) @@ -263,27 +263,27 @@ func (p *processor) processCSI(hypertable string, rows []*insertData) uint64 { tx := MustBegin(p._db) var stmt *sql.Stmt var err error - + stmtString := genBatchInsertStmt(hypertable, cols, len(dataRows)) stmt, err = tx.Prepare(stmtString) - + _, err = stmt.Exec(flatten(dataRows)...) if err != nil { panic(err) } - + err = stmt.Close() if err != nil { panic(err) } - + err = tx.Commit() if err != nil { panic(err) } } } - + return numMetrics } @@ -390,7 +390,7 @@ func (p *processor) ProcessBatch(b targets.Batch, doLoad bool) (uint64, uint64) if doLoad { start := time.Now() metricCnt += p.processCSI(hypertable, rows) - + if p.opts.LogBatches { now := time.Now() took := now.Sub(start) @@ -425,6 +425,6 @@ func convertValsToBasedOnType(values []string, types []string, quotemark string, sqlVals[i] = val } } - + return sqlVals } diff --git a/pkg/targets/timescaledb/scan.go b/pkg/targets/timescaledb/scan.go index 49eb5d5..aef2682 100644 --- a/pkg/targets/timescaledb/scan.go +++ b/pkg/targets/timescaledb/scan.go @@ -3,7 +3,7 @@ package timescaledb import ( "hash/fnv" "strings" - + "github.com/cnosdb/tsdb-comparisons/pkg/data" "github.com/cnosdb/tsdb-comparisons/pkg/targets" ) @@ -51,7 +51,7 @@ type factory struct{} func (f *factory) New() targets.Batch { return &hypertableArr{ - m: map[string][]*insertData{}, + m: map[string][]*insertData{}, cnt: 0, } } diff --git a/pkg/targets/timescaledb/scan_test.go b/pkg/targets/timescaledb/scan_test.go index 7b825e5..af27038 100644 --- a/pkg/targets/timescaledb/scan_test.go +++ b/pkg/targets/timescaledb/scan_test.go @@ -7,7 +7,7 @@ import ( "log" "strings" "testing" - + "github.com/cnosdb/tsdb-comparisons/pkg/data" "github.com/cnosdb/tsdb-comparisons/pkg/data/usecases/common" ) @@ -21,7 +21,7 @@ func TestHostnameIndexer(t *testing.T) { hypertable: "foo", row: &insertData{fields: "0.0,1.0,2.0"}, } - + // single partition check indexer := &hostnameIndexer{1} for _, r := range tagRows { @@ -31,7 +31,7 @@ func TestHostnameIndexer(t *testing.T) { t.Errorf("did not get idx 0 for single partition") } } - + // multiple partition check cases := []uint{2, 10, 100} for _, n := range cases { @@ -223,13 +223,13 @@ func TestFileDataSourceHeaders(t *testing.T) { shouldFatal: true, }, } - + for _, c := range cases { br := bufio.NewReader(bytes.NewReader([]byte(c.input))) ds := &fileDataSource{ scanner: bufio.NewScanner(br), } - + if c.shouldFatal { isCalled := false fatal = func(fmt string, args ...interface{}) { @@ -242,7 +242,7 @@ func TestFileDataSourceHeaders(t *testing.T) { } } else { headers := ds.Headers() - + gotKeys := strings.Join(headers.TagKeys, ",") if gotKeys != c.wantTags { t.Errorf("%s: incorrect tags: got\n%s\nwant\n%s", c.desc, gotKeys, c.wantTags) @@ -251,7 +251,7 @@ func TestFileDataSourceHeaders(t *testing.T) { if gotKeyTypes != c.wantTypes { t.Errorf("%s: incorrect types: got\n%s\nwant\n%s", c.desc, gotKeyTypes, c.wantTypes) } - + if len(headers.FieldKeys) != len(c.wantCols) { t.Errorf("%s: incorrect cols len: got %d want %d", c.desc, len(headers.FieldKeys), len(c.wantCols)) } diff --git a/pkg/targets/timescaledb/serializer.go b/pkg/targets/timescaledb/serializer.go index d1ecf0f..2174e83 100644 --- a/pkg/targets/timescaledb/serializer.go +++ b/pkg/targets/timescaledb/serializer.go @@ -34,7 +34,7 @@ func (s *Serializer) Serialize(p *data.Point, w io.Writer) error { if err != nil { return err } - + // Field row second buf = make([]byte, 0, 256) buf = append(buf, p.MeasurementName()...) diff --git a/pkg/targets/timescaledb/serializer_test.go b/pkg/targets/timescaledb/serializer_test.go index 804bc71..fcbdf47 100644 --- a/pkg/targets/timescaledb/serializer_test.go +++ b/pkg/targets/timescaledb/serializer_test.go @@ -28,7 +28,7 @@ func TestTimescaleDBSerializerSerialize(t *testing.T) { Output: "tags\ncpu,1451606400000000000,38.24311829\n", }, } - + serialize.SerializerTest(t, cases, &Serializer{}) } diff --git a/pkg/targets/timescaledb/simulation_data_source.go b/pkg/targets/timescaledb/simulation_data_source.go index 2329e4a..46f39cb 100644 --- a/pkg/targets/timescaledb/simulation_data_source.go +++ b/pkg/targets/timescaledb/simulation_data_source.go @@ -2,7 +2,7 @@ package timescaledb import ( "fmt" - + "github.com/cnosdb/tsdb-comparisons/pkg/data" "github.com/cnosdb/tsdb-comparisons/pkg/data/serialize" "github.com/cnosdb/tsdb-comparisons/pkg/data/usecases/common" @@ -25,7 +25,7 @@ func (d *simulationDataSource) Headers() *common.GeneratedDataHeaders { if d.headers != nil { return d.headers } - + d.headers = d.simulator.Headers() return d.headers } @@ -68,9 +68,9 @@ func (d *simulationDataSource) NextItem() data.LoadedPoint { buf = append(buf, ',') buf = serialize.FastFormatAppend(v, buf) } - + newLoadPoint.fields = string(buf) - + return data.NewLoadedPoint(&point{ hypertable: string(newSimulatorPoint.MeasurementName()), row: newLoadPoint, From dfb2810922e7ecbda6fdd98c938b4d918ac8ce0d Mon Sep 17 00:00:00 2001 From: Subsegment <304741833@qq.com> Date: Thu, 29 Sep 2022 16:23:59 +0800 Subject: [PATCH 3/7] add grpc --- cmd/load_cnosdb/http_writer.go | 68 ++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 20 deletions(-) diff --git a/cmd/load_cnosdb/http_writer.go b/cmd/load_cnosdb/http_writer.go index bc700a3..adf9f8d 100644 --- a/cmd/load_cnosdb/http_writer.go +++ b/cmd/load_cnosdb/http_writer.go @@ -4,11 +4,14 @@ package main import ( "bytes" + "context" "errors" "fmt" "github.com/cnosdb/tsdb-comparisons/cmd/load_cnosdb/models" + proto "github.com/cnosdb/tsdb-comparisons/cmd/load_cnosdb/proto" flatbuffers "github.com/google/flatbuffers/go" "github.com/valyala/fasthttp" + "google.golang.org/grpc" "strconv" "time" "unsafe" @@ -47,7 +50,8 @@ type HTTPWriterConfig struct { // HTTPWriter is a Writer that writes to an CnosDB HTTP server. type HTTPWriter struct { - client fasthttp.Client + client fasthttp.Client + grpcClient proto.TSKVService_WritePointsClient c HTTPWriterConfig url []byte @@ -55,13 +59,23 @@ type HTTPWriter struct { // NewHTTPWriter returns a new HTTPWriter from the supplied HTTPWriterConfig. func NewHTTPWriter(c HTTPWriterConfig, consistency string) *HTTPWriter { + conn, err := grpc.Dial(c.Host, grpc.WithInsecure(), grpc.WithBlock(), grpc.WithTimeout(10*time.Second)) + if err != nil { + panic(err) + } + grpcClient := proto.NewTSKVServiceClient(conn) + writePointsCli, err := grpcClient.WritePoints(context.Background()) + if err != nil { + panic(err) + } + return &HTTPWriter{ client: fasthttp.Client{ Name: httpClientName, }, - - c: c, - url: []byte(c.Host + "/write"), + grpcClient: writePointsCli, + c: c, + url: []byte(c.Host + "/write"), } } @@ -101,20 +115,34 @@ func (w *HTTPWriter) executeReq(req *fasthttp.Request, resp *fasthttp.Response) // It returns the latency in nanoseconds and any error received while sending the data over HTTP, // or it returns a new error if the HTTP response isn't as expected. func (w *HTTPWriter) WriteLineProtocol(body []byte, isGzip bool) (int64, error) { - //client := TSKVServiceClient - req := fasthttp.AcquireRequest() - defer fasthttp.ReleaseRequest(req) - w.initializeReq(req, body, isGzip) - - resp := fasthttp.AcquireResponse() - defer fasthttp.ReleaseResponse(resp) + //req := fasthttp.AcquireRequest() + //defer fasthttp.ReleaseRequest(req) + //w.initializeReq(req, body, isGzip) + // + //resp := fasthttp.AcquireResponse() + //defer fasthttp.ReleaseResponse(resp) + // + //return w.executeReq(req, resp) + + err := w.grpcClient.Send(&proto.WritePointsRpcRequest{ + Points: body, + }) + if err != nil { + panic(err) + } - return w.executeReq(req, resp) + //_, err = w.grpcClient.Recv() + //if err != nil { + // panic(err) + //} + //w.grpcClient.CloseSend() + return 200, nil } func parserLine(lines []byte) []byte { - pointFb := flatbuffers.NewBuilder(0) + //pointFb := flatbuffers.NewBuilder(0) fb := flatbuffers.NewBuilder(0) + database := fb.CreateByteString([]byte("public")) numLines := bytes.Count(lines, []byte{'\n'}) var pointOffs []flatbuffers.UOffsetT @@ -144,12 +172,12 @@ func parserLine(lines []byte) []byte { fb.PrependUOffsetT(i) } ptVec := fb.EndVector(numLines) - models.PointsStart(pointFb) - models.PointsAddPoints(pointFb, ptVec) - models.PointsAddDatabase(pointFb, pointFb.CreateByteString([]byte("public"))) - endPoints := models.PointsEnd(pointFb) - pointFb.Finish(endPoints) - return pointFb.FinishedBytes() + models.PointsStart(fb) + models.PointsAddPoints(fb, ptVec) + models.PointsAddDatabase(fb, database) + endPoints := models.PointsEnd(fb) + fb.Finish(endPoints) + return fb.FinishedBytes() } func backpressurePred(body []byte) bool { @@ -220,7 +248,7 @@ func scanLine(buf []byte, i int) (int, []byte) { } - return i, buf[start:i] + return i + 1, buf[start:i] } func skipWhitespace(buf []byte, i int) int { From d55709464e94a9d511311d09dd2a273de8431108 Mon Sep 17 00:00:00 2001 From: zipper-meng Date: Wed, 26 Oct 2022 17:35:58 +0800 Subject: [PATCH 4/7] fix: generated invalid flatbuffers data --- cmd/load_cnosdb/http_writer.go | 212 +++++++++++++++++++++++++++------ cmd/load_cnosdb/process.go | 6 +- load/loader.go | 6 +- 3 files changed, 181 insertions(+), 43 deletions(-) diff --git a/cmd/load_cnosdb/http_writer.go b/cmd/load_cnosdb/http_writer.go index adf9f8d..66afeca 100644 --- a/cmd/load_cnosdb/http_writer.go +++ b/cmd/load_cnosdb/http_writer.go @@ -5,16 +5,18 @@ package main import ( "bytes" "context" + "encoding/binary" "errors" "fmt" + "strconv" + "time" + "unsafe" + "github.com/cnosdb/tsdb-comparisons/cmd/load_cnosdb/models" proto "github.com/cnosdb/tsdb-comparisons/cmd/load_cnosdb/proto" flatbuffers "github.com/google/flatbuffers/go" "github.com/valyala/fasthttp" "google.golang.org/grpc" - "strconv" - "time" - "unsafe" ) const ( @@ -75,7 +77,7 @@ func NewHTTPWriter(c HTTPWriterConfig, consistency string) *HTTPWriter { }, grpcClient: writePointsCli, c: c, - url: []byte(c.Host + "/write"), + url: []byte(c.Host + "/api/v1/write?db=" + c.Database), } } @@ -88,8 +90,7 @@ func (w *HTTPWriter) initializeReq(req *fasthttp.Request, body []byte, isGzip bo req.Header.SetContentTypeBytes(textPlain) req.Header.SetMethodBytes(methodPost) req.Header.SetRequestURIBytes(w.url) - req.Header.Add("database", w.c.Database) - req.Header.Add("user_id", w.c.Auth) + req.Header.Set("AUTHORIZATION", w.c.Auth) if isGzip { req.Header.Add(headerContentEncoding, headerGzip) } @@ -111,6 +112,63 @@ func (w *HTTPWriter) executeReq(req *fasthttp.Request, resp *fasthttp.Response) return lat, err } +func printFlatbuffersBody(body []byte) { + fmt.Printf("\nBody Length: %v\n", len(body)) + points := models.GetRootAsPoints(body, 0) + point := &models.Point{} + tag := &models.Tag{} + field := &models.Field{} + for i := 0; i < points.PointsLength(); i++ { + points.Points(point, i) + fmt.Printf("Tags[%d]: ", point.TagsLength()) + for j := 0; j < point.TagsLength(); j++ { + point.Tags(tag, j) + if tag.KeyLength() == 0 { + println("Key is empty") + } + tagKey := string(tag.KeyBytes()) + fmt.Printf("{ %s: ", tagKey) + if tag.KeyLength() == 0 { + println("Value is empty") + } + tagValue := string(tag.ValueBytes()) + fmt.Printf("%s }, ", tagValue) + } + fmt.Printf("\nFields[%d]: ", point.FieldsLength()) + for j := 0; j < point.FieldsLength(); j++ { + point.Fields(field, j) + fieldName := string(field.NameBytes()) + fmt.Printf("{ %s: ", fieldName) + fieldType := field.Type() + switch fieldType { + case models.FieldTypeInteger: + fieldValue := binary.BigEndian.Uint64(field.ValueBytes()) + fmt.Printf("%d, ", int64(fieldValue)) + case models.FieldTypeUnsigned: + fieldValue := binary.BigEndian.Uint64(field.ValueBytes()) + fmt.Printf("%d, ", fieldValue) + case models.FieldTypeFloat: + fieldValue := binary.BigEndian.Uint64(field.ValueBytes()) + fmt.Printf("%f, ", float64(fieldValue)) + case models.FieldTypeBoolean: + fieldValue := field.ValueBytes() + if fieldValue[0] == 1 { + fmt.Printf("true, ") + } else { + fmt.Printf("false, ") + } + case models.FieldTypeString: + fieldValue := string(field.ValueBytes()) + fmt.Printf("%s, ", fieldValue) + default: + + } + fmt.Printf("%d }, ", field.Type()) + } + fmt.Println() + } +} + // WriteLineProtocol writes the given byte slice to the HTTP server described in the Writer's HTTPWriterConfig. // It returns the latency in nanoseconds and any error received while sending the data over HTTP, // or it returns a new error if the HTTP response isn't as expected. @@ -262,6 +320,7 @@ func skipWhitespace(buf []byte, i int) int { } func parsePoint(fb *flatbuffers.Builder, buf []byte) flatbuffers.UOffsetT { + dbOff := fb.CreateByteVector([]byte("tsdb-comparisons")) pos, key, err, mPos := scanKey(buf, 0) if err != nil { @@ -276,13 +335,13 @@ func parsePoint(fb *flatbuffers.Builder, buf []byte) flatbuffers.UOffsetT { } tableOff := fb.CreateByteVector(buf[0 : mPos-1]) - tkValOffs, tvValOffs := parseTags(fb, buf[mPos:]) + tkValOffs, tvValOffs := parseTags(fb, key[mPos:]) tagOffs := make([]flatbuffers.UOffsetT, len(tkValOffs)) for i := 0; i < len(tkValOffs); i++ { models.TagStart(fb) models.TagAddKey(fb, tkValOffs[i]) - models.TagAddKey(fb, tvValOffs[i]) - tagOffs = append(tagOffs, models.TagEnd(fb)) + models.TagAddValue(fb, tvValOffs[i]) + tagOffs[i] = models.TagEnd(fb) } models.PointStartTagsVector(fb, len(tagOffs)) for _, off := range tagOffs { @@ -290,7 +349,7 @@ func parsePoint(fb *flatbuffers.Builder, buf []byte) flatbuffers.UOffsetT { } tagsOff := fb.EndVector(len(tagOffs)) - pos, fields, err := scanFields(buf, pos) + pos, fields, fieldTypes, err := scanFields(buf, pos) if err != nil { panic(err) } @@ -303,9 +362,73 @@ func parsePoint(fb *flatbuffers.Builder, buf []byte) flatbuffers.UOffsetT { var fvOffs []flatbuffers.UOffsetT var fTyps []models.FieldType err = walkFields(fields, func(k, v []byte) bool { + //fmt.Print("FieldKey: " + string(k) + ", FieldValue: " + string(v)) fkOffs = append(fkOffs, fb.CreateByteVector(k)) - fvOffs = append(fvOffs, fb.CreateByteVector(v)) - fTyps = append(fTyps, models.FieldTypeUnknown) + + isNegative := false + fieldValStr := string(v) + if fieldValStr[0] == '-' { + isNegative = true + fieldValStr = fieldValStr[1:] + } else if fieldValStr[0] == '+' { + fieldValStr = fieldValStr[1:] + } + + fType := fieldTypes[0] + fieldTypes = fieldTypes[1:] + numBuf := make([]byte, 8) + switch fType { + case models.FieldTypeInteger: + //fmt.Println(", FieldType: Integer") + fv, _ := strconv.ParseInt(fieldValStr[:len(fieldValStr)-1], 10, 64) + if isNegative { + fv = -fv + } + binary.BigEndian.PutUint64(numBuf, uint64(fv)) + fvOffs = append(fvOffs, fb.CreateByteVector(numBuf)) + fTyps = append(fTyps, models.FieldTypeInteger) + case models.FieldTypeUnsigned: + //fmt.Println(", FieldType: Unsigned") + fv, _ := strconv.ParseUint(fieldValStr[:len(fieldValStr)-1], 10, 64) + if isNegative { + fv = -fv + } + binary.BigEndian.PutUint64(numBuf, fv) + fvOffs = append(fvOffs, fb.CreateByteVector(numBuf)) + fTyps = append(fTyps, models.FieldTypeUnsigned) + case models.FieldTypeFloat: + //fmt.Println(", FieldType: Float") + fv, _ := strconv.ParseFloat(fieldValStr, 10) + if isNegative { + fv = -fv + } + binary.BigEndian.PutUint64(numBuf, uint64(fv)) + fvOffs = append(fvOffs, fb.CreateByteVector(numBuf)) + fTyps = append(fTyps, models.FieldTypeFloat) + case models.FieldTypeBoolean: + //fmt.Println(", FieldType: Boolean") + if fieldValStr[0] == 't' || fieldValStr[0] == 'T' { + fvOffs = append(fvOffs, fb.CreateByteVector([]byte{1})) + fTyps = append(fTyps, models.FieldTypeBoolean) + } else if fieldValStr[0] == 'f' || fieldValStr[0] == 'F' { + fvOffs = append(fvOffs, fb.CreateByteVector([]byte{0})) + fTyps = append(fTyps, models.FieldTypeBoolean) + } + case models.FieldTypeString: + //fmt.Println(", FieldType: String") + if fieldValStr[0] == '"' { + fvOffs = append(fvOffs, fb.CreateByteVector([]byte(fieldValStr[1:len(fieldValStr)-1]))) + fTyps = append(fTyps, models.FieldTypeString) + } else { + fvOffs = append(fvOffs, fb.CreateByteVector(v)) + fTyps = append(fTyps, models.FieldTypeString) + } + default: + //fmt.Println(", FieldType: Unknown") + fvOffs = append(fvOffs, fb.CreateByteVector(v)) + fTyps = append(fTyps, models.FieldTypeString) + } + i++ return true }) @@ -315,7 +438,7 @@ func parsePoint(fb *flatbuffers.Builder, buf []byte) flatbuffers.UOffsetT { models.FieldAddName(fb, fkOffs[i]) models.FieldAddValue(fb, fvOffs[i]) models.FieldAddType(fb, fTyps[i]) - fieldOffs = append(fieldOffs, models.FieldEnd(fb)) + fieldOffs[i] = models.FieldEnd(fb) } models.PointStartFieldsVector(fb, len(fieldOffs)) for _, off := range fieldOffs { @@ -330,7 +453,8 @@ func parsePoint(fb *flatbuffers.Builder, buf []byte) flatbuffers.UOffsetT { } models.PointStart(fb) - models.PointAddDb(fb, tableOff) + models.PointAddDb(fb, dbOff) + models.PointAddTable(fb, tableOff) models.PointAddTags(fb, tagsOff) models.PointAddFields(fb, fieldsOff) models.PointAddTimestamp(fb, int64(tsInt)) @@ -799,7 +923,7 @@ type escapeSet struct { esc [2]byte } -func scanFields(buf []byte, i int) (int, []byte, error) { +func scanFields(buf []byte, i int) (int, []byte, []models.FieldType, error) { start := skipWhitespace(buf, i) i = start quoted := false @@ -810,6 +934,8 @@ func scanFields(buf []byte, i int) (int, []byte, error) { // tracks how many commas we've seen commas := 0 + var types []models.FieldType + var typ models.FieldType for { // reached the end of buf? if i >= len(buf) { @@ -826,6 +952,7 @@ func scanFields(buf []byte, i int) (int, []byte, error) { // Only quote values in the field value since quotes are not significant // in the field key if buf[i] == '"' && equals > commas { + types = append(types, models.FieldTypeBoolean) quoted = !quoted i++ continue @@ -837,38 +964,40 @@ func scanFields(buf []byte, i int) (int, []byte, error) { // check for "... =123" but allow "a\ =123" if buf[i-1] == ' ' && buf[i-2] != '\\' { - return i, buf[start:i], fmt.Errorf("missing field key") + return i, buf[start:i], types, fmt.Errorf("missing field key") } // check for "...a=123,=456" but allow "a=123,a\,=456" if buf[i-1] == ',' && buf[i-2] != '\\' { - return i, buf[start:i], fmt.Errorf("missing field key") + return i, buf[start:i], types, fmt.Errorf("missing field key") } // check for "... value=" if i+1 >= len(buf) { - return i, buf[start:i], fmt.Errorf("missing field value") + return i, buf[start:i], types, fmt.Errorf("missing field value") } // check for "... value=,value2=..." if buf[i+1] == ',' || buf[i+1] == ' ' { - return i, buf[start:i], fmt.Errorf("missing field value") + return i, buf[start:i], types, fmt.Errorf("missing field value") } if isNumeric(buf[i+1]) || buf[i+1] == '-' || buf[i+1] == 'N' || buf[i+1] == 'n' { var err error - i, err = scanNumber(buf, i+1) + typ, i, err = scanNumber(buf, i+1) if err != nil { - return i, buf[start:i], err + return i, buf[start:i], types, err } + types = append(types, typ) continue } // If next byte is not a double-quote, the value must be a boolean if buf[i+1] != '"' { var err error i, _, err = scanBoolean(buf, i+1) + types = append(types, models.FieldTypeBoolean) if err != nil { - return i, buf[start:i], err + return i, buf[start:i], types, err } continue } @@ -886,22 +1015,22 @@ func scanFields(buf []byte, i int) (int, []byte, error) { } if quoted { - return i, buf[start:i], fmt.Errorf("unbalanced quotes") + return i, buf[start:i], types, fmt.Errorf("unbalanced quotes") } // check that all field sections had key and values (e.g. prevent "a=1,b" if equals == 0 || commas != equals-1 { - return i, buf[start:i], fmt.Errorf("invalid field format") + return i, buf[start:i], types, fmt.Errorf("invalid field format") } - return i, buf[start:i], nil + return i, buf[start:i], types, nil } func isNumeric(b byte) bool { return (b >= '0' && b <= '9') || b == '.' } -func scanNumber(buf []byte, i int) (int, error) { +func scanNumber(buf []byte, i int) (models.FieldType, int, error) { start := i var isInt, isUnsigned bool @@ -910,7 +1039,7 @@ func scanNumber(buf []byte, i int) (int, error) { i++ // There must be more characters now, as just '-' is illegal. if i == len(buf) { - return i, ErrInvalidNumber + return models.FieldTypeUnknown, i, ErrInvalidNumber } } @@ -942,7 +1071,7 @@ func scanNumber(buf []byte, i int) (int, error) { if buf[i] == '.' { // Can't have more than 1 decimal (e.g. 1.1.1 should fail) if decimal { - return i, ErrInvalidNumber + return models.FieldTypeUnknown, i, ErrInvalidNumber } decimal = true } @@ -962,17 +1091,17 @@ func scanNumber(buf []byte, i int) (int, error) { // NaN is an unsupported value if i+2 < len(buf) && (buf[i] == 'N' || buf[i] == 'n') { - return i, ErrInvalidNumber + return models.FieldTypeUnknown, i, ErrInvalidNumber } if !isNumeric(buf[i]) { - return i, ErrInvalidNumber + return models.FieldTypeUnknown, i, ErrInvalidNumber } i++ } if (isInt || isUnsigned) && (decimal || scientific) { - return i, ErrInvalidNumber + return models.FieldTypeUnknown, i, ErrInvalidNumber } numericDigits := i - start @@ -987,9 +1116,11 @@ func scanNumber(buf []byte, i int) (int, error) { } if numericDigits == 0 { - return i, ErrInvalidNumber + return models.FieldTypeUnknown, i, ErrInvalidNumber } + numType := models.FieldTypeUnknown + // It's more common that numbers will be within min/max range for their type but we need to prevent // out or range numbers from being parsed successfully. This uses some simple heuristics to decide // if we should parse the number to the actual type. It does not do it all the time because it incurs @@ -997,41 +1128,44 @@ func scanNumber(buf []byte, i int) (int, error) { if isInt { // Make sure the last char is an 'i' for integers (e.g. 9i10 is not valid) if buf[i-1] != 'i' { - return i, ErrInvalidNumber + return models.FieldTypeUnknown, i, ErrInvalidNumber } // Parse the int to check bounds the number of digits could be larger than the max range // We subtract 1 from the index to remove the `i` from our tests if len(buf[start:i-1]) >= maxInt64Digits || len(buf[start:i-1]) >= minInt64Digits { if _, err := parseIntBytes(buf[start:i-1], 10, 64); err != nil { - return i, fmt.Errorf("unable to parse integer %s: %s", buf[start:i-1], err) + return models.FieldTypeUnknown, i, fmt.Errorf("unable to parse integer %s: %s", buf[start:i-1], err) } } + numType = models.FieldTypeInteger } else if isUnsigned { // Make sure the last char is a 'u' for unsigned if buf[i-1] != 'u' { - return i, ErrInvalidNumber + return models.FieldTypeUnknown, i, ErrInvalidNumber } // Make sure the first char is not a '-' for unsigned if buf[start] == '-' { - return i, ErrInvalidNumber + return models.FieldTypeUnknown, i, ErrInvalidNumber } // Parse the uint to check bounds the number of digits could be larger than the max range // We subtract 1 from the index to remove the `u` from our tests if len(buf[start:i-1]) >= maxUint64Digits { if _, err := parseUintBytes(buf[start:i-1], 10, 64); err != nil { - return i, fmt.Errorf("unable to parse unsigned %s: %s", buf[start:i-1], err) + return models.FieldTypeUnknown, i, fmt.Errorf("unable to parse unsigned %s: %s", buf[start:i-1], err) } } + numType = models.FieldTypeUnsigned } else { // Parse the float to check bounds if it's scientific or the number of digits could be larger than the max range if scientific || len(buf[start:i]) >= maxFloat64Digits || len(buf[start:i]) >= minFloat64Digits { if _, err := parseFloatBytes(buf[start:i], 64); err != nil { - return i, fmt.Errorf("invalid float") + return models.FieldTypeUnknown, i, fmt.Errorf("invalid float") } } + numType = models.FieldTypeFloat } - return i, nil + return numType, i, nil } func scanBoolean(buf []byte, i int) (int, []byte, error) { diff --git a/cmd/load_cnosdb/process.go b/cmd/load_cnosdb/process.go index 4be0b2e..5f63189 100644 --- a/cmd/load_cnosdb/process.go +++ b/cmd/load_cnosdb/process.go @@ -2,10 +2,12 @@ package main import ( "bytes" + "encoding/base64" "fmt" + "time" + "github.com/cnosdb/tsdb-comparisons/pkg/targets" "github.com/valyala/fasthttp" - "time" ) const backingOffChanCap = 100 @@ -25,7 +27,7 @@ func (p *processor) Init(numWorker int, _, _ bool) { DebugInfo: fmt.Sprintf("worker #%d, dest url: %s", numWorker, daemonURL), Host: daemonURL, Database: loader.DatabaseName(), - Auth: config.Auth, + Auth: "Basic " + base64.StdEncoding.EncodeToString([]byte(config.User+":"+config.Password)), } w := NewHTTPWriter(cfg, consistency) p.initWithHTTPWriter(numWorker, w) diff --git a/load/loader.go b/load/loader.go index 5c7d06e..b54adf2 100644 --- a/load/loader.go +++ b/load/loader.go @@ -33,7 +33,8 @@ var ( // BenchmarkRunnerConfig contains all the configuration information required for running BenchmarkRunner. type BenchmarkRunnerConfig struct { DBName string `yaml:"db-name" mapstructure:"db-name" json:"db-name"` - Auth string `yaml:"user_id" mapstructure:"user_id" json:"user_id"` + User string `yaml:"user" mapstructure:"user" json:"user"` + Password string `yaml:"password" mapstructure:"password" json:"password"` BatchSize uint `yaml:"batch-size" mapstructure:"batch-size" json:"batch-size"` Workers uint `yaml:"workers" mapstructure:"workers" json:"workers"` Limit uint64 `yaml:"limit" mapstructure:"limit" json:"limit"` @@ -54,7 +55,8 @@ type BenchmarkRunnerConfig struct { // AddToFlagSet adds command line flags needed by the BenchmarkRunnerConfig to the flag set. func (c BenchmarkRunnerConfig) AddToFlagSet(fs *pflag.FlagSet) { fs.String("db-name", "benchmark", "Name of database") - fs.String("user_id", "123", "auth of database") + fs.String("user", "user", "user of database") + fs.String("password", "password", "password of database") fs.Uint("batch-size", defaultBatchSize, "Number of items to batch together in a single insert") fs.Uint("workers", 1, "Number of parallel clients inserting") fs.Uint64("limit", 0, "Number of items to insert (0 = all of them).") From c64b0dde815977d39f9c97fee73e26217d7dc5d7 Mon Sep 17 00:00:00 2001 From: zipper-meng Date: Mon, 7 Nov 2022 16:13:07 +0800 Subject: [PATCH 5/7] migrate to new version of models.fbs --- cmd/load_cnosdb/http_writer.go | 4 +- cmd/load_cnosdb/models/ColumnKey.go | 41 -- cmd/load_cnosdb/models/ColumnKeys.go | 66 -- cmd/load_cnosdb/models/ColumnKeysWithRange.go | 96 --- cmd/load_cnosdb/models/Field.go | 136 ---- cmd/load_cnosdb/models/FieldType.go | 41 -- cmd/load_cnosdb/models/PingBody.go | 81 --- cmd/load_cnosdb/models/Point.go | 188 ------ cmd/load_cnosdb/models/Points.go | 107 --- cmd/load_cnosdb/models/Row.go | 83 --- cmd/load_cnosdb/models/RowField.go | 111 --- cmd/load_cnosdb/models/RowKey.go | 41 -- cmd/load_cnosdb/models/Rows.go | 67 -- cmd/load_cnosdb/models/Tag.go | 121 ---- cmd/load_cnosdb/models/models.go | 639 ++++++++++++++++++ cmd/load_cnosdb/proto/model.fbs | 39 +- 16 files changed, 643 insertions(+), 1218 deletions(-) delete mode 100644 cmd/load_cnosdb/models/ColumnKey.go delete mode 100644 cmd/load_cnosdb/models/ColumnKeys.go delete mode 100644 cmd/load_cnosdb/models/ColumnKeysWithRange.go delete mode 100644 cmd/load_cnosdb/models/Field.go delete mode 100644 cmd/load_cnosdb/models/FieldType.go delete mode 100644 cmd/load_cnosdb/models/PingBody.go delete mode 100644 cmd/load_cnosdb/models/Point.go delete mode 100644 cmd/load_cnosdb/models/Points.go delete mode 100644 cmd/load_cnosdb/models/Row.go delete mode 100644 cmd/load_cnosdb/models/RowField.go delete mode 100644 cmd/load_cnosdb/models/RowKey.go delete mode 100644 cmd/load_cnosdb/models/Rows.go delete mode 100644 cmd/load_cnosdb/models/Tag.go create mode 100644 cmd/load_cnosdb/models/models.go diff --git a/cmd/load_cnosdb/http_writer.go b/cmd/load_cnosdb/http_writer.go index 66afeca..21862a5 100644 --- a/cmd/load_cnosdb/http_writer.go +++ b/cmd/load_cnosdb/http_writer.go @@ -232,7 +232,7 @@ func parserLine(lines []byte) []byte { ptVec := fb.EndVector(numLines) models.PointsStart(fb) models.PointsAddPoints(fb, ptVec) - models.PointsAddDatabase(fb, database) + models.PointsAddDb(fb, database) endPoints := models.PointsEnd(fb) fb.Finish(endPoints) return fb.FinishedBytes() @@ -454,7 +454,7 @@ func parsePoint(fb *flatbuffers.Builder, buf []byte) flatbuffers.UOffsetT { models.PointStart(fb) models.PointAddDb(fb, dbOff) - models.PointAddTable(fb, tableOff) + models.PointAddTab(fb, tableOff) models.PointAddTags(fb, tagsOff) models.PointAddFields(fb, fieldsOff) models.PointAddTimestamp(fb, int64(tsInt)) diff --git a/cmd/load_cnosdb/models/ColumnKey.go b/cmd/load_cnosdb/models/ColumnKey.go deleted file mode 100644 index 392f9b3..0000000 --- a/cmd/load_cnosdb/models/ColumnKey.go +++ /dev/null @@ -1,41 +0,0 @@ -// Code generated by the FlatBuffers compiler. DO NOT EDIT. - -package models - -import ( - flatbuffers "github.com/google/flatbuffers/go" -) - -type ColumnKey struct { - _tab flatbuffers.Struct -} - -func (rcv *ColumnKey) Init(buf []byte, i flatbuffers.UOffsetT) { - rcv._tab.Bytes = buf - rcv._tab.Pos = i -} - -func (rcv *ColumnKey) Table() flatbuffers.Table { - return rcv._tab.Table -} - -func (rcv *ColumnKey) SeriesId() uint64 { - return rcv._tab.GetUint64(rcv._tab.Pos + flatbuffers.UOffsetT(0)) -} -func (rcv *ColumnKey) MutateSeriesId(n uint64) bool { - return rcv._tab.MutateUint64(rcv._tab.Pos+flatbuffers.UOffsetT(0), n) -} - -func (rcv *ColumnKey) FieldId() uint64 { - return rcv._tab.GetUint64(rcv._tab.Pos + flatbuffers.UOffsetT(8)) -} -func (rcv *ColumnKey) MutateFieldId(n uint64) bool { - return rcv._tab.MutateUint64(rcv._tab.Pos+flatbuffers.UOffsetT(8), n) -} - -func CreateColumnKey(builder *flatbuffers.Builder, seriesId uint64, fieldId uint64) flatbuffers.UOffsetT { - builder.Prep(8, 16) - builder.PrependUint64(fieldId) - builder.PrependUint64(seriesId) - return builder.Offset() -} diff --git a/cmd/load_cnosdb/models/ColumnKeys.go b/cmd/load_cnosdb/models/ColumnKeys.go deleted file mode 100644 index e718867..0000000 --- a/cmd/load_cnosdb/models/ColumnKeys.go +++ /dev/null @@ -1,66 +0,0 @@ -// Code generated by the FlatBuffers compiler. DO NOT EDIT. - -package models - -import ( - flatbuffers "github.com/google/flatbuffers/go" -) - -type ColumnKeys struct { - _tab flatbuffers.Table -} - -func GetRootAsColumnKeys(buf []byte, offset flatbuffers.UOffsetT) *ColumnKeys { - n := flatbuffers.GetUOffsetT(buf[offset:]) - x := &ColumnKeys{} - x.Init(buf, n+offset) - return x -} - -func GetSizePrefixedRootAsColumnKeys(buf []byte, offset flatbuffers.UOffsetT) *ColumnKeys { - n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:]) - x := &ColumnKeys{} - x.Init(buf, n+offset+flatbuffers.SizeUint32) - return x -} - -func (rcv *ColumnKeys) Init(buf []byte, i flatbuffers.UOffsetT) { - rcv._tab.Bytes = buf - rcv._tab.Pos = i -} - -func (rcv *ColumnKeys) Table() flatbuffers.Table { - return rcv._tab -} - -func (rcv *ColumnKeys) ColumnKeys(obj *ColumnKey, j int) bool { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - x := rcv._tab.Vector(o) - x += flatbuffers.UOffsetT(j) * 16 - obj.Init(rcv._tab.Bytes, x) - return true - } - return false -} - -func (rcv *ColumnKeys) ColumnKeysLength() int { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - return rcv._tab.VectorLen(o) - } - return 0 -} - -func ColumnKeysStart(builder *flatbuffers.Builder) { - builder.StartObject(1) -} -func ColumnKeysAddColumnKeys(builder *flatbuffers.Builder, columnKeys flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(columnKeys), 0) -} -func ColumnKeysStartColumnKeysVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { - return builder.StartVector(16, numElems, 8) -} -func ColumnKeysEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { - return builder.EndObject() -} diff --git a/cmd/load_cnosdb/models/ColumnKeysWithRange.go b/cmd/load_cnosdb/models/ColumnKeysWithRange.go deleted file mode 100644 index 931e11b..0000000 --- a/cmd/load_cnosdb/models/ColumnKeysWithRange.go +++ /dev/null @@ -1,96 +0,0 @@ -// Code generated by the FlatBuffers compiler. DO NOT EDIT. - -package models - -import ( - flatbuffers "github.com/google/flatbuffers/go" -) - -type ColumnKeysWithRange struct { - _tab flatbuffers.Table -} - -func GetRootAsColumnKeysWithRange(buf []byte, offset flatbuffers.UOffsetT) *ColumnKeysWithRange { - n := flatbuffers.GetUOffsetT(buf[offset:]) - x := &ColumnKeysWithRange{} - x.Init(buf, n+offset) - return x -} - -func GetSizePrefixedRootAsColumnKeysWithRange(buf []byte, offset flatbuffers.UOffsetT) *ColumnKeysWithRange { - n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:]) - x := &ColumnKeysWithRange{} - x.Init(buf, n+offset+flatbuffers.SizeUint32) - return x -} - -func (rcv *ColumnKeysWithRange) Init(buf []byte, i flatbuffers.UOffsetT) { - rcv._tab.Bytes = buf - rcv._tab.Pos = i -} - -func (rcv *ColumnKeysWithRange) Table() flatbuffers.Table { - return rcv._tab -} - -func (rcv *ColumnKeysWithRange) ColumnKeys(obj *ColumnKey, j int) bool { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - x := rcv._tab.Vector(o) - x += flatbuffers.UOffsetT(j) * 16 - obj.Init(rcv._tab.Bytes, x) - return true - } - return false -} - -func (rcv *ColumnKeysWithRange) ColumnKeysLength() int { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - return rcv._tab.VectorLen(o) - } - return 0 -} - -func (rcv *ColumnKeysWithRange) Min() int64 { - o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) - if o != 0 { - return rcv._tab.GetInt64(o + rcv._tab.Pos) - } - return 0 -} - -func (rcv *ColumnKeysWithRange) MutateMin(n int64) bool { - return rcv._tab.MutateInt64Slot(6, n) -} - -func (rcv *ColumnKeysWithRange) Max() int64 { - o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) - if o != 0 { - return rcv._tab.GetInt64(o + rcv._tab.Pos) - } - return 0 -} - -func (rcv *ColumnKeysWithRange) MutateMax(n int64) bool { - return rcv._tab.MutateInt64Slot(8, n) -} - -func ColumnKeysWithRangeStart(builder *flatbuffers.Builder) { - builder.StartObject(3) -} -func ColumnKeysWithRangeAddColumnKeys(builder *flatbuffers.Builder, columnKeys flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(columnKeys), 0) -} -func ColumnKeysWithRangeStartColumnKeysVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { - return builder.StartVector(16, numElems, 8) -} -func ColumnKeysWithRangeAddMin(builder *flatbuffers.Builder, min int64) { - builder.PrependInt64Slot(1, min, 0) -} -func ColumnKeysWithRangeAddMax(builder *flatbuffers.Builder, max int64) { - builder.PrependInt64Slot(2, max, 0) -} -func ColumnKeysWithRangeEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { - return builder.EndObject() -} diff --git a/cmd/load_cnosdb/models/Field.go b/cmd/load_cnosdb/models/Field.go deleted file mode 100644 index ccb567b..0000000 --- a/cmd/load_cnosdb/models/Field.go +++ /dev/null @@ -1,136 +0,0 @@ -// Code generated by the FlatBuffers compiler. DO NOT EDIT. - -package models - -import ( - flatbuffers "github.com/google/flatbuffers/go" -) - -type Field struct { - _tab flatbuffers.Table -} - -func GetRootAsField(buf []byte, offset flatbuffers.UOffsetT) *Field { - n := flatbuffers.GetUOffsetT(buf[offset:]) - x := &Field{} - x.Init(buf, n+offset) - return x -} - -func GetSizePrefixedRootAsField(buf []byte, offset flatbuffers.UOffsetT) *Field { - n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:]) - x := &Field{} - x.Init(buf, n+offset+flatbuffers.SizeUint32) - return x -} - -func (rcv *Field) Init(buf []byte, i flatbuffers.UOffsetT) { - rcv._tab.Bytes = buf - rcv._tab.Pos = i -} - -func (rcv *Field) Table() flatbuffers.Table { - return rcv._tab -} - -func (rcv *Field) Name(j int) byte { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - a := rcv._tab.Vector(o) - return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1)) - } - return 0 -} - -func (rcv *Field) NameLength() int { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - return rcv._tab.VectorLen(o) - } - return 0 -} - -func (rcv *Field) NameBytes() []byte { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - return rcv._tab.ByteVector(o + rcv._tab.Pos) - } - return nil -} - -func (rcv *Field) MutateName(j int, n byte) bool { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - a := rcv._tab.Vector(o) - return rcv._tab.MutateByte(a+flatbuffers.UOffsetT(j*1), n) - } - return false -} - -func (rcv *Field) Type() FieldType { - o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) - if o != 0 { - return FieldType(rcv._tab.GetInt32(o + rcv._tab.Pos)) - } - return 0 -} - -func (rcv *Field) MutateType(n FieldType) bool { - return rcv._tab.MutateInt32Slot(6, int32(n)) -} - -func (rcv *Field) Value(j int) byte { - o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) - if o != 0 { - a := rcv._tab.Vector(o) - return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1)) - } - return 0 -} - -func (rcv *Field) ValueLength() int { - o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) - if o != 0 { - return rcv._tab.VectorLen(o) - } - return 0 -} - -func (rcv *Field) ValueBytes() []byte { - o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) - if o != 0 { - return rcv._tab.ByteVector(o + rcv._tab.Pos) - } - return nil -} - -func (rcv *Field) MutateValue(j int, n byte) bool { - o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) - if o != 0 { - a := rcv._tab.Vector(o) - return rcv._tab.MutateByte(a+flatbuffers.UOffsetT(j*1), n) - } - return false -} - -func FieldStart(builder *flatbuffers.Builder) { - builder.StartObject(3) -} -func FieldAddName(builder *flatbuffers.Builder, name flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(name), 0) -} -func FieldStartNameVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { - return builder.StartVector(1, numElems, 1) -} -func FieldAddType(builder *flatbuffers.Builder, type_ FieldType) { - builder.PrependInt32Slot(1, int32(type_), 0) -} -func FieldAddValue(builder *flatbuffers.Builder, value flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(2, flatbuffers.UOffsetT(value), 0) -} -func FieldStartValueVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { - return builder.StartVector(1, numElems, 1) -} -func FieldEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { - return builder.EndObject() -} diff --git a/cmd/load_cnosdb/models/FieldType.go b/cmd/load_cnosdb/models/FieldType.go deleted file mode 100644 index e50d62f..0000000 --- a/cmd/load_cnosdb/models/FieldType.go +++ /dev/null @@ -1,41 +0,0 @@ -// Code generated by the FlatBuffers compiler. DO NOT EDIT. - -package models - -import "strconv" - -type FieldType int32 - -const ( - FieldTypeUnknown FieldType = -1 - FieldTypeFloat FieldType = 0 - FieldTypeInteger FieldType = 1 - FieldTypeUnsigned FieldType = 2 - FieldTypeBoolean FieldType = 3 - FieldTypeString FieldType = 4 -) - -var EnumNamesFieldType = map[FieldType]string{ - FieldTypeUnknown: "Unknown", - FieldTypeFloat: "Float", - FieldTypeInteger: "Integer", - FieldTypeUnsigned: "Unsigned", - FieldTypeBoolean: "Boolean", - FieldTypeString: "String", -} - -var EnumValuesFieldType = map[string]FieldType{ - "Unknown": FieldTypeUnknown, - "Float": FieldTypeFloat, - "Integer": FieldTypeInteger, - "Unsigned": FieldTypeUnsigned, - "Boolean": FieldTypeBoolean, - "String": FieldTypeString, -} - -func (v FieldType) String() string { - if s, ok := EnumNamesFieldType[v]; ok { - return s - } - return "FieldType(" + strconv.FormatInt(int64(v), 10) + ")" -} diff --git a/cmd/load_cnosdb/models/PingBody.go b/cmd/load_cnosdb/models/PingBody.go deleted file mode 100644 index 4c2e040..0000000 --- a/cmd/load_cnosdb/models/PingBody.go +++ /dev/null @@ -1,81 +0,0 @@ -// Code generated by the FlatBuffers compiler. DO NOT EDIT. - -package models - -import ( - flatbuffers "github.com/google/flatbuffers/go" -) - -type PingBody struct { - _tab flatbuffers.Table -} - -func GetRootAsPingBody(buf []byte, offset flatbuffers.UOffsetT) *PingBody { - n := flatbuffers.GetUOffsetT(buf[offset:]) - x := &PingBody{} - x.Init(buf, n+offset) - return x -} - -func GetSizePrefixedRootAsPingBody(buf []byte, offset flatbuffers.UOffsetT) *PingBody { - n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:]) - x := &PingBody{} - x.Init(buf, n+offset+flatbuffers.SizeUint32) - return x -} - -func (rcv *PingBody) Init(buf []byte, i flatbuffers.UOffsetT) { - rcv._tab.Bytes = buf - rcv._tab.Pos = i -} - -func (rcv *PingBody) Table() flatbuffers.Table { - return rcv._tab -} - -func (rcv *PingBody) Payload(j int) byte { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - a := rcv._tab.Vector(o) - return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1)) - } - return 0 -} - -func (rcv *PingBody) PayloadLength() int { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - return rcv._tab.VectorLen(o) - } - return 0 -} - -func (rcv *PingBody) PayloadBytes() []byte { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - return rcv._tab.ByteVector(o + rcv._tab.Pos) - } - return nil -} - -func (rcv *PingBody) MutatePayload(j int, n byte) bool { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - a := rcv._tab.Vector(o) - return rcv._tab.MutateByte(a+flatbuffers.UOffsetT(j*1), n) - } - return false -} - -func PingBodyStart(builder *flatbuffers.Builder) { - builder.StartObject(1) -} -func PingBodyAddPayload(builder *flatbuffers.Builder, payload flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(payload), 0) -} -func PingBodyStartPayloadVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { - return builder.StartVector(1, numElems, 1) -} -func PingBodyEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { - return builder.EndObject() -} diff --git a/cmd/load_cnosdb/models/Point.go b/cmd/load_cnosdb/models/Point.go deleted file mode 100644 index c1feb0d..0000000 --- a/cmd/load_cnosdb/models/Point.go +++ /dev/null @@ -1,188 +0,0 @@ -// Code generated by the FlatBuffers compiler. DO NOT EDIT. - -package models - -import ( - flatbuffers "github.com/google/flatbuffers/go" -) - -type Point struct { - _tab flatbuffers.Table -} - -func GetRootAsPoint(buf []byte, offset flatbuffers.UOffsetT) *Point { - n := flatbuffers.GetUOffsetT(buf[offset:]) - x := &Point{} - x.Init(buf, n+offset) - return x -} - -func GetSizePrefixedRootAsPoint(buf []byte, offset flatbuffers.UOffsetT) *Point { - n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:]) - x := &Point{} - x.Init(buf, n+offset+flatbuffers.SizeUint32) - return x -} - -func (rcv *Point) Init(buf []byte, i flatbuffers.UOffsetT) { - rcv._tab.Bytes = buf - rcv._tab.Pos = i -} - -func (rcv *Point) Table() flatbuffers.Table { - return rcv._tab -} - -func (rcv *Point) Db(j int) byte { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - a := rcv._tab.Vector(o) - return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1)) - } - return 0 -} - -func (rcv *Point) DbLength() int { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - return rcv._tab.VectorLen(o) - } - return 0 -} - -func (rcv *Point) DbBytes() []byte { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - return rcv._tab.ByteVector(o + rcv._tab.Pos) - } - return nil -} - -func (rcv *Point) MutateDb(j int, n byte) bool { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - a := rcv._tab.Vector(o) - return rcv._tab.MutateByte(a+flatbuffers.UOffsetT(j*1), n) - } - return false -} - -//func (rcv *Point) Table(j int) byte { -// o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) -// if o != 0 { -// a := rcv._tab.Vector(o) -// return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1)) -// } -// return 0 -//} - -func (rcv *Point) TableLength() int { - o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) - if o != 0 { - return rcv._tab.VectorLen(o) - } - return 0 -} - -func (rcv *Point) TableBytes() []byte { - o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) - if o != 0 { - return rcv._tab.ByteVector(o + rcv._tab.Pos) - } - return nil -} - -func (rcv *Point) MutateTable(j int, n byte) bool { - o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) - if o != 0 { - a := rcv._tab.Vector(o) - return rcv._tab.MutateByte(a+flatbuffers.UOffsetT(j*1), n) - } - return false -} - -func (rcv *Point) Tags(obj *Tag, j int) bool { - o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) - if o != 0 { - x := rcv._tab.Vector(o) - x += flatbuffers.UOffsetT(j) * 4 - x = rcv._tab.Indirect(x) - obj.Init(rcv._tab.Bytes, x) - return true - } - return false -} - -func (rcv *Point) TagsLength() int { - o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) - if o != 0 { - return rcv._tab.VectorLen(o) - } - return 0 -} - -func (rcv *Point) Fields(obj *Field, j int) bool { - o := flatbuffers.UOffsetT(rcv._tab.Offset(10)) - if o != 0 { - x := rcv._tab.Vector(o) - x += flatbuffers.UOffsetT(j) * 4 - x = rcv._tab.Indirect(x) - obj.Init(rcv._tab.Bytes, x) - return true - } - return false -} - -func (rcv *Point) FieldsLength() int { - o := flatbuffers.UOffsetT(rcv._tab.Offset(10)) - if o != 0 { - return rcv._tab.VectorLen(o) - } - return 0 -} - -func (rcv *Point) Timestamp() int64 { - o := flatbuffers.UOffsetT(rcv._tab.Offset(12)) - if o != 0 { - return rcv._tab.GetInt64(o + rcv._tab.Pos) - } - return 0 -} - -func (rcv *Point) MutateTimestamp(n int64) bool { - return rcv._tab.MutateInt64Slot(12, n) -} - -func PointStart(builder *flatbuffers.Builder) { - builder.StartObject(5) -} -func PointAddDb(builder *flatbuffers.Builder, db flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(db), 0) -} -func PointStartDbVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { - return builder.StartVector(1, numElems, 1) -} -func PointAddTable(builder *flatbuffers.Builder, table flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(table), 0) -} -func PointStartTableVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { - return builder.StartVector(1, numElems, 1) -} -func PointAddTags(builder *flatbuffers.Builder, tags flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(2, flatbuffers.UOffsetT(tags), 0) -} -func PointStartTagsVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { - return builder.StartVector(4, numElems, 4) -} -func PointAddFields(builder *flatbuffers.Builder, fields flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(3, flatbuffers.UOffsetT(fields), 0) -} -func PointStartFieldsVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { - return builder.StartVector(4, numElems, 4) -} -func PointAddTimestamp(builder *flatbuffers.Builder, timestamp int64) { - builder.PrependInt64Slot(4, timestamp, 0) -} -func PointEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { - return builder.EndObject() -} diff --git a/cmd/load_cnosdb/models/Points.go b/cmd/load_cnosdb/models/Points.go deleted file mode 100644 index 02ea046..0000000 --- a/cmd/load_cnosdb/models/Points.go +++ /dev/null @@ -1,107 +0,0 @@ -// Code generated by the FlatBuffers compiler. DO NOT EDIT. - -package models - -import ( - flatbuffers "github.com/google/flatbuffers/go" -) - -type Points struct { - _tab flatbuffers.Table -} - -func GetRootAsPoints(buf []byte, offset flatbuffers.UOffsetT) *Points { - n := flatbuffers.GetUOffsetT(buf[offset:]) - x := &Points{} - x.Init(buf, n+offset) - return x -} - -func GetSizePrefixedRootAsPoints(buf []byte, offset flatbuffers.UOffsetT) *Points { - n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:]) - x := &Points{} - x.Init(buf, n+offset+flatbuffers.SizeUint32) - return x -} - -func (rcv *Points) Init(buf []byte, i flatbuffers.UOffsetT) { - rcv._tab.Bytes = buf - rcv._tab.Pos = i -} - -func (rcv *Points) Table() flatbuffers.Table { - return rcv._tab -} - -func (rcv *Points) Database(j int) byte { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - a := rcv._tab.Vector(o) - return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1)) - } - return 0 -} - -func (rcv *Points) DatabaseLength() int { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - return rcv._tab.VectorLen(o) - } - return 0 -} - -func (rcv *Points) DatabaseBytes() []byte { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - return rcv._tab.ByteVector(o + rcv._tab.Pos) - } - return nil -} - -func (rcv *Points) MutateDatabase(j int, n byte) bool { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - a := rcv._tab.Vector(o) - return rcv._tab.MutateByte(a+flatbuffers.UOffsetT(j*1), n) - } - return false -} - -func (rcv *Points) Points(obj *Point, j int) bool { - o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) - if o != 0 { - x := rcv._tab.Vector(o) - x += flatbuffers.UOffsetT(j) * 4 - x = rcv._tab.Indirect(x) - obj.Init(rcv._tab.Bytes, x) - return true - } - return false -} - -func (rcv *Points) PointsLength() int { - o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) - if o != 0 { - return rcv._tab.VectorLen(o) - } - return 0 -} - -func PointsStart(builder *flatbuffers.Builder) { - builder.StartObject(2) -} -func PointsAddDatabase(builder *flatbuffers.Builder, database flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(database), 0) -} -func PointsStartDatabaseVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { - return builder.StartVector(1, numElems, 1) -} -func PointsAddPoints(builder *flatbuffers.Builder, points flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(points), 0) -} -func PointsStartPointsVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { - return builder.StartVector(4, numElems, 4) -} -func PointsEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { - return builder.EndObject() -} diff --git a/cmd/load_cnosdb/models/Row.go b/cmd/load_cnosdb/models/Row.go deleted file mode 100644 index af4737e..0000000 --- a/cmd/load_cnosdb/models/Row.go +++ /dev/null @@ -1,83 +0,0 @@ -// Code generated by the FlatBuffers compiler. DO NOT EDIT. - -package models - -import ( - flatbuffers "github.com/google/flatbuffers/go" -) - -type Row struct { - _tab flatbuffers.Table -} - -func GetRootAsRow(buf []byte, offset flatbuffers.UOffsetT) *Row { - n := flatbuffers.GetUOffsetT(buf[offset:]) - x := &Row{} - x.Init(buf, n+offset) - return x -} - -func GetSizePrefixedRootAsRow(buf []byte, offset flatbuffers.UOffsetT) *Row { - n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:]) - x := &Row{} - x.Init(buf, n+offset+flatbuffers.SizeUint32) - return x -} - -func (rcv *Row) Init(buf []byte, i flatbuffers.UOffsetT) { - rcv._tab.Bytes = buf - rcv._tab.Pos = i -} - -func (rcv *Row) Table() flatbuffers.Table { - return rcv._tab -} - -func (rcv *Row) Key(obj *RowKey) *RowKey { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - x := o + rcv._tab.Pos - if obj == nil { - obj = new(RowKey) - } - obj.Init(rcv._tab.Bytes, x) - return obj - } - return nil -} - -func (rcv *Row) Fields(obj *RowField, j int) bool { - o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) - if o != 0 { - x := rcv._tab.Vector(o) - x += flatbuffers.UOffsetT(j) * 4 - x = rcv._tab.Indirect(x) - obj.Init(rcv._tab.Bytes, x) - return true - } - return false -} - -func (rcv *Row) FieldsLength() int { - o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) - if o != 0 { - return rcv._tab.VectorLen(o) - } - return 0 -} - -func RowStart(builder *flatbuffers.Builder) { - builder.StartObject(2) -} -func RowAddKey(builder *flatbuffers.Builder, key flatbuffers.UOffsetT) { - builder.PrependStructSlot(0, flatbuffers.UOffsetT(key), 0) -} -func RowAddFields(builder *flatbuffers.Builder, fields flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(fields), 0) -} -func RowStartFieldsVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { - return builder.StartVector(4, numElems, 4) -} -func RowEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { - return builder.EndObject() -} diff --git a/cmd/load_cnosdb/models/RowField.go b/cmd/load_cnosdb/models/RowField.go deleted file mode 100644 index f2de44e..0000000 --- a/cmd/load_cnosdb/models/RowField.go +++ /dev/null @@ -1,111 +0,0 @@ -// Code generated by the FlatBuffers compiler. DO NOT EDIT. - -package models - -import ( - flatbuffers "github.com/google/flatbuffers/go" -) - -type RowField struct { - _tab flatbuffers.Table -} - -func GetRootAsRowField(buf []byte, offset flatbuffers.UOffsetT) *RowField { - n := flatbuffers.GetUOffsetT(buf[offset:]) - x := &RowField{} - x.Init(buf, n+offset) - return x -} - -func GetSizePrefixedRootAsRowField(buf []byte, offset flatbuffers.UOffsetT) *RowField { - n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:]) - x := &RowField{} - x.Init(buf, n+offset+flatbuffers.SizeUint32) - return x -} - -func (rcv *RowField) Init(buf []byte, i flatbuffers.UOffsetT) { - rcv._tab.Bytes = buf - rcv._tab.Pos = i -} - -func (rcv *RowField) Table() flatbuffers.Table { - return rcv._tab -} - -func (rcv *RowField) FieldId() uint64 { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - return rcv._tab.GetUint64(o + rcv._tab.Pos) - } - return 0 -} - -func (rcv *RowField) MutateFieldId(n uint64) bool { - return rcv._tab.MutateUint64Slot(4, n) -} - -func (rcv *RowField) Type() FieldType { - o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) - if o != 0 { - return FieldType(rcv._tab.GetInt32(o + rcv._tab.Pos)) - } - return 0 -} - -func (rcv *RowField) MutateType(n FieldType) bool { - return rcv._tab.MutateInt32Slot(6, int32(n)) -} - -func (rcv *RowField) Value(j int) byte { - o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) - if o != 0 { - a := rcv._tab.Vector(o) - return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1)) - } - return 0 -} - -func (rcv *RowField) ValueLength() int { - o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) - if o != 0 { - return rcv._tab.VectorLen(o) - } - return 0 -} - -func (rcv *RowField) ValueBytes() []byte { - o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) - if o != 0 { - return rcv._tab.ByteVector(o + rcv._tab.Pos) - } - return nil -} - -func (rcv *RowField) MutateValue(j int, n byte) bool { - o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) - if o != 0 { - a := rcv._tab.Vector(o) - return rcv._tab.MutateByte(a+flatbuffers.UOffsetT(j*1), n) - } - return false -} - -func RowFieldStart(builder *flatbuffers.Builder) { - builder.StartObject(3) -} -func RowFieldAddFieldId(builder *flatbuffers.Builder, fieldId uint64) { - builder.PrependUint64Slot(0, fieldId, 0) -} -func RowFieldAddType(builder *flatbuffers.Builder, type_ FieldType) { - builder.PrependInt32Slot(1, int32(type_), 0) -} -func RowFieldAddValue(builder *flatbuffers.Builder, value flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(2, flatbuffers.UOffsetT(value), 0) -} -func RowFieldStartValueVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { - return builder.StartVector(1, numElems, 1) -} -func RowFieldEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { - return builder.EndObject() -} diff --git a/cmd/load_cnosdb/models/RowKey.go b/cmd/load_cnosdb/models/RowKey.go deleted file mode 100644 index 52ecef1..0000000 --- a/cmd/load_cnosdb/models/RowKey.go +++ /dev/null @@ -1,41 +0,0 @@ -// Code generated by the FlatBuffers compiler. DO NOT EDIT. - -package models - -import ( - flatbuffers "github.com/google/flatbuffers/go" -) - -type RowKey struct { - _tab flatbuffers.Struct -} - -func (rcv *RowKey) Init(buf []byte, i flatbuffers.UOffsetT) { - rcv._tab.Bytes = buf - rcv._tab.Pos = i -} - -func (rcv *RowKey) Table() flatbuffers.Table { - return rcv._tab.Table -} - -func (rcv *RowKey) SeriesId() uint64 { - return rcv._tab.GetUint64(rcv._tab.Pos + flatbuffers.UOffsetT(0)) -} -func (rcv *RowKey) MutateSeriesId(n uint64) bool { - return rcv._tab.MutateUint64(rcv._tab.Pos+flatbuffers.UOffsetT(0), n) -} - -func (rcv *RowKey) Timestamp() uint64 { - return rcv._tab.GetUint64(rcv._tab.Pos + flatbuffers.UOffsetT(8)) -} -func (rcv *RowKey) MutateTimestamp(n uint64) bool { - return rcv._tab.MutateUint64(rcv._tab.Pos+flatbuffers.UOffsetT(8), n) -} - -func CreateRowKey(builder *flatbuffers.Builder, seriesId uint64, timestamp uint64) flatbuffers.UOffsetT { - builder.Prep(8, 16) - builder.PrependUint64(timestamp) - builder.PrependUint64(seriesId) - return builder.Offset() -} diff --git a/cmd/load_cnosdb/models/Rows.go b/cmd/load_cnosdb/models/Rows.go deleted file mode 100644 index 7e1280f..0000000 --- a/cmd/load_cnosdb/models/Rows.go +++ /dev/null @@ -1,67 +0,0 @@ -// Code generated by the FlatBuffers compiler. DO NOT EDIT. - -package models - -import ( - flatbuffers "github.com/google/flatbuffers/go" -) - -type Rows struct { - _tab flatbuffers.Table -} - -func GetRootAsRows(buf []byte, offset flatbuffers.UOffsetT) *Rows { - n := flatbuffers.GetUOffsetT(buf[offset:]) - x := &Rows{} - x.Init(buf, n+offset) - return x -} - -func GetSizePrefixedRootAsRows(buf []byte, offset flatbuffers.UOffsetT) *Rows { - n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:]) - x := &Rows{} - x.Init(buf, n+offset+flatbuffers.SizeUint32) - return x -} - -func (rcv *Rows) Init(buf []byte, i flatbuffers.UOffsetT) { - rcv._tab.Bytes = buf - rcv._tab.Pos = i -} - -func (rcv *Rows) Table() flatbuffers.Table { - return rcv._tab -} - -func (rcv *Rows) Rows(obj *Row, j int) bool { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - x := rcv._tab.Vector(o) - x += flatbuffers.UOffsetT(j) * 4 - x = rcv._tab.Indirect(x) - obj.Init(rcv._tab.Bytes, x) - return true - } - return false -} - -func (rcv *Rows) RowsLength() int { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - return rcv._tab.VectorLen(o) - } - return 0 -} - -func RowsStart(builder *flatbuffers.Builder) { - builder.StartObject(1) -} -func RowsAddRows(builder *flatbuffers.Builder, rows flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(rows), 0) -} -func RowsStartRowsVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { - return builder.StartVector(4, numElems, 4) -} -func RowsEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { - return builder.EndObject() -} diff --git a/cmd/load_cnosdb/models/Tag.go b/cmd/load_cnosdb/models/Tag.go deleted file mode 100644 index 285269e..0000000 --- a/cmd/load_cnosdb/models/Tag.go +++ /dev/null @@ -1,121 +0,0 @@ -// Code generated by the FlatBuffers compiler. DO NOT EDIT. - -package models - -import ( - flatbuffers "github.com/google/flatbuffers/go" -) - -type Tag struct { - _tab flatbuffers.Table -} - -func GetRootAsTag(buf []byte, offset flatbuffers.UOffsetT) *Tag { - n := flatbuffers.GetUOffsetT(buf[offset:]) - x := &Tag{} - x.Init(buf, n+offset) - return x -} - -func GetSizePrefixedRootAsTag(buf []byte, offset flatbuffers.UOffsetT) *Tag { - n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:]) - x := &Tag{} - x.Init(buf, n+offset+flatbuffers.SizeUint32) - return x -} - -func (rcv *Tag) Init(buf []byte, i flatbuffers.UOffsetT) { - rcv._tab.Bytes = buf - rcv._tab.Pos = i -} - -func (rcv *Tag) Table() flatbuffers.Table { - return rcv._tab -} - -func (rcv *Tag) Key(j int) byte { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - a := rcv._tab.Vector(o) - return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1)) - } - return 0 -} - -func (rcv *Tag) KeyLength() int { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - return rcv._tab.VectorLen(o) - } - return 0 -} - -func (rcv *Tag) KeyBytes() []byte { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - return rcv._tab.ByteVector(o + rcv._tab.Pos) - } - return nil -} - -func (rcv *Tag) MutateKey(j int, n byte) bool { - o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) - if o != 0 { - a := rcv._tab.Vector(o) - return rcv._tab.MutateByte(a+flatbuffers.UOffsetT(j*1), n) - } - return false -} - -func (rcv *Tag) Value(j int) byte { - o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) - if o != 0 { - a := rcv._tab.Vector(o) - return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1)) - } - return 0 -} - -func (rcv *Tag) ValueLength() int { - o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) - if o != 0 { - return rcv._tab.VectorLen(o) - } - return 0 -} - -func (rcv *Tag) ValueBytes() []byte { - o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) - if o != 0 { - return rcv._tab.ByteVector(o + rcv._tab.Pos) - } - return nil -} - -func (rcv *Tag) MutateValue(j int, n byte) bool { - o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) - if o != 0 { - a := rcv._tab.Vector(o) - return rcv._tab.MutateByte(a+flatbuffers.UOffsetT(j*1), n) - } - return false -} - -func TagStart(builder *flatbuffers.Builder) { - builder.StartObject(2) -} -func TagAddKey(builder *flatbuffers.Builder, key flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(key), 0) -} -func TagStartKeyVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { - return builder.StartVector(1, numElems, 1) -} -func TagAddValue(builder *flatbuffers.Builder, value flatbuffers.UOffsetT) { - builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(value), 0) -} -func TagStartValueVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { - return builder.StartVector(1, numElems, 1) -} -func TagEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { - return builder.EndObject() -} diff --git a/cmd/load_cnosdb/models/models.go b/cmd/load_cnosdb/models/models.go new file mode 100644 index 0000000..7339af5 --- /dev/null +++ b/cmd/load_cnosdb/models/models.go @@ -0,0 +1,639 @@ +// Code generated by the FlatBuffers compiler. DO NOT EDIT. + +package models + +import ( + "strconv" + + flatbuffers "github.com/google/flatbuffers/go" +) + +type FieldType int32 + +const ( + FieldTypeUnknown FieldType = -1 + FieldTypeFloat FieldType = 0 + FieldTypeInteger FieldType = 1 + FieldTypeUnsigned FieldType = 2 + FieldTypeBoolean FieldType = 3 + FieldTypeString FieldType = 4 +) + +var EnumNamesFieldType = map[FieldType]string{ + FieldTypeUnknown: "Unknown", + FieldTypeFloat: "Float", + FieldTypeInteger: "Integer", + FieldTypeUnsigned: "Unsigned", + FieldTypeBoolean: "Boolean", + FieldTypeString: "String", +} + +var EnumValuesFieldType = map[string]FieldType{ + "Unknown": FieldTypeUnknown, + "Float": FieldTypeFloat, + "Integer": FieldTypeInteger, + "Unsigned": FieldTypeUnsigned, + "Boolean": FieldTypeBoolean, + "String": FieldTypeString, +} + +func (v FieldType) String() string { + if s, ok := EnumNamesFieldType[v]; ok { + return s + } + return "FieldType(" + strconv.FormatInt(int64(v), 10) + ")" +} + +type PingBody struct { + _tab flatbuffers.Table +} + +func GetRootAsPingBody(buf []byte, offset flatbuffers.UOffsetT) *PingBody { + n := flatbuffers.GetUOffsetT(buf[offset:]) + x := &PingBody{} + x.Init(buf, n+offset) + return x +} + +func GetSizePrefixedRootAsPingBody(buf []byte, offset flatbuffers.UOffsetT) *PingBody { + n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:]) + x := &PingBody{} + x.Init(buf, n+offset+flatbuffers.SizeUint32) + return x +} + +func (rcv *PingBody) Init(buf []byte, i flatbuffers.UOffsetT) { + rcv._tab.Bytes = buf + rcv._tab.Pos = i +} + +func (rcv *PingBody) Table() flatbuffers.Table { + return rcv._tab +} + +func (rcv *PingBody) Payload(j int) byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1)) + } + return 0 +} + +func (rcv *PingBody) PayloadLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +func (rcv *PingBody) PayloadBytes() []byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + return rcv._tab.ByteVector(o + rcv._tab.Pos) + } + return nil +} + +func (rcv *PingBody) MutatePayload(j int, n byte) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.MutateByte(a+flatbuffers.UOffsetT(j*1), n) + } + return false +} + +func PingBodyStart(builder *flatbuffers.Builder) { + builder.StartObject(1) +} +func PingBodyAddPayload(builder *flatbuffers.Builder, payload flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(payload), 0) +} +func PingBodyStartPayloadVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(1, numElems, 1) +} +func PingBodyEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { + return builder.EndObject() +} +type Tag struct { + _tab flatbuffers.Table +} + +func GetRootAsTag(buf []byte, offset flatbuffers.UOffsetT) *Tag { + n := flatbuffers.GetUOffsetT(buf[offset:]) + x := &Tag{} + x.Init(buf, n+offset) + return x +} + +func GetSizePrefixedRootAsTag(buf []byte, offset flatbuffers.UOffsetT) *Tag { + n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:]) + x := &Tag{} + x.Init(buf, n+offset+flatbuffers.SizeUint32) + return x +} + +func (rcv *Tag) Init(buf []byte, i flatbuffers.UOffsetT) { + rcv._tab.Bytes = buf + rcv._tab.Pos = i +} + +func (rcv *Tag) Table() flatbuffers.Table { + return rcv._tab +} + +func (rcv *Tag) Key(j int) byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1)) + } + return 0 +} + +func (rcv *Tag) KeyLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +func (rcv *Tag) KeyBytes() []byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + return rcv._tab.ByteVector(o + rcv._tab.Pos) + } + return nil +} + +func (rcv *Tag) MutateKey(j int, n byte) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.MutateByte(a+flatbuffers.UOffsetT(j*1), n) + } + return false +} + +func (rcv *Tag) Value(j int) byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1)) + } + return 0 +} + +func (rcv *Tag) ValueLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +func (rcv *Tag) ValueBytes() []byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) + if o != 0 { + return rcv._tab.ByteVector(o + rcv._tab.Pos) + } + return nil +} + +func (rcv *Tag) MutateValue(j int, n byte) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.MutateByte(a+flatbuffers.UOffsetT(j*1), n) + } + return false +} + +func TagStart(builder *flatbuffers.Builder) { + builder.StartObject(2) +} +func TagAddKey(builder *flatbuffers.Builder, key flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(key), 0) +} +func TagStartKeyVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(1, numElems, 1) +} +func TagAddValue(builder *flatbuffers.Builder, value flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(value), 0) +} +func TagStartValueVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(1, numElems, 1) +} +func TagEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { + return builder.EndObject() +} +type Field struct { + _tab flatbuffers.Table +} + +func GetRootAsField(buf []byte, offset flatbuffers.UOffsetT) *Field { + n := flatbuffers.GetUOffsetT(buf[offset:]) + x := &Field{} + x.Init(buf, n+offset) + return x +} + +func GetSizePrefixedRootAsField(buf []byte, offset flatbuffers.UOffsetT) *Field { + n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:]) + x := &Field{} + x.Init(buf, n+offset+flatbuffers.SizeUint32) + return x +} + +func (rcv *Field) Init(buf []byte, i flatbuffers.UOffsetT) { + rcv._tab.Bytes = buf + rcv._tab.Pos = i +} + +func (rcv *Field) Table() flatbuffers.Table { + return rcv._tab +} + +func (rcv *Field) Name(j int) byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1)) + } + return 0 +} + +func (rcv *Field) NameLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +func (rcv *Field) NameBytes() []byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + return rcv._tab.ByteVector(o + rcv._tab.Pos) + } + return nil +} + +func (rcv *Field) MutateName(j int, n byte) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.MutateByte(a+flatbuffers.UOffsetT(j*1), n) + } + return false +} + +func (rcv *Field) Type() FieldType { + o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) + if o != 0 { + return FieldType(rcv._tab.GetInt32(o + rcv._tab.Pos)) + } + return 0 +} + +func (rcv *Field) MutateType(n FieldType) bool { + return rcv._tab.MutateInt32Slot(6, int32(n)) +} + +func (rcv *Field) Value(j int) byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1)) + } + return 0 +} + +func (rcv *Field) ValueLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +func (rcv *Field) ValueBytes() []byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) + if o != 0 { + return rcv._tab.ByteVector(o + rcv._tab.Pos) + } + return nil +} + +func (rcv *Field) MutateValue(j int, n byte) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.MutateByte(a+flatbuffers.UOffsetT(j*1), n) + } + return false +} + +func FieldStart(builder *flatbuffers.Builder) { + builder.StartObject(3) +} +func FieldAddName(builder *flatbuffers.Builder, name flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(name), 0) +} +func FieldStartNameVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(1, numElems, 1) +} +func FieldAddType(builder *flatbuffers.Builder, type_ FieldType) { + builder.PrependInt32Slot(1, int32(type_), 0) +} +func FieldAddValue(builder *flatbuffers.Builder, value flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(2, flatbuffers.UOffsetT(value), 0) +} +func FieldStartValueVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(1, numElems, 1) +} +func FieldEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { + return builder.EndObject() +} +type Point struct { + _tab flatbuffers.Table +} + +func GetRootAsPoint(buf []byte, offset flatbuffers.UOffsetT) *Point { + n := flatbuffers.GetUOffsetT(buf[offset:]) + x := &Point{} + x.Init(buf, n+offset) + return x +} + +func GetSizePrefixedRootAsPoint(buf []byte, offset flatbuffers.UOffsetT) *Point { + n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:]) + x := &Point{} + x.Init(buf, n+offset+flatbuffers.SizeUint32) + return x +} + +func (rcv *Point) Init(buf []byte, i flatbuffers.UOffsetT) { + rcv._tab.Bytes = buf + rcv._tab.Pos = i +} + +func (rcv *Point) Table() flatbuffers.Table { + return rcv._tab +} + +func (rcv *Point) Db(j int) byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1)) + } + return 0 +} + +func (rcv *Point) DbLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +func (rcv *Point) DbBytes() []byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + return rcv._tab.ByteVector(o + rcv._tab.Pos) + } + return nil +} + +func (rcv *Point) MutateDb(j int, n byte) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.MutateByte(a+flatbuffers.UOffsetT(j*1), n) + } + return false +} + +func (rcv *Point) Tab(j int) byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1)) + } + return 0 +} + +func (rcv *Point) TabLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +func (rcv *Point) TabBytes() []byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) + if o != 0 { + return rcv._tab.ByteVector(o + rcv._tab.Pos) + } + return nil +} + +func (rcv *Point) MutateTab(j int, n byte) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.MutateByte(a+flatbuffers.UOffsetT(j*1), n) + } + return false +} + +func (rcv *Point) Tags(obj *Tag, j int) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) + if o != 0 { + x := rcv._tab.Vector(o) + x += flatbuffers.UOffsetT(j) * 4 + x = rcv._tab.Indirect(x) + obj.Init(rcv._tab.Bytes, x) + return true + } + return false +} + +func (rcv *Point) TagsLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(8)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +func (rcv *Point) Fields(obj *Field, j int) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(10)) + if o != 0 { + x := rcv._tab.Vector(o) + x += flatbuffers.UOffsetT(j) * 4 + x = rcv._tab.Indirect(x) + obj.Init(rcv._tab.Bytes, x) + return true + } + return false +} + +func (rcv *Point) FieldsLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(10)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +func (rcv *Point) Timestamp() int64 { + o := flatbuffers.UOffsetT(rcv._tab.Offset(12)) + if o != 0 { + return rcv._tab.GetInt64(o + rcv._tab.Pos) + } + return 0 +} + +func (rcv *Point) MutateTimestamp(n int64) bool { + return rcv._tab.MutateInt64Slot(12, n) +} + +func PointStart(builder *flatbuffers.Builder) { + builder.StartObject(5) +} +func PointAddDb(builder *flatbuffers.Builder, db flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(db), 0) +} +func PointStartDbVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(1, numElems, 1) +} +func PointAddTab(builder *flatbuffers.Builder, tab flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(tab), 0) +} +func PointStartTabVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(1, numElems, 1) +} +func PointAddTags(builder *flatbuffers.Builder, tags flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(2, flatbuffers.UOffsetT(tags), 0) +} +func PointStartTagsVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(4, numElems, 4) +} +func PointAddFields(builder *flatbuffers.Builder, fields flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(3, flatbuffers.UOffsetT(fields), 0) +} +func PointStartFieldsVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(4, numElems, 4) +} +func PointAddTimestamp(builder *flatbuffers.Builder, timestamp int64) { + builder.PrependInt64Slot(4, timestamp, 0) +} +func PointEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { + return builder.EndObject() +} +type Points struct { + _tab flatbuffers.Table +} + +func GetRootAsPoints(buf []byte, offset flatbuffers.UOffsetT) *Points { + n := flatbuffers.GetUOffsetT(buf[offset:]) + x := &Points{} + x.Init(buf, n+offset) + return x +} + +func GetSizePrefixedRootAsPoints(buf []byte, offset flatbuffers.UOffsetT) *Points { + n := flatbuffers.GetUOffsetT(buf[offset+flatbuffers.SizeUint32:]) + x := &Points{} + x.Init(buf, n+offset+flatbuffers.SizeUint32) + return x +} + +func (rcv *Points) Init(buf []byte, i flatbuffers.UOffsetT) { + rcv._tab.Bytes = buf + rcv._tab.Pos = i +} + +func (rcv *Points) Table() flatbuffers.Table { + return rcv._tab +} + +func (rcv *Points) Db(j int) byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.GetByte(a + flatbuffers.UOffsetT(j*1)) + } + return 0 +} + +func (rcv *Points) DbLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +func (rcv *Points) DbBytes() []byte { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + return rcv._tab.ByteVector(o + rcv._tab.Pos) + } + return nil +} + +func (rcv *Points) MutateDb(j int, n byte) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(4)) + if o != 0 { + a := rcv._tab.Vector(o) + return rcv._tab.MutateByte(a+flatbuffers.UOffsetT(j*1), n) + } + return false +} + +func (rcv *Points) Points(obj *Point, j int) bool { + o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) + if o != 0 { + x := rcv._tab.Vector(o) + x += flatbuffers.UOffsetT(j) * 4 + x = rcv._tab.Indirect(x) + obj.Init(rcv._tab.Bytes, x) + return true + } + return false +} + +func (rcv *Points) PointsLength() int { + o := flatbuffers.UOffsetT(rcv._tab.Offset(6)) + if o != 0 { + return rcv._tab.VectorLen(o) + } + return 0 +} + +func PointsStart(builder *flatbuffers.Builder) { + builder.StartObject(2) +} +func PointsAddDb(builder *flatbuffers.Builder, db flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(db), 0) +} +func PointsStartDbVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(1, numElems, 1) +} +func PointsAddPoints(builder *flatbuffers.Builder, points flatbuffers.UOffsetT) { + builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(points), 0) +} +func PointsStartPointsVector(builder *flatbuffers.Builder, numElems int) flatbuffers.UOffsetT { + return builder.StartVector(4, numElems, 4) +} +func PointsEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { + return builder.EndObject() +} diff --git a/cmd/load_cnosdb/proto/model.fbs b/cmd/load_cnosdb/proto/model.fbs index 7997a29..ad6f59d 100644 --- a/cmd/load_cnosdb/proto/model.fbs +++ b/cmd/load_cnosdb/proto/model.fbs @@ -13,26 +13,6 @@ enum FieldType: int { String, } -struct RowKey { - series_id: uint64; - timestamp: uint64; -} - -table RowField { - field_id: uint64; - type: FieldType; - value: [ubyte]; -} - -table Row { - key: RowKey; - fields: [RowField]; -} - -table Rows { - rows: [Row]; -} - table Tag { key: [ubyte]; value: [ubyte]; @@ -46,28 +26,13 @@ table Field { table Point { db: [ubyte]; - table: [ubyte]; + tab: [ubyte]; tags: [Tag]; fields: [Field]; timestamp: int64; } table Points { - database: [ubyte]; + db: [ubyte]; points: [Point]; } - -struct ColumnKey { - series_id: uint64; - field_id: uint64; -} - -table ColumnKeys { - column_keys: [ColumnKey]; -} - -table ColumnKeysWithRange { - column_keys: [ColumnKey]; - min: int64; - max: int64; -} From fb041c3c59b00f8753403a08a2c9f2231f20c6a8 Mon Sep 17 00:00:00 2001 From: zipper-meng Date: Mon, 7 Nov 2022 16:43:31 +0800 Subject: [PATCH 6/7] add generate.go, use `go generate ./...` to generate flatbuffers and protobuf models and grpc services. --- cmd/load_cnosdb/generate.go | 4 + .../{proto/model.fbs => models/models.fbs} | 0 .../models/{models.go => models_generated.go} | 4 + cmd/load_cnosdb/proto/kv_service.pb.go | 367 +++++++++--------- cmd/load_cnosdb/proto/kv_service.proto | 4 +- cmd/load_cnosdb/proto/kv_service_grpc.pb.go | 8 +- 6 files changed, 198 insertions(+), 189 deletions(-) create mode 100644 cmd/load_cnosdb/generate.go rename cmd/load_cnosdb/{proto/model.fbs => models/models.fbs} (100%) rename cmd/load_cnosdb/models/{models.go => models_generated.go} (99%) diff --git a/cmd/load_cnosdb/generate.go b/cmd/load_cnosdb/generate.go new file mode 100644 index 0000000..ef71be9 --- /dev/null +++ b/cmd/load_cnosdb/generate.go @@ -0,0 +1,4 @@ +package main + +//go:generate flatc -o models --go --go-namespace models --gen-onefile ./models/models.fbs +//go:generate protoc --go_out=. --go-grpc_out=. proto/kv_service.proto diff --git a/cmd/load_cnosdb/proto/model.fbs b/cmd/load_cnosdb/models/models.fbs similarity index 100% rename from cmd/load_cnosdb/proto/model.fbs rename to cmd/load_cnosdb/models/models.fbs diff --git a/cmd/load_cnosdb/models/models.go b/cmd/load_cnosdb/models/models_generated.go similarity index 99% rename from cmd/load_cnosdb/models/models.go rename to cmd/load_cnosdb/models/models_generated.go index 7339af5..43aeeee 100644 --- a/cmd/load_cnosdb/models/models.go +++ b/cmd/load_cnosdb/models/models_generated.go @@ -117,6 +117,7 @@ func PingBodyStartPayloadVector(builder *flatbuffers.Builder, numElems int) flat func PingBodyEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { return builder.EndObject() } + type Tag struct { _tab flatbuffers.Table } @@ -230,6 +231,7 @@ func TagStartValueVector(builder *flatbuffers.Builder, numElems int) flatbuffers func TagEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { return builder.EndObject() } + type Field struct { _tab flatbuffers.Table } @@ -358,6 +360,7 @@ func FieldStartValueVector(builder *flatbuffers.Builder, numElems int) flatbuffe func FieldEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { return builder.EndObject() } + type Point struct { _tab flatbuffers.Table } @@ -538,6 +541,7 @@ func PointAddTimestamp(builder *flatbuffers.Builder, timestamp int64) { func PointEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT { return builder.EndObject() } + type Points struct { _tab flatbuffers.Table } diff --git a/cmd/load_cnosdb/proto/kv_service.pb.go b/cmd/load_cnosdb/proto/kv_service.pb.go index 500b3e4..21faaea 100644 --- a/cmd/load_cnosdb/proto/kv_service.pb.go +++ b/cmd/load_cnosdb/proto/kv_service.pb.go @@ -1,10 +1,10 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.5 -// source: kv_service.proto +// protoc-gen-go v1.28.0 +// protoc v3.21.9 +// source: proto/kv_service.proto -package __ +package proto import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -59,11 +59,11 @@ func (x FieldType) String() string { } func (FieldType) Descriptor() protoreflect.EnumDescriptor { - return file_kv_service_proto_enumTypes[0].Descriptor() + return file_proto_kv_service_proto_enumTypes[0].Descriptor() } func (FieldType) Type() protoreflect.EnumType { - return &file_kv_service_proto_enumTypes[0] + return &file_proto_kv_service_proto_enumTypes[0] } func (x FieldType) Number() protoreflect.EnumNumber { @@ -72,7 +72,7 @@ func (x FieldType) Number() protoreflect.EnumNumber { // Deprecated: Use FieldType.Descriptor instead. func (FieldType) EnumDescriptor() ([]byte, []int) { - return file_kv_service_proto_rawDescGZIP(), []int{0} + return file_proto_kv_service_proto_rawDescGZIP(), []int{0} } type PingRequest struct { @@ -87,7 +87,7 @@ type PingRequest struct { func (x *PingRequest) Reset() { *x = PingRequest{} if protoimpl.UnsafeEnabled { - mi := &file_kv_service_proto_msgTypes[0] + mi := &file_proto_kv_service_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -100,7 +100,7 @@ func (x *PingRequest) String() string { func (*PingRequest) ProtoMessage() {} func (x *PingRequest) ProtoReflect() protoreflect.Message { - mi := &file_kv_service_proto_msgTypes[0] + mi := &file_proto_kv_service_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -113,7 +113,7 @@ func (x *PingRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use PingRequest.ProtoReflect.Descriptor instead. func (*PingRequest) Descriptor() ([]byte, []int) { - return file_kv_service_proto_rawDescGZIP(), []int{0} + return file_proto_kv_service_proto_rawDescGZIP(), []int{0} } func (x *PingRequest) GetVersion() uint64 { @@ -142,7 +142,7 @@ type PingResponse struct { func (x *PingResponse) Reset() { *x = PingResponse{} if protoimpl.UnsafeEnabled { - mi := &file_kv_service_proto_msgTypes[1] + mi := &file_proto_kv_service_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -155,7 +155,7 @@ func (x *PingResponse) String() string { func (*PingResponse) ProtoMessage() {} func (x *PingResponse) ProtoReflect() protoreflect.Message { - mi := &file_kv_service_proto_msgTypes[1] + mi := &file_proto_kv_service_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -168,7 +168,7 @@ func (x *PingResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use PingResponse.ProtoReflect.Descriptor instead. func (*PingResponse) Descriptor() ([]byte, []int) { - return file_kv_service_proto_rawDescGZIP(), []int{1} + return file_proto_kv_service_proto_rawDescGZIP(), []int{1} } func (x *PingResponse) GetVersion() uint64 { @@ -197,7 +197,7 @@ type Tag struct { func (x *Tag) Reset() { *x = Tag{} if protoimpl.UnsafeEnabled { - mi := &file_kv_service_proto_msgTypes[2] + mi := &file_proto_kv_service_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -210,7 +210,7 @@ func (x *Tag) String() string { func (*Tag) ProtoMessage() {} func (x *Tag) ProtoReflect() protoreflect.Message { - mi := &file_kv_service_proto_msgTypes[2] + mi := &file_proto_kv_service_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -223,7 +223,7 @@ func (x *Tag) ProtoReflect() protoreflect.Message { // Deprecated: Use Tag.ProtoReflect.Descriptor instead. func (*Tag) Descriptor() ([]byte, []int) { - return file_kv_service_proto_rawDescGZIP(), []int{2} + return file_proto_kv_service_proto_rawDescGZIP(), []int{2} } func (x *Tag) GetKey() []byte { @@ -253,7 +253,7 @@ type FieldInfo struct { func (x *FieldInfo) Reset() { *x = FieldInfo{} if protoimpl.UnsafeEnabled { - mi := &file_kv_service_proto_msgTypes[3] + mi := &file_proto_kv_service_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -266,7 +266,7 @@ func (x *FieldInfo) String() string { func (*FieldInfo) ProtoMessage() {} func (x *FieldInfo) ProtoReflect() protoreflect.Message { - mi := &file_kv_service_proto_msgTypes[3] + mi := &file_proto_kv_service_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -279,7 +279,7 @@ func (x *FieldInfo) ProtoReflect() protoreflect.Message { // Deprecated: Use FieldInfo.ProtoReflect.Descriptor instead. func (*FieldInfo) Descriptor() ([]byte, []int) { - return file_kv_service_proto_rawDescGZIP(), []int{3} + return file_proto_kv_service_proto_rawDescGZIP(), []int{3} } func (x *FieldInfo) GetFieldType() FieldType { @@ -317,7 +317,7 @@ type AddSeriesRpcRequest struct { func (x *AddSeriesRpcRequest) Reset() { *x = AddSeriesRpcRequest{} if protoimpl.UnsafeEnabled { - mi := &file_kv_service_proto_msgTypes[4] + mi := &file_proto_kv_service_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -330,7 +330,7 @@ func (x *AddSeriesRpcRequest) String() string { func (*AddSeriesRpcRequest) ProtoMessage() {} func (x *AddSeriesRpcRequest) ProtoReflect() protoreflect.Message { - mi := &file_kv_service_proto_msgTypes[4] + mi := &file_proto_kv_service_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -343,7 +343,7 @@ func (x *AddSeriesRpcRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use AddSeriesRpcRequest.ProtoReflect.Descriptor instead. func (*AddSeriesRpcRequest) Descriptor() ([]byte, []int) { - return file_kv_service_proto_rawDescGZIP(), []int{4} + return file_proto_kv_service_proto_rawDescGZIP(), []int{4} } func (x *AddSeriesRpcRequest) GetVersion() uint64 { @@ -388,7 +388,7 @@ type AddSeriesRpcResponse struct { func (x *AddSeriesRpcResponse) Reset() { *x = AddSeriesRpcResponse{} if protoimpl.UnsafeEnabled { - mi := &file_kv_service_proto_msgTypes[5] + mi := &file_proto_kv_service_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -401,7 +401,7 @@ func (x *AddSeriesRpcResponse) String() string { func (*AddSeriesRpcResponse) ProtoMessage() {} func (x *AddSeriesRpcResponse) ProtoReflect() protoreflect.Message { - mi := &file_kv_service_proto_msgTypes[5] + mi := &file_proto_kv_service_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -414,7 +414,7 @@ func (x *AddSeriesRpcResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use AddSeriesRpcResponse.ProtoReflect.Descriptor instead. func (*AddSeriesRpcResponse) Descriptor() ([]byte, []int) { - return file_kv_service_proto_rawDescGZIP(), []int{5} + return file_proto_kv_service_proto_rawDescGZIP(), []int{5} } func (x *AddSeriesRpcResponse) GetVersion() uint64 { @@ -457,7 +457,7 @@ type GetSeriesInfoRpcRequest struct { func (x *GetSeriesInfoRpcRequest) Reset() { *x = GetSeriesInfoRpcRequest{} if protoimpl.UnsafeEnabled { - mi := &file_kv_service_proto_msgTypes[6] + mi := &file_proto_kv_service_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -470,7 +470,7 @@ func (x *GetSeriesInfoRpcRequest) String() string { func (*GetSeriesInfoRpcRequest) ProtoMessage() {} func (x *GetSeriesInfoRpcRequest) ProtoReflect() protoreflect.Message { - mi := &file_kv_service_proto_msgTypes[6] + mi := &file_proto_kv_service_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -483,7 +483,7 @@ func (x *GetSeriesInfoRpcRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetSeriesInfoRpcRequest.ProtoReflect.Descriptor instead. func (*GetSeriesInfoRpcRequest) Descriptor() ([]byte, []int) { - return file_kv_service_proto_rawDescGZIP(), []int{6} + return file_proto_kv_service_proto_rawDescGZIP(), []int{6} } func (x *GetSeriesInfoRpcRequest) GetProtocolVersion() uint64 { @@ -514,7 +514,7 @@ type GetSeriesInfoRpcResponse struct { func (x *GetSeriesInfoRpcResponse) Reset() { *x = GetSeriesInfoRpcResponse{} if protoimpl.UnsafeEnabled { - mi := &file_kv_service_proto_msgTypes[7] + mi := &file_proto_kv_service_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -527,7 +527,7 @@ func (x *GetSeriesInfoRpcResponse) String() string { func (*GetSeriesInfoRpcResponse) ProtoMessage() {} func (x *GetSeriesInfoRpcResponse) ProtoReflect() protoreflect.Message { - mi := &file_kv_service_proto_msgTypes[7] + mi := &file_proto_kv_service_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -540,7 +540,7 @@ func (x *GetSeriesInfoRpcResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetSeriesInfoRpcResponse.ProtoReflect.Descriptor instead. func (*GetSeriesInfoRpcResponse) Descriptor() ([]byte, []int) { - return file_kv_service_proto_rawDescGZIP(), []int{7} + return file_proto_kv_service_proto_rawDescGZIP(), []int{7} } func (x *GetSeriesInfoRpcResponse) GetVersion() uint64 { @@ -583,7 +583,7 @@ type WriteRowsRpcRequest struct { func (x *WriteRowsRpcRequest) Reset() { *x = WriteRowsRpcRequest{} if protoimpl.UnsafeEnabled { - mi := &file_kv_service_proto_msgTypes[8] + mi := &file_proto_kv_service_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -596,7 +596,7 @@ func (x *WriteRowsRpcRequest) String() string { func (*WriteRowsRpcRequest) ProtoMessage() {} func (x *WriteRowsRpcRequest) ProtoReflect() protoreflect.Message { - mi := &file_kv_service_proto_msgTypes[8] + mi := &file_proto_kv_service_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -609,7 +609,7 @@ func (x *WriteRowsRpcRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use WriteRowsRpcRequest.ProtoReflect.Descriptor instead. func (*WriteRowsRpcRequest) Descriptor() ([]byte, []int) { - return file_kv_service_proto_rawDescGZIP(), []int{8} + return file_proto_kv_service_proto_rawDescGZIP(), []int{8} } func (x *WriteRowsRpcRequest) GetVersion() uint64 { @@ -638,7 +638,7 @@ type WriteRowsRpcResponse struct { func (x *WriteRowsRpcResponse) Reset() { *x = WriteRowsRpcResponse{} if protoimpl.UnsafeEnabled { - mi := &file_kv_service_proto_msgTypes[9] + mi := &file_proto_kv_service_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -651,7 +651,7 @@ func (x *WriteRowsRpcResponse) String() string { func (*WriteRowsRpcResponse) ProtoMessage() {} func (x *WriteRowsRpcResponse) ProtoReflect() protoreflect.Message { - mi := &file_kv_service_proto_msgTypes[9] + mi := &file_proto_kv_service_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -664,7 +664,7 @@ func (x *WriteRowsRpcResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use WriteRowsRpcResponse.ProtoReflect.Descriptor instead. func (*WriteRowsRpcResponse) Descriptor() ([]byte, []int) { - return file_kv_service_proto_rawDescGZIP(), []int{9} + return file_proto_kv_service_proto_rawDescGZIP(), []int{9} } func (x *WriteRowsRpcResponse) GetVersion() uint64 { @@ -693,7 +693,7 @@ type WritePointsRpcRequest struct { func (x *WritePointsRpcRequest) Reset() { *x = WritePointsRpcRequest{} if protoimpl.UnsafeEnabled { - mi := &file_kv_service_proto_msgTypes[10] + mi := &file_proto_kv_service_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -706,7 +706,7 @@ func (x *WritePointsRpcRequest) String() string { func (*WritePointsRpcRequest) ProtoMessage() {} func (x *WritePointsRpcRequest) ProtoReflect() protoreflect.Message { - mi := &file_kv_service_proto_msgTypes[10] + mi := &file_proto_kv_service_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -719,7 +719,7 @@ func (x *WritePointsRpcRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use WritePointsRpcRequest.ProtoReflect.Descriptor instead. func (*WritePointsRpcRequest) Descriptor() ([]byte, []int) { - return file_kv_service_proto_rawDescGZIP(), []int{10} + return file_proto_kv_service_proto_rawDescGZIP(), []int{10} } func (x *WritePointsRpcRequest) GetVersion() uint64 { @@ -748,7 +748,7 @@ type WritePointsRpcResponse struct { func (x *WritePointsRpcResponse) Reset() { *x = WritePointsRpcResponse{} if protoimpl.UnsafeEnabled { - mi := &file_kv_service_proto_msgTypes[11] + mi := &file_proto_kv_service_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -761,7 +761,7 @@ func (x *WritePointsRpcResponse) String() string { func (*WritePointsRpcResponse) ProtoMessage() {} func (x *WritePointsRpcResponse) ProtoReflect() protoreflect.Message { - mi := &file_kv_service_proto_msgTypes[11] + mi := &file_proto_kv_service_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -774,7 +774,7 @@ func (x *WritePointsRpcResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use WritePointsRpcResponse.ProtoReflect.Descriptor instead. func (*WritePointsRpcResponse) Descriptor() ([]byte, []int) { - return file_kv_service_proto_rawDescGZIP(), []int{11} + return file_proto_kv_service_proto_rawDescGZIP(), []int{11} } func (x *WritePointsRpcResponse) GetVersion() uint64 { @@ -791,133 +791,134 @@ func (x *WritePointsRpcResponse) GetPoints() []byte { return nil } -var File_kv_service_proto protoreflect.FileDescriptor +var File_proto_kv_service_proto protoreflect.FileDescriptor -var file_kv_service_proto_rawDesc = []byte{ - 0x0a, 0x10, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x12, 0x0a, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x22, 0x3b, - 0x0a, 0x0b, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, +var file_proto_kv_service_proto_rawDesc = []byte{ + 0x0a, 0x16, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x22, 0x3b, 0x0a, 0x0b, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, + 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, + 0x79, 0x22, 0x3c, 0x0a, 0x0c, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x62, + 0x6f, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, + 0x2d, 0x0a, 0x03, 0x54, 0x61, 0x67, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x65, + 0x0a, 0x09, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x34, 0x0a, 0x0a, 0x66, + 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x15, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x46, 0x69, 0x65, + 0x6c, 0x64, 0x54, 0x79, 0x70, 0x65, 0x52, 0x09, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x54, 0x79, 0x70, + 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x02, 0x69, 0x64, 0x22, 0xa0, 0x01, 0x0a, 0x13, 0x41, 0x64, 0x64, 0x53, 0x65, 0x72, + 0x69, 0x65, 0x73, 0x52, 0x70, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, - 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x3c, 0x0a, 0x0c, 0x50, - 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x2d, 0x0a, 0x03, 0x54, 0x61, 0x67, - 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x6b, - 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x65, 0x0a, 0x09, 0x46, 0x69, 0x65, 0x6c, - 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x34, 0x0a, 0x0a, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x74, - 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x6b, 0x76, 0x5f, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x54, 0x79, 0x70, 0x65, - 0x52, 0x09, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, - 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x22, - 0xa0, 0x01, 0x0a, 0x13, 0x41, 0x64, 0x64, 0x53, 0x65, 0x72, 0x69, 0x65, 0x73, 0x52, 0x70, 0x63, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x65, 0x72, 0x69, 0x65, 0x73, 0x5f, 0x69, 0x64, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x72, 0x69, 0x65, 0x73, 0x49, 0x64, 0x12, 0x23, - 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x6b, - 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x54, 0x61, 0x67, 0x52, 0x04, 0x74, - 0x61, 0x67, 0x73, 0x12, 0x2d, 0x0a, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x18, 0x04, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x06, 0x66, 0x69, 0x65, 0x6c, - 0x64, 0x73, 0x22, 0xa1, 0x01, 0x0a, 0x14, 0x41, 0x64, 0x64, 0x53, 0x65, 0x72, 0x69, 0x65, 0x73, - 0x52, 0x70, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x65, 0x72, 0x69, 0x65, 0x73, 0x5f, - 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x72, 0x69, 0x65, 0x73, - 0x49, 0x64, 0x12, 0x23, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x0f, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x54, 0x61, - 0x67, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x2d, 0x0a, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, - 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x06, - 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x22, 0x61, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, - 0x69, 0x65, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x70, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x29, 0x0a, 0x10, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x5f, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, - 0x73, 0x65, 0x72, 0x69, 0x65, 0x73, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, - 0x08, 0x73, 0x65, 0x72, 0x69, 0x65, 0x73, 0x49, 0x64, 0x22, 0xa5, 0x01, 0x0a, 0x18, 0x47, 0x65, - 0x74, 0x53, 0x65, 0x72, 0x69, 0x65, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x70, 0x63, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x65, 0x72, 0x69, 0x65, 0x73, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x72, 0x69, 0x65, 0x73, 0x49, 0x64, 0x12, 0x23, 0x0a, - 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x6b, 0x76, - 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x54, 0x61, 0x67, 0x52, 0x04, 0x74, 0x61, - 0x67, 0x73, 0x12, 0x2d, 0x0a, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x18, 0x04, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, - 0x46, 0x69, 0x65, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, - 0x73, 0x22, 0x43, 0x0a, 0x13, 0x57, 0x72, 0x69, 0x74, 0x65, 0x52, 0x6f, 0x77, 0x73, 0x52, 0x70, - 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x77, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, - 0x52, 0x04, 0x72, 0x6f, 0x77, 0x73, 0x22, 0x44, 0x0a, 0x14, 0x57, 0x72, 0x69, 0x74, 0x65, 0x52, - 0x6f, 0x77, 0x73, 0x52, 0x70, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, - 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, - 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x77, 0x73, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x72, 0x6f, 0x77, 0x73, 0x22, 0x49, 0x0a, 0x15, - 0x57, 0x72, 0x69, 0x74, 0x65, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x52, 0x70, 0x63, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, - 0x16, 0x0a, 0x06, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x06, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x22, 0x4a, 0x0a, 0x16, 0x57, 0x72, 0x69, 0x74, 0x65, - 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x52, 0x70, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x65, 0x72, 0x69, 0x65, + 0x73, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x72, 0x69, + 0x65, 0x73, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x03, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, + 0x54, 0x61, 0x67, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x2d, 0x0a, 0x06, 0x66, 0x69, 0x65, + 0x6c, 0x64, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6b, 0x76, 0x5f, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, + 0x52, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x22, 0xa1, 0x01, 0x0a, 0x14, 0x41, 0x64, 0x64, + 0x53, 0x65, 0x72, 0x69, 0x65, 0x73, 0x52, 0x70, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x04, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x70, - 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x70, 0x6f, 0x69, - 0x6e, 0x74, 0x73, 0x2a, 0x4a, 0x0a, 0x09, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x54, 0x79, 0x70, 0x65, - 0x12, 0x09, 0x0a, 0x05, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x49, - 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x6e, 0x73, 0x69, - 0x67, 0x6e, 0x65, 0x64, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x42, 0x6f, 0x6f, 0x6c, 0x65, 0x61, - 0x6e, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x10, 0x05, 0x32, - 0xaa, 0x03, 0x0a, 0x0b, 0x54, 0x53, 0x4b, 0x56, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, - 0x39, 0x0a, 0x04, 0x50, 0x69, 0x6e, 0x67, 0x12, 0x17, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x18, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x50, 0x69, - 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x50, 0x0a, 0x09, 0x41, 0x64, - 0x64, 0x53, 0x65, 0x72, 0x69, 0x65, 0x73, 0x12, 0x1f, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x2e, 0x41, 0x64, 0x64, 0x53, 0x65, 0x72, 0x69, 0x65, 0x73, 0x52, 0x70, - 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x41, 0x64, 0x64, 0x53, 0x65, 0x72, 0x69, 0x65, 0x73, 0x52, - 0x70, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5c, 0x0a, 0x0d, - 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x69, 0x65, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x23, 0x2e, - 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, - 0x72, 0x69, 0x65, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x70, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, + 0x28, 0x04, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x73, + 0x65, 0x72, 0x69, 0x65, 0x73, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, + 0x73, 0x65, 0x72, 0x69, 0x65, 0x73, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, + 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x2e, 0x54, 0x61, 0x67, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x2d, 0x0a, + 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, + 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, + 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x22, 0x61, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x69, 0x65, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x70, 0x63, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x54, 0x0a, 0x09, 0x57, 0x72, - 0x69, 0x74, 0x65, 0x52, 0x6f, 0x77, 0x73, 0x12, 0x1f, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x2e, 0x57, 0x72, 0x69, 0x74, 0x65, 0x52, 0x6f, 0x77, 0x73, 0x52, 0x70, - 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x57, 0x72, 0x69, 0x74, 0x65, 0x52, 0x6f, 0x77, 0x73, 0x52, - 0x70, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, - 0x12, 0x5a, 0x0a, 0x0b, 0x57, 0x72, 0x69, 0x74, 0x65, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x12, - 0x21, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x57, 0x72, 0x69, - 0x74, 0x65, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x52, 0x70, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, - 0x57, 0x72, 0x69, 0x74, 0x65, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x52, 0x70, 0x63, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x42, 0x04, 0x5a, 0x02, - 0x2e, 0x2f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x29, 0x0a, 0x10, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x63, 0x6f, 0x6c, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x0f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x56, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x65, 0x72, 0x69, 0x65, 0x73, 0x5f, 0x69, 0x64, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x72, 0x69, 0x65, 0x73, 0x49, 0x64, 0x22, + 0xa5, 0x01, 0x0a, 0x18, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x69, 0x65, 0x73, 0x49, 0x6e, 0x66, + 0x6f, 0x52, 0x70, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x76, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x65, 0x72, 0x69, 0x65, 0x73, + 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x72, 0x69, 0x65, + 0x73, 0x49, 0x64, 0x12, 0x23, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x0f, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x54, + 0x61, 0x67, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x2d, 0x0a, 0x06, 0x66, 0x69, 0x65, 0x6c, + 0x64, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x52, + 0x06, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x73, 0x22, 0x43, 0x0a, 0x13, 0x57, 0x72, 0x69, 0x74, 0x65, + 0x52, 0x6f, 0x77, 0x73, 0x52, 0x70, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, + 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x77, 0x73, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x72, 0x6f, 0x77, 0x73, 0x22, 0x44, 0x0a, 0x14, + 0x57, 0x72, 0x69, 0x74, 0x65, 0x52, 0x6f, 0x77, 0x73, 0x52, 0x70, 0x63, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, + 0x0a, 0x04, 0x72, 0x6f, 0x77, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x72, 0x6f, + 0x77, 0x73, 0x22, 0x49, 0x0a, 0x15, 0x57, 0x72, 0x69, 0x74, 0x65, 0x50, 0x6f, 0x69, 0x6e, 0x74, + 0x73, 0x52, 0x70, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x76, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x76, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x22, 0x4a, 0x0a, + 0x16, 0x57, 0x72, 0x69, 0x74, 0x65, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x52, 0x70, 0x63, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x06, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x2a, 0x4a, 0x0a, 0x09, 0x46, 0x69, 0x65, + 0x6c, 0x64, 0x54, 0x79, 0x70, 0x65, 0x12, 0x09, 0x0a, 0x05, 0x46, 0x6c, 0x6f, 0x61, 0x74, 0x10, + 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x10, 0x01, 0x12, 0x0c, + 0x0a, 0x08, 0x55, 0x6e, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, + 0x42, 0x6f, 0x6f, 0x6c, 0x65, 0x61, 0x6e, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x74, 0x72, + 0x69, 0x6e, 0x67, 0x10, 0x05, 0x32, 0xaa, 0x03, 0x0a, 0x0b, 0x54, 0x53, 0x4b, 0x56, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x39, 0x0a, 0x04, 0x50, 0x69, 0x6e, 0x67, 0x12, 0x17, 0x2e, + 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x50, 0x0a, 0x09, 0x41, 0x64, 0x64, 0x53, 0x65, 0x72, 0x69, 0x65, 0x73, 0x12, 0x1f, 0x2e, + 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x41, 0x64, 0x64, 0x53, 0x65, + 0x72, 0x69, 0x65, 0x73, 0x52, 0x70, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, + 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x41, 0x64, 0x64, 0x53, + 0x65, 0x72, 0x69, 0x65, 0x73, 0x52, 0x70, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x00, 0x12, 0x5c, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x69, 0x65, 0x73, 0x49, + 0x6e, 0x66, 0x6f, 0x12, 0x23, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x69, 0x65, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x70, + 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x69, 0x65, 0x73, 0x49, + 0x6e, 0x66, 0x6f, 0x52, 0x70, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x54, 0x0a, 0x09, 0x57, 0x72, 0x69, 0x74, 0x65, 0x52, 0x6f, 0x77, 0x73, 0x12, 0x1f, 0x2e, + 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x57, 0x72, 0x69, 0x74, 0x65, + 0x52, 0x6f, 0x77, 0x73, 0x52, 0x70, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, + 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x57, 0x72, 0x69, 0x74, + 0x65, 0x52, 0x6f, 0x77, 0x73, 0x52, 0x70, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x12, 0x5a, 0x0a, 0x0b, 0x57, 0x72, 0x69, 0x74, 0x65, 0x50, + 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x12, 0x21, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x2e, 0x57, 0x72, 0x69, 0x74, 0x65, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x52, 0x70, + 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x6b, 0x76, 0x5f, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x57, 0x72, 0x69, 0x74, 0x65, 0x50, 0x6f, 0x69, 0x6e, 0x74, + 0x73, 0x52, 0x70, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, + 0x30, 0x01, 0x42, 0x09, 0x5a, 0x07, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_kv_service_proto_rawDescOnce sync.Once - file_kv_service_proto_rawDescData = file_kv_service_proto_rawDesc + file_proto_kv_service_proto_rawDescOnce sync.Once + file_proto_kv_service_proto_rawDescData = file_proto_kv_service_proto_rawDesc ) -func file_kv_service_proto_rawDescGZIP() []byte { - file_kv_service_proto_rawDescOnce.Do(func() { - file_kv_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_kv_service_proto_rawDescData) +func file_proto_kv_service_proto_rawDescGZIP() []byte { + file_proto_kv_service_proto_rawDescOnce.Do(func() { + file_proto_kv_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_kv_service_proto_rawDescData) }) - return file_kv_service_proto_rawDescData + return file_proto_kv_service_proto_rawDescData } -var file_kv_service_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_kv_service_proto_msgTypes = make([]protoimpl.MessageInfo, 12) -var file_kv_service_proto_goTypes = []interface{}{ +var file_proto_kv_service_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_proto_kv_service_proto_msgTypes = make([]protoimpl.MessageInfo, 12) +var file_proto_kv_service_proto_goTypes = []interface{}{ (FieldType)(0), // 0: kv_service.FieldType (*PingRequest)(nil), // 1: kv_service.PingRequest (*PingResponse)(nil), // 2: kv_service.PingResponse @@ -932,7 +933,7 @@ var file_kv_service_proto_goTypes = []interface{}{ (*WritePointsRpcRequest)(nil), // 11: kv_service.WritePointsRpcRequest (*WritePointsRpcResponse)(nil), // 12: kv_service.WritePointsRpcResponse } -var file_kv_service_proto_depIdxs = []int32{ +var file_proto_kv_service_proto_depIdxs = []int32{ 0, // 0: kv_service.FieldInfo.field_type:type_name -> kv_service.FieldType 3, // 1: kv_service.AddSeriesRpcRequest.tags:type_name -> kv_service.Tag 4, // 2: kv_service.AddSeriesRpcRequest.fields:type_name -> kv_service.FieldInfo @@ -957,13 +958,13 @@ var file_kv_service_proto_depIdxs = []int32{ 0, // [0:7] is the sub-list for field type_name } -func init() { file_kv_service_proto_init() } -func file_kv_service_proto_init() { - if File_kv_service_proto != nil { +func init() { file_proto_kv_service_proto_init() } +func file_proto_kv_service_proto_init() { + if File_proto_kv_service_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_kv_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_proto_kv_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*PingRequest); i { case 0: return &v.state @@ -975,7 +976,7 @@ func file_kv_service_proto_init() { return nil } } - file_kv_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_proto_kv_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*PingResponse); i { case 0: return &v.state @@ -987,7 +988,7 @@ func file_kv_service_proto_init() { return nil } } - file_kv_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_proto_kv_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Tag); i { case 0: return &v.state @@ -999,7 +1000,7 @@ func file_kv_service_proto_init() { return nil } } - file_kv_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_proto_kv_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*FieldInfo); i { case 0: return &v.state @@ -1011,7 +1012,7 @@ func file_kv_service_proto_init() { return nil } } - file_kv_service_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_proto_kv_service_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*AddSeriesRpcRequest); i { case 0: return &v.state @@ -1023,7 +1024,7 @@ func file_kv_service_proto_init() { return nil } } - file_kv_service_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_proto_kv_service_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*AddSeriesRpcResponse); i { case 0: return &v.state @@ -1035,7 +1036,7 @@ func file_kv_service_proto_init() { return nil } } - file_kv_service_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_proto_kv_service_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetSeriesInfoRpcRequest); i { case 0: return &v.state @@ -1047,7 +1048,7 @@ func file_kv_service_proto_init() { return nil } } - file_kv_service_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_proto_kv_service_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetSeriesInfoRpcResponse); i { case 0: return &v.state @@ -1059,7 +1060,7 @@ func file_kv_service_proto_init() { return nil } } - file_kv_service_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_proto_kv_service_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*WriteRowsRpcRequest); i { case 0: return &v.state @@ -1071,7 +1072,7 @@ func file_kv_service_proto_init() { return nil } } - file_kv_service_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + file_proto_kv_service_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*WriteRowsRpcResponse); i { case 0: return &v.state @@ -1083,7 +1084,7 @@ func file_kv_service_proto_init() { return nil } } - file_kv_service_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + file_proto_kv_service_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*WritePointsRpcRequest); i { case 0: return &v.state @@ -1095,7 +1096,7 @@ func file_kv_service_proto_init() { return nil } } - file_kv_service_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_proto_kv_service_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*WritePointsRpcResponse); i { case 0: return &v.state @@ -1112,19 +1113,19 @@ func file_kv_service_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_kv_service_proto_rawDesc, + RawDescriptor: file_proto_kv_service_proto_rawDesc, NumEnums: 1, NumMessages: 12, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_kv_service_proto_goTypes, - DependencyIndexes: file_kv_service_proto_depIdxs, - EnumInfos: file_kv_service_proto_enumTypes, - MessageInfos: file_kv_service_proto_msgTypes, + GoTypes: file_proto_kv_service_proto_goTypes, + DependencyIndexes: file_proto_kv_service_proto_depIdxs, + EnumInfos: file_proto_kv_service_proto_enumTypes, + MessageInfos: file_proto_kv_service_proto_msgTypes, }.Build() - File_kv_service_proto = out.File - file_kv_service_proto_rawDesc = nil - file_kv_service_proto_goTypes = nil - file_kv_service_proto_depIdxs = nil + File_proto_kv_service_proto = out.File + file_proto_kv_service_proto_rawDesc = nil + file_proto_kv_service_proto_goTypes = nil + file_proto_kv_service_proto_depIdxs = nil } diff --git a/cmd/load_cnosdb/proto/kv_service.proto b/cmd/load_cnosdb/proto/kv_service.proto index 1b9cf06..96a3ac7 100644 --- a/cmd/load_cnosdb/proto/kv_service.proto +++ b/cmd/load_cnosdb/proto/kv_service.proto @@ -1,6 +1,6 @@ syntax = "proto3"; package kv_service; -option go_package = "proto"; +option go_package = "./proto"; message PingRequest { uint64 version = 1; @@ -87,4 +87,4 @@ service TSKVService { rpc WriteRows(stream WriteRowsRpcRequest) returns (stream WriteRowsRpcResponse) {}; rpc WritePoints(stream WritePointsRpcRequest) returns (stream WritePointsRpcResponse) {}; -} \ No newline at end of file +} diff --git a/cmd/load_cnosdb/proto/kv_service_grpc.pb.go b/cmd/load_cnosdb/proto/kv_service_grpc.pb.go index 3b44b59..908f54b 100644 --- a/cmd/load_cnosdb/proto/kv_service_grpc.pb.go +++ b/cmd/load_cnosdb/proto/kv_service_grpc.pb.go @@ -1,10 +1,10 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.2.0 -// - protoc v3.21.5 -// source: kv_service.proto +// - protoc v3.21.9 +// source: proto/kv_service.proto -package __ +package proto import ( context "context" @@ -310,5 +310,5 @@ var TSKVService_ServiceDesc = grpc.ServiceDesc{ ClientStreams: true, }, }, - Metadata: "kv_service.proto", + Metadata: "proto/kv_service.proto", } From 975f62784a8a5868b4c7228e10f72e0ad375ec9e Mon Sep 17 00:00:00 2001 From: zipper-meng Date: Tue, 29 Nov 2022 12:03:06 +0800 Subject: [PATCH 7/7] fix using deprecated api --- cmd/load_cnosdb/http_writer.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/load_cnosdb/http_writer.go b/cmd/load_cnosdb/http_writer.go index 21862a5..9be3a97 100644 --- a/cmd/load_cnosdb/http_writer.go +++ b/cmd/load_cnosdb/http_writer.go @@ -17,6 +17,7 @@ import ( flatbuffers "github.com/google/flatbuffers/go" "github.com/valyala/fasthttp" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" ) const ( @@ -61,7 +62,9 @@ type HTTPWriter struct { // NewHTTPWriter returns a new HTTPWriter from the supplied HTTPWriterConfig. func NewHTTPWriter(c HTTPWriterConfig, consistency string) *HTTPWriter { - conn, err := grpc.Dial(c.Host, grpc.WithInsecure(), grpc.WithBlock(), grpc.WithTimeout(10*time.Second)) + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + conn, err := grpc.DialContext(ctx, c.Host, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock()) if err != nil { panic(err) }