diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 1b068c96..80eed46b 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -32,14 +32,17 @@ jobs: matrix: gemini-features: ["basic", "normal", "all"] gemini-concurrency: [16] - oracle-scylla-version: ["6.1.1"] - test-scylla-version: ["6.1.1"] + duration: ["5m"] + dataset-size: [large, small] + oracle-scylla-version: ["6.1"] + test-scylla-version: ["6.1"] fail-fast: false steps: - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 - name: Start ScyllaDB id: scylla + shell: bash run: | chmod +x ./bin/gemini make scylla-setup \ @@ -51,14 +54,17 @@ jobs: make integration-test \ CONCURRENCY=${{ matrix.gemini-concurrency }} \ CQL_FEATURES=${{ matrix.gemini-features }} \ - DURATION=5m + DURATION=${{ matrix.duration }} \ + DATASET_SIZE=${{ matrix.dataset-size }} \ - name: Shutdown ScyllaDB + shell: bash run: | make scylla-shutdown \ SCYLLA_TEST_VERSION=${{ matrix.test-scylla-version }} \ SCYLLA_ORACLE_VERSION=${{ matrix.oracle-scylla-version }} - uses: actions/upload-artifact@v4 + if: always() with: name: results-${{ matrix.gemini-features }}-${{ matrix.gemini-concurrency }} path: ./results diff --git a/Makefile b/Makefile index a845e74b..07b0259d 100644 --- a/Makefile +++ b/Makefile @@ -35,14 +35,14 @@ fix: $(GOBIN)/golangci-lint .PHONY: build build: - CGO_ENABLED=0 go build -ldflags="-asan" -gcflags "all=-N -l" -o bin/gemini ./cmd/gemini + @CGO_ENABLED=0 go build -o bin/gemini ./cmd/gemini debug-build: - CGO_ENABLED=0 go build -gcflags "all=-N -l" -o bin/gemini ./cmd/gemini + @CGO_ENABLED=0 go build -ldflags="-asan" -gcflags "all=-N -l" -o bin/gemini ./cmd/gemini .PHONY: build-docker build-docker: - docker build --target production -t scylladb/gemini:$(DOCKER_VERSION) --compress . + @docker build --target production -t scylladb/gemini:$(DOCKER_VERSION) --compress . .PHONY: scylla-setup scylla-setup: @@ -57,46 +57,51 @@ scylla-shutdown: .PHONY: test test: - go test -covermode=atomic -race -coverprofile=coverage.txt -timeout 5m -json -v ./... 2>&1 | gotestfmt -showteststatus + @go test -covermode=atomic -race -coverprofile=coverage.txt -timeout 5m -json -v ./... 2>&1 | gotestfmt -showteststatus -CQL_FEATURES := normal -CONCURRENCY := 16 -DURATION := 10m -WARMUP := 1m -SEED := $(shell date +%s | tee ./results/gemini_seed) +CQL_FEATURES ?= normal +CONCURRENCY ?= 16 +DURATION ?= 1m +WARMUP ?= 1m +DATASET_SIZE ?= large +SEED ?= $(shell date +%s | tee ./results/gemini_seed) .PHONY: integration-test -integration-test: build - mkdir -p ./results - touch ./results/gemini_seed - ./bin/gemini \ +integration-test: debug-build + @mkdir -p $(PWD)/results + @touch $(PWD)/results/gemini_seed + @./bin/gemini \ + --dataset-size=$(DATASET_SIZE) \ + --seed=$(SEED) \ + --schema-seed=$(SEED) \ + --cql-features $(CQL_FEATURES) \ + --duration $(DURATION) \ + --warmup $(WARMUP) \ --drop-schema true \ --fail-fast \ + --level info \ --non-interactive \ --materialized-views false \ - --dataset-size=large \ - --outfile ./results/gemini.log \ - --test-statement-log-file ./results/gemini_test_statements.log \ - --oracle-statement-log-file ./results/gemini_oracle_statements.log \ + --consistency LOCAL_QUORUM \ + --outfile $(PWD)/results/gemini.log \ + --test-statement-log-file $(PWD)/results/gemini_test_statements.log \ + --oracle-statement-log-file $(PWD)/results/gemini_oracle_statements.log \ --test-host-selection-policy token-aware \ --oracle-host-selection-policy token-aware \ - --seed=$(SEED) \ --test-cluster=$(shell docker inspect --format='{{ .NetworkSettings.Networks.gemini.IPAddress }}' gemini-test) \ --oracle-cluster=$(shell docker inspect --format='{{ .NetworkSettings.Networks.gemini.IPAddress }}' gemini-oracle) \ - --outfile ./results/gemini_result.log \ - --duration $(DURATION) \ - --warmup $(WARMUP) \ - -m mixed \ + --outfile $(PWD)/results/gemini_result.log \ + --mode mixed \ --non-interactive \ - --cql-features $(CQL_FEATURES) \ --request-timeout 180s \ --connect-timeout 120s \ --consistency LOCAL_QUORUM \ - --use-server-timestamps true \ + --use-server-timestamps false \ --async-objects-stabilization-attempts 10 \ --async-objects-stabilization-backoff 100ms \ --replication-strategy "{'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}" \ --oracle-replication-strategy "{'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}" \ - --max-mutation-retries 1 \ - --max-mutation-retries-backoff 500ms \ - -c $(CONCURRENCY) + --max-mutation-retries 5 \ + --max-mutation-retries-backoff 1000ms \ + --concurrency $(CONCURRENCY) \ + --tracing-outfile $(PWD)/results/gemini_tracing.log diff --git a/cmd/gemini/spinner.go b/cmd/gemini/spinner.go index 96e383bd..1826dfe7 100644 --- a/cmd/gemini/spinner.go +++ b/cmd/gemini/spinner.go @@ -25,7 +25,7 @@ type spinningFeedback struct { s *spinner.Spinner } -func (sf *spinningFeedback) Set(format string, args ...interface{}) { +func (sf *spinningFeedback) Set(format string, args ...any) { if sf.s != nil { sf.s.Suffix = fmt.Sprintf(format, args...) } diff --git a/docs/architecture.md b/docs/architecture.md index 63c028cc..ff72a02a 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -9,7 +9,7 @@ database clusters. ## The different Jobs 1. ___MutationJob___: This job applies mutations to the clusters. The mutations can be of several types. - The basic _INSERT_ and _DELETE_ with various conditions or ___DDL___ type statements such as _ALTER_ the + The basic _INSERT_ and _DELETE_ with various conditions or ___DDL___ type statements such as _ALTER_ the structure of the table. These type of mutations happen with different frequency with normal _INSERT_ being the most common and _ALTER_ the most infrequent. @@ -39,7 +39,7 @@ The application allows the user to decide the level of concurrency that Gemini o The toggle `--concurrency` currently means that the application will create that number of ___READ___ and ___WRITE___ jobs when running _mixed_ mode. If running in ___WRITE___ or ___READ___ mode it will correspond to the exact number of job executing goroutines. Each goroutine is only -working on a subset of the data (from now known as bucket) when mutating and validating to avoid +working on a subset of the data (from now known as bucket) when mutating and validating to avoid concurrent modification races when validating the system under test. This can still happen when executing read queries that performs an index scan. @@ -56,7 +56,7 @@ in use but the idea is to introduce some jitter into the execution flow. The application generates partition ids through a `Generator` that creates a steady flow of partition key components for the desired [concurrency](architecture.md#Concurrency). Each goroutine is connected to a `partition` that the generator controls. This partition continuously emits -new partition ids in the form of a `[]interface{}`. These keys are created in the same way as the the +new partition ids in the form of a `[]any`. These keys are created in the same way as the the driver does to ensure that each goroutine only processes partition keys from it's designated bucket. These partition keys These values are copied into another list that keeps the old partition ids for later reuse. The idea of reusing the partition keys is that probability of hitting the same partition @@ -72,14 +72,14 @@ ___NB___:There are probably issues with this approach and we may want to refine There are a number of core data structures that has a more central place in Gemini's design. * Schema - + Gemini has a top level data structure named `Schema`. This structure a loose wrapper around a keyspace and a list of tables. It furthermore contains exported methods for generating a schema and it's corresponding CQL DDL statements allowing for creating the tables in the database. It also holds the methods for creating queries of all kinds which are used in the main Gemini program. * Table - + Tables are conceptually very similar to regular CQL tables. Their base elements are partition keys, clustering keys and columns. They also may contain materialized views and indexes depending on user preferences. diff --git a/pkg/generators/utils.go b/pkg/generators/utils.go index e582d88b..e5758dc0 100644 --- a/pkg/generators/utils.go +++ b/pkg/generators/utils.go @@ -20,8 +20,8 @@ import ( "github.com/scylladb/gemini/pkg/typedef" ) -func CreatePartitionKeyValues(table *typedef.Table, r *rand.Rand, g *typedef.PartitionRangeConfig) []interface{} { - values := make([]interface{}, 0, table.PartitionKeysLenValues()) +func CreatePartitionKeyValues(table *typedef.Table, r *rand.Rand, g *typedef.PartitionRangeConfig) []any { + values := make([]any, 0, table.PartitionKeysLenValues()) for _, pk := range table.PartitionKeys { values = append(values, pk.Type.GenValue(r, g)...) } diff --git a/pkg/inflight/inflight_test.go b/pkg/inflight/inflight_test.go index 5a27e230..e0d4a7c7 100644 --- a/pkg/inflight/inflight_test.go +++ b/pkg/inflight/inflight_test.go @@ -69,10 +69,10 @@ func TestDeleteSharded(t *testing.T) { func TestInflight(t *testing.T) { t.Parallel() flight := newSyncU64set(shrinkInflightsLimit) - f := func(v uint64) interface{} { + f := func(v uint64) any { return flight.AddIfNotPresent(v) } - g := func(v uint64) interface{} { + g := func(v uint64) any { flight.Delete(v) return !flight.Has(v) } @@ -105,10 +105,10 @@ func TestAutoShrink(t *testing.T) { func TestInflightSharded(t *testing.T) { t.Parallel() flight := newShardedSyncU64set() - f := func(v uint64) interface{} { + f := func(v uint64) any { return flight.AddIfNotPresent(v) } - g := func(v uint64) interface{} { + g := func(v uint64) any { flight.Delete(v) return !flight.shards[v%256].Has(v) } diff --git a/pkg/joberror/joberror_test.go b/pkg/joberror/joberror_test.go index 60c72bef..1cba3793 100644 --- a/pkg/joberror/joberror_test.go +++ b/pkg/joberror/joberror_test.go @@ -33,7 +33,7 @@ func TestParallel(t *testing.T) { wg := sync.WaitGroup{} resultList := joberror.NewErrorList(1000) expectedList := joberror.NewErrorList(1000) - baseDate := time.Date(2020, 02, 01, 0, 0, 0, 0, time.UTC) + baseDate := time.Date(2020, 0o2, 0o1, 0, 0, 0, 0, time.UTC) idx := atomic.Int32{} for y := 0; y < 1000; y++ { expectedList.AddError(&joberror.JobError{ @@ -73,7 +73,7 @@ func TestErrorSerialization(t *testing.T) { t.Parallel() expected := []byte(`{"timestamp":"2020-02-01T00:00:00Z","message":"Some Message","query":"Some Query","stmt-type":"Some Type"}`) result, err := json.Marshal(joberror.JobError{ - Timestamp: time.Date(2020, 02, 01, 0, 0, 0, 0, time.UTC), + Timestamp: time.Date(2020, 0o2, 0o1, 0, 0, 0, 0, time.UTC), Message: "Some Message", Query: "Some Query", StmtType: "Some Type", @@ -92,7 +92,7 @@ func TestErrorListSerialization(t *testing.T) { //nolint:lll expected := []byte(`[{"timestamp":"2020-02-01T00:00:00Z","message":"Some Message 0","query":"Some Query 0","stmt-type":"Some Stmt Type 0"},{"timestamp":"2020-02-02T00:00:00Z","message":"Some Message 1","query":"Some Query 1","stmt-type":"Some Stmt Type 1"},{"timestamp":"2020-02-03T00:00:00Z","message":"Some Message 2","query":"Some Query 2","stmt-type":"Some Stmt Type 2"},{"timestamp":"2020-02-04T00:00:00Z","message":"Some Message 3","query":"Some Query 3","stmt-type":"Some Stmt Type 3"},{"timestamp":"2020-02-05T00:00:00Z","message":"Some Message 4","query":"Some Query 4","stmt-type":"Some Stmt Type 4"},{"timestamp":"2020-02-06T00:00:00Z","message":"Some Message 5","query":"Some Query 5","stmt-type":"Some Stmt Type 5"},{"timestamp":"2020-02-07T00:00:00Z","message":"Some Message 6","query":"Some Query 6","stmt-type":"Some Stmt Type 6"},{"timestamp":"2020-02-08T00:00:00Z","message":"Some Message 7","query":"Some Query 7","stmt-type":"Some Stmt Type 7"},{"timestamp":"2020-02-09T00:00:00Z","message":"Some Message 8","query":"Some Query 8","stmt-type":"Some Stmt Type 8"},{"timestamp":"2020-02-10T00:00:00Z","message":"Some Message 9","query":"Some Query 9","stmt-type":"Some Stmt Type 9"}]`) lst := joberror.NewErrorList(1000) - baseDate := time.Date(2020, 02, 01, 0, 0, 0, 0, time.UTC) + baseDate := time.Date(2020, 0o2, 0o1, 0, 0, 0, 0, time.UTC) for y := 0; y < 10; y++ { lst.AddError(&joberror.JobError{ Timestamp: baseDate.AddDate(0, 0, y), diff --git a/pkg/jobs/gen_check_stmt.go b/pkg/jobs/gen_check_stmt.go index 15b53fba..3822b409 100644 --- a/pkg/jobs/gen_check_stmt.go +++ b/pkg/jobs/gen_check_stmt.go @@ -165,7 +165,7 @@ func genSinglePartitionQueryMv( values := valuesWithToken.Value.Copy() if mv.HaveNonPrimaryKey() { - var mvValues []interface{} + var mvValues []any mvValues = append(mvValues, mv.NonPrimaryKey.Type.GenValue(r, p)...) values = append(mvValues, values...) } @@ -189,7 +189,7 @@ func genMultiplePartitionQuery( t.RLock() defer t.RUnlock() typs := make([]typedef.Type, numQueryPKs*t.PartitionKeys.Len()) - values := make([]interface{}, numQueryPKs*t.PartitionKeys.Len()) + values := make([]any, numQueryPKs*t.PartitionKeys.Len()) builder := qb.Select(s.Keyspace.Name + "." + t.Name) tokens := make([]*typedef.ValueWithToken, 0, numQueryPKs) @@ -233,7 +233,7 @@ func genMultiplePartitionQueryMv( mv := t.MaterializedViews[mvNum] typs := make([]typedef.Type, numQueryPKs*mv.PartitionKeys.Len()) - values := make([]interface{}, numQueryPKs*mv.PartitionKeys.Len()) + values := make([]any, numQueryPKs*mv.PartitionKeys.Len()) builder := qb.Select(s.Keyspace.Name + "." + t.Name) tokens := make([]*typedef.ValueWithToken, 0, numQueryPKs) @@ -245,7 +245,7 @@ func genMultiplePartitionQueryMv( return nil } tokens = append(tokens, vs) - vals := make([]interface{}, mv.PartitionKeys.Len()) + vals := make([]any, mv.PartitionKeys.Len()) if mv.HaveNonPrimaryKey() { vals[0] = mv.NonPrimaryKey.Type.GenValue(r, p) copy(vals[1:], vs.Value.Copy()) @@ -335,7 +335,7 @@ func genClusteringRangeQueryMv( values := vs.Value.Copy() mv := t.MaterializedViews[mvNum] if mv.HaveNonPrimaryKey() { - mvValues := append([]interface{}{}, mv.NonPrimaryKey.Type.GenValue(r, p)...) + mvValues := append([]any{}, mv.NonPrimaryKey.Type.GenValue(r, p)...) values = append(mvValues, values...) } builder := qb.Select(s.Keyspace.Name + "." + mv.Name) @@ -525,7 +525,7 @@ func genSingleIndexQuery( defer t.RUnlock() var ( - values []interface{} + values []any typs []typedef.Type ) diff --git a/pkg/jobs/gen_ddl_stmt.go b/pkg/jobs/gen_ddl_stmt.go index 9d14fc73..a8866fd4 100644 --- a/pkg/jobs/gen_ddl_stmt.go +++ b/pkg/jobs/gen_ddl_stmt.go @@ -45,7 +45,7 @@ func GenDDLStmt(s *typedef.Schema, t *typedef.Table, r *rand.Rand, _ *typedef.Pa } } -func appendValue(columnType typedef.Type, r *rand.Rand, p *typedef.PartitionRangeConfig, values []interface{}) []interface{} { +func appendValue(columnType typedef.Type, r *rand.Rand, p *typedef.PartitionRangeConfig, values []any) []any { return append(values, columnType.GenValue(r, p)...) } diff --git a/pkg/jobs/gen_mutate_stmt.go b/pkg/jobs/gen_mutate_stmt.go index 9f903d9c..6f65caab 100644 --- a/pkg/jobs/gen_mutate_stmt.go +++ b/pkg/jobs/gen_mutate_stmt.go @@ -129,13 +129,13 @@ func genInsertJSONStmt( return nil, nil } vs := valuesWithToken.Value.Copy() - values := make(map[string]interface{}) + values := make(map[string]any) for i, pk := range table.PartitionKeys { switch t := pk.Type.(type) { case typedef.SimpleType: values[pk.Name] = convertForJSON(t, vs[i]) case *typedef.TupleType: - tupVals := make([]interface{}, len(t.ValueTypes)) + tupVals := make([]any, len(t.ValueTypes)) for j := 0; j < len(t.ValueTypes); j++ { tupVals[i] = convertForJSON(t, vs[i]) i++ @@ -161,7 +161,7 @@ func genInsertJSONStmt( QueryType: typedef.InsertJSONStatementType, }, ValuesWithToken: []*typedef.ValueWithToken{valuesWithToken}, - Values: []interface{}{string(jsonString)}, + Values: []any{string(jsonString)}, }, nil } @@ -180,7 +180,7 @@ func genDeleteRows(_ *typedef.Schema, t *typedef.Table, valuesWithToken *typedef }, nil } -func convertForJSON(vType typedef.Type, value interface{}) interface{} { +func convertForJSON(vType typedef.Type, value any) any { switch vType { case typedef.TYPE_BLOB: val, _ := value.(string) diff --git a/pkg/jobs/gen_utils_test.go b/pkg/jobs/gen_utils_test.go index db0eb3db..04ad7a7d 100644 --- a/pkg/jobs/gen_utils_test.go +++ b/pkg/jobs/gen_utils_test.go @@ -151,7 +151,7 @@ func (r results) Diff(t results) string { return strings.Join(out, "\n") } -func convertStmtsToResults(stmt interface{}) results { +func convertStmtsToResults(stmt any) results { var out results switch stmts := stmt.(type) { case *typedef.Stmts: @@ -239,7 +239,7 @@ func GetCkCountFromOptions(options testutils.TestCaseOptions, allValue int) int return ckCount } -func validateStmt(t *testing.T, stmt interface{}, err error) { +func validateStmt(t *testing.T, stmt any, err error) { t.Helper() if err != nil { t.Fatalf("error: get an error on create test inputs:%v", err) diff --git a/pkg/replication/replication.go b/pkg/replication/replication.go index 8bd80d66..e0e26ef6 100644 --- a/pkg/replication/replication.go +++ b/pkg/replication/replication.go @@ -19,7 +19,7 @@ import ( "strings" ) -type Replication map[string]interface{} +type Replication map[string]any func (r *Replication) ToCQL() string { b, _ := json.Marshal(r) @@ -41,7 +41,7 @@ func NewNetworkTopologyStrategy() *Replication { } func (r *Replication) UnmarshalJSON(data []byte) error { - dataMap := make(map[string]interface{}) + dataMap := make(map[string]any) if err := json.Unmarshal(data, &dataMap); err != nil { return err } diff --git a/pkg/routingkey/routing_key.go b/pkg/routingkey/routing_key.go index 9e551d4d..2e53d795 100644 --- a/pkg/routingkey/routing_key.go +++ b/pkg/routingkey/routing_key.go @@ -28,7 +28,7 @@ type Creator struct { routingKeyBuffer []byte } -func (rc *Creator) CreateRoutingKey(table *typedef.Table, values []interface{}) ([]byte, error) { +func (rc *Creator) CreateRoutingKey(table *typedef.Table, values []any) ([]byte, error) { partitionKeys := table.PartitionKeys if len(partitionKeys) == 1 { // single column routing key diff --git a/pkg/routingkey/routing_key_test.go b/pkg/routingkey/routing_key_test.go index ecf92aaa..a433815c 100644 --- a/pkg/routingkey/routing_key_test.go +++ b/pkg/routingkey/routing_key_test.go @@ -44,231 +44,231 @@ func TestRoutingKey(t *testing.T) { }, data: []data{ { - values: []interface{}{1641072984}, + values: []any{1641072984}, want: decodeHex("61d0c958"), }, { - values: []interface{}{1904972303}, + values: []any{1904972303}, want: decodeHex("718b920f"), }, { - values: []interface{}{1236194666}, + values: []any{1236194666}, want: decodeHex("49aed56a"), }, { - values: []interface{}{2095188122}, + values: []any{2095188122}, want: decodeHex("7ce2089a"), }, { - values: []interface{}{45882928}, + values: []any{45882928}, want: decodeHex("02bc1e30"), }, { - values: []interface{}{1057932065}, + values: []any{1057932065}, want: decodeHex("3f0ec321"), }, { - values: []interface{}{1236194666}, + values: []any{1236194666}, want: decodeHex("49aed56a"), }, { - values: []interface{}{812457792}, + values: []any{812457792}, want: decodeHex("306d1f40"), }, { - values: []interface{}{1334454052}, + values: []any{1334454052}, want: decodeHex("4f8a2724"), }, { - values: []interface{}{45882928}, + values: []any{45882928}, want: decodeHex("02bc1e30"), }, { - values: []interface{}{1904972303}, + values: []any{1904972303}, want: decodeHex("718b920f"), }, { - values: []interface{}{368842197}, + values: []any{368842197}, want: decodeHex("15fc15d5"), }, { - values: []interface{}{2095188122}, + values: []any{2095188122}, want: decodeHex("7ce2089a"), }, { - values: []interface{}{475379656}, + values: []any{475379656}, want: decodeHex("1c55b7c8"), }, { - values: []interface{}{1641072984}, + values: []any{1641072984}, want: decodeHex("61d0c958"), }, { - values: []interface{}{904957324}, + values: []any{904957324}, want: decodeHex("35f08d8c"), }, { - values: []interface{}{262309475}, + values: []any{262309475}, want: decodeHex("0fa28663"), }, { - values: []interface{}{1227835653}, + values: []any{1227835653}, want: decodeHex("492f4905"), }, { - values: []interface{}{1425448500}, + values: []any{1425448500}, want: decodeHex("54f69e34"), }, { - values: []interface{}{597709428}, + values: []any{597709428}, want: decodeHex("23a05274"), }, { - values: []interface{}{1800248233}, + values: []any{1800248233}, want: decodeHex("6b4d9ba9"), }, { - values: []interface{}{806697938}, + values: []any{806697938}, want: decodeHex("30153bd2"), }, { - values: []interface{}{2086829109}, + values: []any{2086829109}, want: decodeHex("7c627c35"), }, { - values: []interface{}{1630944338}, + values: []any{1630944338}, want: decodeHex("61363c52"), }, { - values: []interface{}{168212700}, + values: []any{168212700}, want: decodeHex("0a06b8dc"), }, { - values: []interface{}{168212700}, + values: []any{168212700}, want: decodeHex("0a06b8dc"), }, { - values: []interface{}{2086829109}, + values: []any{2086829109}, want: decodeHex("7c627c35"), }, { - values: []interface{}{1800248233}, + values: []any{1800248233}, want: decodeHex("6b4d9ba9"), }, { - values: []interface{}{904957324}, + values: []any{904957324}, want: decodeHex("35f08d8c"), }, { - values: []interface{}{806697938}, + values: []any{806697938}, want: decodeHex("30153bd2"), }, { - values: []interface{}{1425448500}, + values: []any{1425448500}, want: decodeHex("54f69e34"), }, { - values: []interface{}{1227835653}, + values: []any{1227835653}, want: decodeHex("492f4905"), }, { - values: []interface{}{597709428}, + values: []any{597709428}, want: decodeHex("23a05274"), }, { - values: []interface{}{1630944338}, + values: []any{1630944338}, want: decodeHex("61363c52"), }, { - values: []interface{}{262309475}, + values: []any{262309475}, want: decodeHex("0fa28663"), }, { - values: []interface{}{1121302931}, + values: []any{1121302931}, want: decodeHex("42d5b993"), }, { - values: []interface{}{1683526033}, + values: []any{1683526033}, want: decodeHex("64589191"), }, { - values: []interface{}{413686973}, + values: []any{413686973}, want: decodeHex("18a85cbd"), }, { - values: []interface{}{1768299632}, + values: []any{1768299632}, want: decodeHex("69661c70"), }, { - values: []interface{}{798338925}, + values: []any{798338925}, want: decodeHex("2f95af6d"), }, { - values: []interface{}{1499238155}, + values: []any{1499238155}, want: decodeHex("595c8f0b"), }, { - values: []interface{}{162452846}, + values: []any{162452846}, want: decodeHex("09aed56e"), }, { - values: []interface{}{995951772}, + values: []any{995951772}, want: decodeHex("3b5d049c"), }, { - values: []interface{}{591949574}, + values: []any{591949574}, want: decodeHex("23486f06"), }, { - values: []interface{}{1980296387}, + values: []any{1980296387}, want: decodeHex("7608ecc3"), }, { - values: []interface{}{1980296387}, + values: []any{1980296387}, want: decodeHex("7608ecc3"), }, { - values: []interface{}{798338925}, + values: []any{798338925}, want: decodeHex("2f95af6d"), }, { - values: []interface{}{1121302931}, + values: []any{1121302931}, want: decodeHex("42d5b993"), }, { - values: []interface{}{1499238155}, + values: []any{1499238155}, want: decodeHex("595c8f0b"), }, { - values: []interface{}{162452846}, + values: []any{162452846}, want: decodeHex("09aed56e"), }, { - values: []interface{}{413686973}, + values: []any{413686973}, want: decodeHex("18a85cbd"), }, { - values: []interface{}{1683526033}, + values: []any{1683526033}, want: decodeHex("64589191"), }, { - values: []interface{}{1768299632}, + values: []any{1768299632}, want: decodeHex("69661c70"), }, { - values: []interface{}{995951772}, + values: []any{995951772}, want: decodeHex("3b5d049c"), }, { - values: []interface{}{591949574}, + values: []any{591949574}, want: decodeHex("23486f06"), }, { - values: []interface{}{1417141266}, + values: []any{1417141266}, want: decodeHex("5477dc12"), }, { - values: []interface{}{1417141266}, + values: []any{1417141266}, want: decodeHex("5477dc12"), }, }, @@ -280,183 +280,183 @@ func TestRoutingKey(t *testing.T) { }, data: []data{ { - values: []interface{}{154109775, 10044141}, + values: []any{154109775, 10044141}, want: decodeHex("0004092f874f000004009942ed00"), }, { - values: []interface{}{1313258788, 1466181868}, + values: []any{1313258788, 1466181868}, want: decodeHex("00044e46bd24000004576428ec00"), }, { - values: []interface{}{287541659, 266079166}, + values: []any{287541659, 266079166}, want: decodeHex("00041123899b0000040fdc0bbe00"), }, { - values: []interface{}{1555318302, 1661168631}, + values: []any{1555318302, 1661168631}, want: decodeHex("00045cb4461e00000463036bf700"), }, { - values: []interface{}{441838458, 453773327}, + values: []any{441838458, 453773327}, want: decodeHex("00041a55eb7a0000041b0c080f00"), }, { - values: []interface{}{876168687, 910346726}, + values: []any{876168687, 910346726}, want: decodeHex("0004343945ef0000043642c9e600"), }, { - values: []interface{}{682056909, 682069788}, + values: []any{682056909, 682069788}, want: decodeHex("000428a75ccd00000428a78f1c00"), }, { - values: []interface{}{1099404621, 1260277606}, + values: []any{1099404621, 1260277606}, want: decodeHex("00044187954d0000044b1e4f6600"), }, { - values: []interface{}{48146003, 72800984}, + values: []any{48146003, 72800984}, want: decodeHex("000402dea6530000040456dad800"), }, { - values: []interface{}{1045015705, 1017672610}, + values: []any{1045015705, 1017672610}, want: decodeHex("00043e49ac990000043ca873a200"), }, { - values: []interface{}{1338382691, 1378061000}, + values: []any{1338382691, 1378061000}, want: decodeHex("00044fc6196300000452238ac800"), }, { - values: []interface{}{441838458, 453773327}, + values: []any{441838458, 453773327}, want: decodeHex("00041a55eb7a0000041b0c080f00"), }, { - values: []interface{}{1555318302, 1661168631}, + values: []any{1555318302, 1661168631}, want: decodeHex("00045cb4461e00000463036bf700"), }, { - values: []interface{}{287541659, 266079166}, + values: []any{287541659, 266079166}, want: decodeHex("00041123899b0000040fdc0bbe00"), }, { - values: []interface{}{1085821086, 1230891834}, + values: []any{1085821086, 1230891834}, want: decodeHex("000440b8509e000004495deb3a00"), }, { - values: []interface{}{2118757525, 2091414430}, + values: []any{2118757525, 2091414430}, want: decodeHex("00047e49ac950000047ca8739e00"), }, { - values: []interface{}{723092642, 797106325}, + values: []any{723092642, 797106325}, want: decodeHex("00042b1984a20000042f82e09500"), }, { - values: []interface{}{1900826555, 1739648564}, + values: []any{1900826555, 1739648564}, want: decodeHex("0004714c4fbb00000467b0ee3400"), }, { - values: []interface{}{48146003, 72800984}, + values: []any{48146003, 72800984}, want: decodeHex("000402dea6530000040456dad800"), }, { - values: []interface{}{1338382691, 1378061000}, + values: []any{1338382691, 1378061000}, want: decodeHex("00044fc6196300000452238ac800"), }, { - values: []interface{}{1045015705, 1017672610}, + values: []any{1045015705, 1017672610}, want: decodeHex("00043e49ac990000043ca873a200"), }, { - values: []interface{}{290624561, 281368602}, + values: []any{290624561, 281368602}, want: decodeHex("00041152943100000410c5581a00"), }, { - values: []interface{}{1628942696, 1544546792}, + values: []any{1628942696, 1544546792}, want: decodeHex("00046117b1680000045c0fe9e800"), }, { - values: []interface{}{439094547, 457987688}, + values: []any{439094547, 457987688}, want: decodeHex("00041a2c0d130000041b4c566800"), }, { - values: []interface{}{1085821086, 1230891834}, + values: []any{1085821086, 1230891834}, want: decodeHex("000440b8509e000004495deb3a00"), }, { - values: []interface{}{2118757525, 2091414430}, + values: []any{2118757525, 2091414430}, want: decodeHex("00047e49ac950000047ca8739e00"), }, { - values: []interface{}{55214822, 972879}, + values: []any{55214822, 972879}, want: decodeHex("0004034a82e6000004000ed84f00"), }, { - values: []interface{}{723092642, 797106325}, + values: []any{723092642, 797106325}, want: decodeHex("00042b1984a20000042f82e09500"), }, { - values: []interface{}{1900826555, 1739648564}, + values: []any{1900826555, 1739648564}, want: decodeHex("0004714c4fbb00000467b0ee3400"), }, { - values: []interface{}{1307654654, 1374426858}, + values: []any{1307654654, 1374426858}, want: decodeHex("00044df139fe00000451ec16ea00"), }, { - values: []interface{}{958724071, 967981814}, + values: []any{958724071, 967981814}, want: decodeHex("00043924f7e700000439b23af600"), }, { - values: []interface{}{290624561, 281368602}, + values: []any{290624561, 281368602}, want: decodeHex("00041152943100000410c5581a00"), }, { - values: []interface{}{1628942696, 1544546792}, + values: []any{1628942696, 1544546792}, want: decodeHex("00046117b1680000045c0fe9e800"), }, { - values: []interface{}{439094547, 457987688}, + values: []any{439094547, 457987688}, want: decodeHex("00041a2c0d130000041b4c566800"), }, { - values: []interface{}{691470817, 838419659}, + values: []any{691470817, 838419659}, want: decodeHex("0004293701e100000431f944cb00"), }, { - values: []interface{}{2032465891, 2041723634}, + values: []any{2032465891, 2041723634}, want: decodeHex("00047924f7e300000479b23af200"), }, { - values: []interface{}{1724551686, 1929537609}, + values: []any{1724551686, 1929537609}, want: decodeHex("000466ca92060000047302684900"), }, { - values: []interface{}{958724071, 967981814}, + values: []any{958724071, 967981814}, want: decodeHex("00043924f7e700000439b23af600"), }, { - values: []interface{}{1307654654, 1374426858}, + values: []any{1307654654, 1374426858}, want: decodeHex("00044df139fe00000451ec16ea00"), }, { - values: []interface{}{2032465891, 2041723634}, + values: []any{2032465891, 2041723634}, want: decodeHex("00047924f7e300000479b23af200"), }, { - values: []interface{}{691470817, 838419659}, + values: []any{691470817, 838419659}, want: decodeHex("0004293701e100000431f944cb00"), }, { - values: []interface{}{1724551686, 1929537609}, + values: []any{1724551686, 1929537609}, want: decodeHex("000466ca92060000047302684900"), }, { - values: []interface{}{55214822, 972879}, + values: []any{55214822, 972879}, want: decodeHex("0004034a82e6000004000ed84f00"), }, { - values: []interface{}{1207341986, 1257554950}, + values: []any{1207341986, 1257554950}, want: decodeHex("000447f693a20000044af4c40600"), }, { - values: []interface{}{1207341986, 1257554950}, + values: []any{1207341986, 1257554950}, want: decodeHex("000447f693a20000044af4c40600"), }, }, diff --git a/pkg/status/status.go b/pkg/status/status.go index fc178aa5..cbaf1c9d 100644 --- a/pkg/status/status.go +++ b/pkg/status/status.go @@ -57,7 +57,7 @@ func (gs *GlobalStatus) AddReadError(err *joberror.JobError) { } func (gs *GlobalStatus) PrintResultAsJSON(w io.Writer, schema *typedef.Schema, version string) error { - result := map[string]interface{}{ + result := map[string]any{ "result": gs, "gemini_version": version, "schemaHash": schema.GetHash(), diff --git a/pkg/status/status_test.go b/pkg/status/status_test.go index f4b78153..8b4cd28c 100644 --- a/pkg/status/status_test.go +++ b/pkg/status/status_test.go @@ -34,7 +34,7 @@ func TestSerialization(t *testing.T) { st.WriteOps.Store(10) st.ReadOps.Store(5) - baseDate := time.Date(2020, 02, 01, 0, 0, 0, 0, time.UTC) + baseDate := time.Date(2020, 0o2, 0o1, 0, 0, 0, 0, time.UTC) for y := 0; y < 5; y++ { st.AddReadError(&joberror.JobError{ Timestamp: baseDate.AddDate(0, 0, y), @@ -44,7 +44,7 @@ func TestSerialization(t *testing.T) { }) } - baseDate = time.Date(2020, 03, 01, 0, 0, 0, 0, time.UTC) + baseDate = time.Date(2020, 0o3, 0o1, 0, 0, 0, 0, time.UTC) for y := 0; y < 5; y++ { st.AddWriteError(&joberror.JobError{ Timestamp: baseDate.AddDate(0, 0, y), diff --git a/pkg/stmtlogger/filelogger.go b/pkg/stmtlogger/filelogger.go index b6bc1526..d2217670 100644 --- a/pkg/stmtlogger/filelogger.go +++ b/pkg/stmtlogger/filelogger.go @@ -124,7 +124,7 @@ func NewFileLogger(filename string) (StmtToFile, error) { if filename == "" { return &nopFileLogger{}, nil } - fd, err := os.OpenFile(filename, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644) + fd, err := os.OpenFile(filename, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0o644) if err != nil { return nil, err } diff --git a/pkg/store/cqlstore.go b/pkg/store/cqlstore.go index 33707417..60448c4d 100644 --- a/pkg/store/cqlstore.go +++ b/pkg/store/cqlstore.go @@ -93,7 +93,7 @@ func (cs *cqlStore) doMutate(ctx context.Context, stmt *typedef.Stmt, ts time.Ti return nil } -func (cs *cqlStore) load(ctx context.Context, stmt *typedef.Stmt) (result []map[string]interface{}, err error) { +func (cs *cqlStore) load(ctx context.Context, stmt *typedef.Stmt) (result []map[string]any, err error) { query, _ := stmt.Query.ToCql() cs.stmtLogger.LogStmt(stmt) iter := cs.session.Query(query, stmt.Values...).WithContext(ctx).Iter() diff --git a/pkg/store/helpers.go b/pkg/store/helpers.go index c95546d5..6758851e 100644 --- a/pkg/store/helpers.go +++ b/pkg/store/helpers.go @@ -25,7 +25,7 @@ import ( "github.com/scylladb/gemini/pkg/typedef" ) -func pks(t *typedef.Table, rows []map[string]interface{}) []string { +func pks(t *typedef.Table, rows []map[string]any) []string { var keySet []string for _, row := range rows { keys := make([]string, 0, len(t.PartitionKeys)+len(t.ClusteringKeys)) @@ -36,14 +36,14 @@ func pks(t *typedef.Table, rows []map[string]interface{}) []string { return keySet } -func extractRowValues(values []string, columns typedef.Columns, row map[string]interface{}) []string { +func extractRowValues(values []string, columns typedef.Columns, row map[string]any) []string { for _, pk := range columns { values = append(values, fmt.Sprintf(pk.Name+"=%v", row[pk.Name])) } return values } -func lt(mi, mj map[string]interface{}) bool { +func lt(mi, mj map[string]any) bool { switch mis := mi["pk0"].(type) { case []byte: mjs, _ := mj["pk0"].([]byte) @@ -84,10 +84,10 @@ func lt(mi, mj map[string]interface{}) bool { } } -func loadSet(iter *gocql.Iter) []map[string]interface{} { - var rows []map[string]interface{} +func loadSet(iter *gocql.Iter) []map[string]any { + var rows []map[string]any for { - row := make(map[string]interface{}) + row := make(map[string]any) if !iter.MapScan(row) { break } diff --git a/pkg/store/store.go b/pkg/store/store.go index 0d72e2cf..51095b2d 100644 --- a/pkg/store/store.go +++ b/pkg/store/store.go @@ -42,7 +42,7 @@ import ( ) type loader interface { - load(context.Context, *typedef.Stmt) ([]map[string]interface{}, error) + load(context.Context, *typedef.Stmt) ([]map[string]any, error) } type storer interface { @@ -107,7 +107,7 @@ func (n *noOpStore) mutate(context.Context, *typedef.Stmt) error { return nil } -func (n *noOpStore) load(context.Context, *typedef.Stmt) ([]map[string]interface{}, error) { +func (n *noOpStore) load(context.Context, *typedef.Stmt) ([]map[string]any, error) { return nil, nil } @@ -178,7 +178,7 @@ func mutate(ctx context.Context, s storeLoader, stmt *typedef.Stmt) error { } func (ds delegatingStore) Check(ctx context.Context, table *typedef.Table, stmt *typedef.Stmt, detailedDiff bool) error { - var testRows, oracleRows []map[string]interface{} + var testRows, oracleRows []map[string]any var testErr, oracleErr error var wg sync.WaitGroup wg.Add(1) diff --git a/pkg/tableopts/options.go b/pkg/tableopts/options.go index 7b02cedc..8b3bd0b5 100644 --- a/pkg/tableopts/options.go +++ b/pkg/tableopts/options.go @@ -35,7 +35,7 @@ func (o *SimpleOption) ToCQL() string { } type MapOption struct { - val map[string]interface{} + val map[string]any key string } diff --git a/pkg/testutils/expected_store.go b/pkg/testutils/expected_store.go index 056fe234..d58a9268 100644 --- a/pkg/testutils/expected_store.go +++ b/pkg/testutils/expected_store.go @@ -93,7 +93,7 @@ func (f *ExpectedStore[T]) UpdateExpected(t *testing.T) { if err != nil { t.Fatalf("Marshal funcStmtTests error:%v", err) } - err = os.WriteFile(f.filePath, data, 0644) + err = os.WriteFile(f.filePath, data, 0o644) if err != nil { t.Fatalf("write to file %s error:%v", f.filePath, err) } diff --git a/pkg/testutils/mock_generator.go b/pkg/testutils/mock_generator.go index 2a0575a0..eb6c0184 100644 --- a/pkg/testutils/mock_generator.go +++ b/pkg/testutils/mock_generator.go @@ -64,8 +64,8 @@ func (g *MockGenerator) GiveOlds(_ []*typedef.ValueWithToken) {} func (g *MockGenerator) ReleaseToken(_ uint64) { } -func (g *MockGenerator) createPartitionKeyValues(r *rand.Rand) []interface{} { - var values []interface{} +func (g *MockGenerator) createPartitionKeyValues(r *rand.Rand) []any { + var values []any for _, pk := range g.table.PartitionKeys { values = append(values, pk.Type.GenValue(r, g.partitionsConfig)...) } diff --git a/pkg/typedef/bag.go b/pkg/typedef/bag.go index 32f32d5d..51a9d619 100644 --- a/pkg/typedef/bag.go +++ b/pkg/typedef/bag.go @@ -59,7 +59,7 @@ func (ct *BagType) CQLHolder() string { return "?" } -func (ct *BagType) CQLPretty(value interface{}) string { +func (ct *BagType) CQLPretty(value any) string { if reflect.TypeOf(value).Kind() != reflect.Slice { panic(fmt.Sprintf("set cql pretty, unknown type %v", ct)) } @@ -75,18 +75,18 @@ func (ct *BagType) CQLPretty(value interface{}) string { return fmt.Sprintf(format, strings.Join(out, ",")) } -func (ct *BagType) GenValue(r *rand.Rand, p *PartitionRangeConfig) []interface{} { +func (ct *BagType) GenValue(r *rand.Rand, p *PartitionRangeConfig) []any { count := utils.RandInt2(r, 1, maxBagSize+1) - out := make([]interface{}, count) + out := make([]any, count) for i := 0; i < count; i++ { out[i] = ct.ValueType.GenValue(r, p)[0] } - return []interface{}{out} + return []any{out} } -func (ct *BagType) GenJSONValue(r *rand.Rand, p *PartitionRangeConfig) interface{} { +func (ct *BagType) GenJSONValue(r *rand.Rand, p *PartitionRangeConfig) any { count := utils.RandInt2(r, 1, maxBagSize+1) - out := make([]interface{}, count) + out := make([]any, count) for i := 0; i < count; i++ { out[i] = ct.ValueType.GenJSONValue(r, p) } diff --git a/pkg/typedef/columns.go b/pkg/typedef/columns.go index 34f1da16..c77bcac6 100644 --- a/pkg/typedef/columns.go +++ b/pkg/typedef/columns.go @@ -39,7 +39,7 @@ func (cd *ColumnDef) IsValidForPrimaryKey() bool { } func (cd *ColumnDef) UnmarshalJSON(data []byte) error { - dataMap := make(map[string]interface{}) + dataMap := make(map[string]any) if err := json.Unmarshal(data, &dataMap); err != nil { return err } @@ -49,7 +49,7 @@ func (cd *ColumnDef) UnmarshalJSON(data []byte) error { if !typeOk { return errors.Wrapf(ErrSchemaValidation, "missing definition of column 'type': [%T]%+[1]v", dataMap) } - complexTypeMap, typeMapOk := typeMap.(map[string]interface{}) + complexTypeMap, typeMapOk := typeMap.(map[string]any) if !typeMapOk { return errors.Wrapf(ErrSchemaValidation, "unknown definition column 'type': [%T]%+[1]v", typeMap) } @@ -107,7 +107,7 @@ func (c Columns) Remove(column *ColumnDef) Columns { return out } -func (c Columns) ToJSONMap(values map[string]interface{}, r *rand.Rand, p *PartitionRangeConfig) map[string]interface{} { +func (c Columns) ToJSONMap(values map[string]any, r *rand.Rand, p *PartitionRangeConfig) map[string]any { for _, k := range c { values[k.Name] = k.Type.GenJSONValue(r, p) } @@ -155,9 +155,9 @@ func (c Columns) ValueVariationsNumber(p *PartitionRangeConfig) float64 { return out } -func GetMapTypeColumn(data map[string]interface{}) (out *ColumnDef, err error) { +func GetMapTypeColumn(data map[string]any) (out *ColumnDef, err error) { st := struct { - Type map[string]interface{} + Type map[string]any Name string }{} @@ -200,9 +200,9 @@ func GetMapTypeColumn(data map[string]interface{}) (out *ColumnDef, err error) { }, err } -func GetBagTypeColumn(data map[string]interface{}) (out *ColumnDef, err error) { +func GetBagTypeColumn(data map[string]any) (out *ColumnDef, err error) { st := struct { - Type map[string]interface{} + Type map[string]any Name string }{} @@ -231,9 +231,9 @@ func GetBagTypeColumn(data map[string]interface{}) (out *ColumnDef, err error) { }, err } -func GetTupleTypeColumn(data map[string]interface{}) (out *ColumnDef, err error) { +func GetTupleTypeColumn(data map[string]any) (out *ColumnDef, err error) { st := struct { - Type map[string]interface{} + Type map[string]any Name string }{} @@ -263,9 +263,9 @@ func GetTupleTypeColumn(data map[string]interface{}) (out *ColumnDef, err error) }, nil } -func GetUDTTypeColumn(data map[string]interface{}) (out *ColumnDef, err error) { +func GetUDTTypeColumn(data map[string]any) (out *ColumnDef, err error) { st := struct { - Type map[string]interface{} + Type map[string]any Name string }{} @@ -303,7 +303,7 @@ func GetUDTTypeColumn(data map[string]interface{}) (out *ColumnDef, err error) { }, nil } -func GetSimpleTypeColumn(data map[string]interface{}) (*ColumnDef, error) { +func GetSimpleTypeColumn(data map[string]any) (*ColumnDef, error) { st := struct { Name string Type SimpleType diff --git a/pkg/typedef/simple_type.go b/pkg/typedef/simple_type.go index aa86191f..ecd0ad98 100644 --- a/pkg/typedef/simple_type.go +++ b/pkg/typedef/simple_type.go @@ -66,7 +66,7 @@ func (st SimpleType) LenValue() int { return 1 } -func (st SimpleType) CQLPretty(value interface{}) string { +func (st SimpleType) CQLPretty(value any) string { switch st { case TYPE_ASCII, TYPE_TEXT, TYPE_VARCHAR, TYPE_INET, TYPE_DATE: return fmt.Sprintf("'%s'", value) @@ -165,7 +165,7 @@ func (st SimpleType) Indexable() bool { return st != TYPE_DURATION } -func (st SimpleType) GenJSONValue(r *rand.Rand, p *PartitionRangeConfig) interface{} { +func (st SimpleType) GenJSONValue(r *rand.Rand, p *PartitionRangeConfig) any { switch st { case TYPE_BLOB: ln := r.Intn(p.MaxBlobLength) + p.MinBlobLength @@ -176,11 +176,11 @@ func (st SimpleType) GenJSONValue(r *rand.Rand, p *PartitionRangeConfig) interfa return st.genValue(r, p) } -func (st SimpleType) GenValue(r *rand.Rand, p *PartitionRangeConfig) []interface{} { - return []interface{}{st.genValue(r, p)} +func (st SimpleType) GenValue(r *rand.Rand, p *PartitionRangeConfig) []any { + return []any{st.genValue(r, p)} } -func (st SimpleType) genValue(r *rand.Rand, p *PartitionRangeConfig) interface{} { +func (st SimpleType) genValue(r *rand.Rand, p *PartitionRangeConfig) any { switch st { case TYPE_ASCII, TYPE_TEXT, TYPE_VARCHAR: ln := r.Intn(p.MaxStringLength) + p.MinStringLength diff --git a/pkg/typedef/tuple.go b/pkg/typedef/tuple.go index 3a61f2e7..6c720b08 100644 --- a/pkg/typedef/tuple.go +++ b/pkg/typedef/tuple.go @@ -55,8 +55,8 @@ func (t *TupleType) CQLHolder() string { return "(" + strings.TrimRight(strings.Repeat("?,", len(t.ValueTypes)), ",") + ")" } -func (t *TupleType) CQLPretty(value interface{}) string { - values, ok := value.([]interface{}) +func (t *TupleType) CQLPretty(value any) string { + values, ok := value.([]any) if !ok { return "()" } @@ -76,16 +76,16 @@ func (t *TupleType) Indexable() bool { return true } -func (t *TupleType) GenJSONValue(r *rand.Rand, p *PartitionRangeConfig) interface{} { - out := make([]interface{}, 0, len(t.ValueTypes)) +func (t *TupleType) GenJSONValue(r *rand.Rand, p *PartitionRangeConfig) any { + out := make([]any, 0, len(t.ValueTypes)) for _, tp := range t.ValueTypes { out = append(out, tp.GenJSONValue(r, p)) } return out } -func (t *TupleType) GenValue(r *rand.Rand, p *PartitionRangeConfig) []interface{} { - out := make([]interface{}, 0, len(t.ValueTypes)) +func (t *TupleType) GenValue(r *rand.Rand, p *PartitionRangeConfig) []any { + out := make([]any, 0, len(t.ValueTypes)) for _, tp := range t.ValueTypes { out = append(out, tp.GenValue(r, p)...) } diff --git a/pkg/typedef/typedef.go b/pkg/typedef/typedef.go index d1db6598..6176e3b4 100644 --- a/pkg/typedef/typedef.go +++ b/pkg/typedef/typedef.go @@ -199,7 +199,7 @@ const ( CacheArrayLen ) -func splitString(str string, delimiter string) func(func(int, string) bool) { +func splitString(str, delimiter string) func(func(int, string) bool) { lastPos := 0 delLen := len(delimiter) return func(yield func(int, string) bool) { diff --git a/pkg/typedef/types.go b/pkg/typedef/types.go index e311d42f..8854613b 100644 --- a/pkg/typedef/types.go +++ b/pkg/typedef/types.go @@ -140,7 +140,7 @@ func (mt *MapType) CQLHolder() string { return "?" } -func (mt *MapType) CQLPretty(value interface{}) string { +func (mt *MapType) CQLPretty(value any) string { if reflect.TypeOf(value).Kind() != reflect.Map { panic(fmt.Sprintf("map cql pretty, unknown type %v", mt)) } @@ -155,7 +155,7 @@ func (mt *MapType) CQLPretty(value interface{}) string { return fmt.Sprintf("{%s}", strings.Join(out, ",")) } -func (mt *MapType) GenJSONValue(r *rand.Rand, p *PartitionRangeConfig) interface{} { +func (mt *MapType) GenJSONValue(r *rand.Rand, p *PartitionRangeConfig) any { count := r.Intn(9) + 1 vals := reflect.MakeMap(reflect.MapOf(reflect.TypeOf(mt.KeyType.GenJSONValue(r, p)), reflect.TypeOf(mt.ValueType.GenJSONValue(r, p)))) for i := 0; i < count; i++ { @@ -164,13 +164,13 @@ func (mt *MapType) GenJSONValue(r *rand.Rand, p *PartitionRangeConfig) interface return vals.Interface() } -func (mt *MapType) GenValue(r *rand.Rand, p *PartitionRangeConfig) []interface{} { +func (mt *MapType) GenValue(r *rand.Rand, p *PartitionRangeConfig) []any { count := utils.RandInt2(r, 1, maxMapSize+1) vals := reflect.MakeMap(reflect.MapOf(reflect.TypeOf(mt.KeyType.GenValue(r, p)[0]), reflect.TypeOf(mt.ValueType.GenValue(r, p)[0]))) for i := 0; i < count; i++ { vals.SetMapIndex(reflect.ValueOf(mt.KeyType.GenValue(r, p)[0]), reflect.ValueOf(mt.ValueType.GenValue(r, p)[0])) } - return []interface{}{vals.Interface()} + return []any{vals.Interface()} } func (mt *MapType) LenValue() int { @@ -209,22 +209,22 @@ func (ct *CounterType) CQLHolder() string { return "?" } -func (ct *CounterType) CQLPretty(value interface{}) string { +func (ct *CounterType) CQLPretty(value any) string { return fmt.Sprintf("%d", value) } -func (ct *CounterType) GenJSONValue(r *rand.Rand, _ *PartitionRangeConfig) interface{} { +func (ct *CounterType) GenJSONValue(r *rand.Rand, _ *PartitionRangeConfig) any { if utils.UnderTest { return r.Int63() } return atomic.AddInt64(&ct.Value, 1) } -func (ct *CounterType) GenValue(r *rand.Rand, _ *PartitionRangeConfig) []interface{} { +func (ct *CounterType) GenValue(r *rand.Rand, _ *PartitionRangeConfig) []any { if utils.UnderTest { - return []interface{}{r.Int63()} + return []any{r.Int63()} } - return []interface{}{atomic.AddInt64(&ct.Value, 1)} + return []any{atomic.AddInt64(&ct.Value, 1)} } func (ct *CounterType) LenValue() int { diff --git a/pkg/typedef/udt.go b/pkg/typedef/udt.go index 447f4475..d8899e49 100644 --- a/pkg/typedef/udt.go +++ b/pkg/typedef/udt.go @@ -48,8 +48,8 @@ func (t *UDTType) CQLHolder() string { return "?" } -func (t *UDTType) CQLPretty(value interface{}) string { - s, ok := value.(map[string]interface{}) +func (t *UDTType) CQLPretty(value any) string { + s, ok := value.(map[string]any) if !ok { panic(fmt.Sprintf("udt pretty, unknown type %v", t)) } @@ -74,20 +74,20 @@ func (t *UDTType) Indexable() bool { return true } -func (t *UDTType) GenJSONValue(r *rand.Rand, p *PartitionRangeConfig) interface{} { - vals := make(map[string]interface{}) +func (t *UDTType) GenJSONValue(r *rand.Rand, p *PartitionRangeConfig) any { + vals := make(map[string]any) for name, typ := range t.ValueTypes { vals[name] = typ.GenJSONValue(r, p) } return vals } -func (t *UDTType) GenValue(r *rand.Rand, p *PartitionRangeConfig) []interface{} { - vals := make(map[string]interface{}) +func (t *UDTType) GenValue(r *rand.Rand, p *PartitionRangeConfig) []any { + vals := make(map[string]any) for name, typ := range t.ValueTypes { vals[name] = typ.GenValue(r, p)[0] } - return []interface{}{vals} + return []any{vals} } func (t *UDTType) LenValue() int {