From 6700ff3a9d5e1bb88c31bf3a2f9475b3932b23e6 Mon Sep 17 00:00:00 2001 From: kpango Date: Mon, 26 Dec 2022 15:33:44 +0900 Subject: [PATCH] add canceled status for CreateIndex api Signed-off-by: kpango --- Makefile | 20 + Makefile.d/test.mk | 38 +- apis/docs/v1/docs.md | 610 ++--- apis/grpc/v1/agent/core/agent.pb.go | 2 +- apis/grpc/v1/agent/sidecar/sidecar.pb.go | 2 +- apis/grpc/v1/discoverer/discoverer.pb.go | 2 +- .../grpc/v1/filter/egress/egress_filter.pb.go | 2 +- .../v1/filter/ingress/ingress_filter.pb.go | 2 +- .../grpc/v1/manager/index/index_manager.pb.go | 2 +- apis/grpc/v1/payload/payload.pb.go | 2 +- apis/grpc/v1/vald/filter.pb.go | 2 +- apis/grpc/v1/vald/insert.pb.go | 2 +- apis/grpc/v1/vald/object.pb.go | 2 +- apis/grpc/v1/vald/remove.pb.go | 2 +- apis/grpc/v1/vald/search.pb.go | 2 +- apis/grpc/v1/vald/update.pb.go | 2 +- apis/grpc/v1/vald/upsert.pb.go | 2 +- dockers/agent/core/ngt/Dockerfile | 11 +- dockers/ci/base/Dockerfile | 3 + dockers/dev/Dockerfile | 9 +- example/client/go.mod | 8 +- example/client/go.sum | 8 +- go.mod | 42 +- go.sum | 54 +- internal/config/compress_test.go | 76 + internal/errors/redis_test.go | 88 + internal/file/file_test.go | 94 + .../exporter/otlp/option_test.go | 1061 ++++++++ internal/observability/exporter/otlp/otlp.go | 11 +- .../observability/exporter/otlp/otlp_test.go | 719 ++++++ internal/test/data/vector/gen.go | 25 +- internal/test/data/vector/gen_test.go | 88 + .../core/ngt/handler/grpc/handler_test.go | 24 +- pkg/agent/core/ngt/handler/grpc/index.go | 85 +- .../core/ngt/handler/grpc/object_test.go | 11 +- .../core/ngt/handler/grpc/remove_test.go | 11 +- .../core/ngt/handler/grpc/search_test.go | 58 +- .../core/ngt/handler/grpc/update_test.go | 12 +- .../core/ngt/handler/grpc/upsert_test.go | 12 +- pkg/agent/core/ngt/service/ngt.go | 50 +- pkg/agent/core/ngt/service/ngt_test.go | 1343 ++++++++-- .../{uninserted_index_map.go => indexmap.go} | 107 +- ...ted_index_map_test.go => indexmap_test.go} | 444 +++- pkg/agent/core/ngt/service/vqueue/option.go | 47 +- .../core/ngt/service/vqueue/option_test.go | 412 --- pkg/agent/core/ngt/service/vqueue/queue.go | 262 +- .../core/ngt/service/vqueue/queue_test.go | 2212 ++++------------- .../ngt/service/vqueue/undeleted_index_map.go | 274 -- .../vqueue/undeleted_index_map_test.go | 1395 ----------- versions/NGT_VERSION | 2 +- 50 files changed, 4806 insertions(+), 4948 deletions(-) create mode 100644 internal/observability/exporter/otlp/option_test.go create mode 100644 internal/observability/exporter/otlp/otlp_test.go rename pkg/agent/core/ngt/service/vqueue/{uninserted_index_map.go => indexmap.go} (59%) rename pkg/agent/core/ngt/service/vqueue/{uninserted_index_map_test.go => indexmap_test.go} (71%) delete mode 100644 pkg/agent/core/ngt/service/vqueue/option_test.go delete mode 100644 pkg/agent/core/ngt/service/vqueue/undeleted_index_map.go delete mode 100644 pkg/agent/core/ngt/service/vqueue/undeleted_index_map_test.go diff --git a/Makefile b/Makefile index 18544af19e..3c24c6c0f2 100644 --- a/Makefile +++ b/Makefile @@ -46,6 +46,7 @@ GOBIN := $(eval GOBIN := $(shell go env GOBIN))$(GOBIN) GOCACHE := $(eval GOCACHE := $(shell go env GOCACHE))$(GOCACHE) GOOS := $(eval GOOS := $(shell go env GOOS))$(GOOS) GOPATH := $(eval GOPATH := $(shell go env GOPATH))$(GOPATH) +GOTEST_TIMEOUT = 30m TEMP_DIR := $(eval TEMP_DIR := $(shell mktemp -d))$(TEMP_DIR) @@ -376,6 +377,8 @@ update: \ format: \ license \ format/go \ + format/json \ + format/md \ format/yaml .PHONY: format/go @@ -399,6 +402,23 @@ format/yaml: \ "cmd/**/*.yaml" \ "k8s/**/*.yaml" +.PHONY: format/md +format/md: \ + prettier/install + prettier --write \ + "charts/**/*.md" \ + "apis/**/*.md" \ + "tests/**/*.md" \ + "./*.md" + +.PHONY: format/json +format/json: \ + prettier/install + prettier --write \ + "apis/**/*.json" \ + "charts/**/*.json" \ + "hack/**/*.json" + .PHONY: deps ## resolve dependencies deps: \ diff --git a/Makefile.d/test.mk b/Makefile.d/test.mk index d09cc71d73..a16cb5fd60 100644 --- a/Makefile.d/test.mk +++ b/Makefile.d/test.mk @@ -42,7 +42,7 @@ $(GOPATH)bin/gotests: ## run tests for cmd, internal, pkg test: - go test -shuffle=on -race -mod=readonly -cover -timeout=30m ./cmd/... ./internal/... ./pkg/... + go test -short -shuffle=on -race -mod=readonly -cover -timeout=$(GOTEST_TIMEOUT) ./cmd/... ./internal/... ./pkg/... .PHONY: test/tparse ## run tests for cmd, internal, pkg and show table @@ -50,7 +50,7 @@ test/tparse: \ tparse/install set -euo pipefail rm -rf "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" - go test -shuffle=on -race -mod=readonly -json -cover -timeout=30m ./cmd/... ./internal/... ./pkg/... \ + go test -short -shuffle=on -race -mod=readonly -json -cover -timeout=$(GOTEST_TIMEOUT) ./cmd/... ./internal/... ./pkg/... \ | tee "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" \ | tparse -pass -notests @@ -60,7 +60,7 @@ test/cmd/tparse: \ tparse/install set -euo pipefail rm -rf "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" - go test -shuffle=on -race -mod=readonly -json -cover -timeout=30m ./cmd/... \ + go test -short -shuffle=on -race -mod=readonly -json -cover -timeout=$(GOTEST_TIMEOUT) ./cmd/... \ | tee "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" \ | tparse -pass -notests @@ -70,7 +70,7 @@ test/internal/tparse: \ tparse/install set -euo pipefail rm -rf "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" - go test -shuffle=on -race -mod=readonly -json -cover -timeout=30m ./internal/... \ + go test -short -shuffle=on -race -mod=readonly -json -cover -timeout=$(GOTEST_TIMEOUT) ./internal/... \ | tee "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" \ | tparse -pass -notests @@ -80,7 +80,7 @@ test/pkg/tparse: \ tparse/install set -euo pipefail rm -rf "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" - go test -shuffle=on -race -mod=readonly -json -cover -timeout=30m ./pkg/... \ + go test -short -shuffle=on -race -mod=readonly -json -cover -timeout=$(GOTEST_TIMEOUT) ./pkg/... \ | tee "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" \ | tparse -pass -notests @@ -90,7 +90,7 @@ test/hack/tparse: \ tparse/install set -euo pipefail rm -rf "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" - go test -shuffle=on -race -mod=readonly -json -cover \ + go test -short -shuffle=on -race -mod=readonly -json -cover \ ./hack/gorules/... \ ./hack/helm/... \ ./hack/license/... \ @@ -104,7 +104,7 @@ test/all/tparse: \ tparse/install set -euo pipefail rm -rf "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" - go test -shuffle=on -race -mod=readonly -json -cover -timeout=30m ./... \ + go test -short -shuffle=on -race -mod=readonly -json -cover -timeout=$(GOTEST_TIMEOUT) ./... \ | tee "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" \ | tparse -pass -notests @@ -114,7 +114,7 @@ test/gotestfmt: \ gotestfmt/install set -euo pipefail rm -rf "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" - go test -shuffle=on -race -mod=readonly -json -cover -timeout=30m ./cmd/... ./internal/... ./pkg/... \ + go test -short -shuffle=on -race -mod=readonly -json -cover -timeout=$(GOTEST_TIMEOUT) ./cmd/... ./internal/... ./pkg/... \ | tee "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" \ | gotestfmt -showteststatus @@ -124,7 +124,7 @@ test/cmd/gotestfmt: \ gotestfmt/install set -euo pipefail rm -rf "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" - go test -shuffle=on -race -mod=readonly -json -cover -timeout=30m ./cmd/... \ + go test -short -shuffle=on -race -mod=readonly -json -cover -timeout=$(GOTEST_TIMEOUT) ./cmd/... \ | tee "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" \ | gotestfmt -showteststatus @@ -134,7 +134,7 @@ test/internal/gotestfmt: \ gotestfmt/install set -euo pipefail rm -rf "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" - go test -shuffle=on -race -mod=readonly -json -cover -timeout=30m ./internal/... \ + go test -short -shuffle=on -race -mod=readonly -json -cover -timeout=$(GOTEST_TIMEOUT) ./internal/... \ | tee "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" \ | gotestfmt -showteststatus @@ -144,7 +144,7 @@ test/pkg/gotestfmt: \ gotestfmt/install set -euo pipefail rm -rf "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" - go test -shuffle=on -race -mod=readonly -json -cover -timeout=30m ./pkg/... \ + go test -short -shuffle=on -race -mod=readonly -json -cover -timeout=$(GOTEST_TIMEOUT) ./pkg/... \ | tee "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" \ | gotestfmt -showteststatus @@ -154,7 +154,7 @@ test/hack/gotestfmt: \ gotestfmt/install set -euo pipefail rm -rf "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" - go test -shuffle=on -race -mod=readonly -json -cover \ + go test -short -shuffle=on -race -mod=readonly -json -cover \ ./hack/gorules/... \ ./hack/helm/... \ ./hack/license/... \ @@ -168,29 +168,29 @@ test/all/gotestfmt: \ gotestfmt/install set -euo pipefail rm -rf "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" - go test -shuffle=on -race -mod=readonly -json -cover -timeout=30m ./... \ + go test -short -shuffle=on -race -mod=readonly -json -cover -timeout=$(GOTEST_TIMEOUT) ./... \ | tee "$(TEST_RESULT_DIR)/`echo $@ | sed -e 's%/%-%g'`-result.json" \ | gotestfmt -showteststatus .PHONY: test/pkg ## run tests for pkg test/pkg: - go test -shuffle=on -race -mod=readonly -cover ./pkg/... + go test -short -shuffle=on -race -mod=readonly -cover ./pkg/... .PHONY: test/internal ## run tests for internal test/internal: - go test -shuffle=on -race -mod=readonly -cover ./internal/... + go test -short -shuffle=on -race -mod=readonly -cover ./internal/... .PHONY: test/cmd ## run tests for cmd test/cmd: - go test -shuffle=on -race -mod=readonly -cover ./cmd/... + go test -short -shuffle=on -race -mod=readonly -cover ./cmd/... .PHONY: test/hack ## run tests for hack test/hack: - go test -shuffle=on -race -mod=readonly -cover \ + go test -short -shuffle=on -race -mod=readonly -cover \ ./hack/gorules... \ ./hack/helm/... \ ./hack/license/...\ @@ -199,12 +199,12 @@ test/hack: .PHONY: test/all ## run tests for all Go codes test/all: - go test -shuffle=on -race -mod=readonly -cover ./... + go test -short -shuffle=on -race -mod=readonly -cover ./... .PHONY: coverage ## calculate coverages coverage: - go test -shuffle=on -race -mod=readonly -v -race -covermode=atomic -timeout=30m -coverprofile=coverage.out ./... + go test -short -shuffle=on -race -mod=readonly -v -race -covermode=atomic -timeout=$(GOTEST_TIMEOUT) -coverprofile=coverage.out ./... go tool cover -html=coverage.out -o coverage.html .PHONY: gotests/gen diff --git a/apis/docs/v1/docs.md b/apis/docs/v1/docs.md index 977e18018e..35b72c4be8 100644 --- a/apis/docs/v1/docs.md +++ b/apis/docs/v1/docs.md @@ -4,111 +4,111 @@ ## Table of Contents -- [apis/proto/v1/agent/core/agent.proto](#apis/proto/v1/agent/core/agent.proto) - - [Agent](#core.v1.Agent) -- [apis/proto/v1/agent/sidecar/sidecar.proto](#apis/proto/v1/agent/sidecar/sidecar.proto) - - [Sidecar](#sidecar.v1.Sidecar) -- [apis/proto/v1/discoverer/discoverer.proto](#apis/proto/v1/discoverer/discoverer.proto) - - [Discoverer](#discoverer.v1.Discoverer) -- [apis/proto/v1/filter/egress/egress_filter.proto](#apis/proto/v1/filter/egress/egress_filter.proto) - - [Filter](#filter.egress.v1.Filter) -- [apis/proto/v1/filter/ingress/ingress_filter.proto](#apis/proto/v1/filter/ingress/ingress_filter.proto) - - [Filter](#filter.ingress.v1.Filter) -- [apis/proto/v1/manager/index/index_manager.proto](#apis/proto/v1/manager/index/index_manager.proto) - - [Index](#manager.index.v1.Index) -- [apis/proto/v1/payload/payload.proto](#apis/proto/v1/payload/payload.proto) - - [Control](#payload.v1.Control) - - [Control.CreateIndexRequest](#payload.v1.Control.CreateIndexRequest) - - [Discoverer](#payload.v1.Discoverer) - - [Discoverer.Request](#payload.v1.Discoverer.Request) - - [Empty](#payload.v1.Empty) - - [Filter](#payload.v1.Filter) - - [Filter.Config](#payload.v1.Filter.Config) - - [Filter.Target](#payload.v1.Filter.Target) - - [Info](#payload.v1.Info) - - [Info.CPU](#payload.v1.Info.CPU) - - [Info.IPs](#payload.v1.Info.IPs) - - [Info.Index](#payload.v1.Info.Index) - - [Info.Index.Count](#payload.v1.Info.Index.Count) - - [Info.Index.UUID](#payload.v1.Info.Index.UUID) - - [Info.Index.UUID.Committed](#payload.v1.Info.Index.UUID.Committed) - - [Info.Index.UUID.Uncommitted](#payload.v1.Info.Index.UUID.Uncommitted) - - [Info.Memory](#payload.v1.Info.Memory) - - [Info.Node](#payload.v1.Info.Node) - - [Info.Nodes](#payload.v1.Info.Nodes) - - [Info.Pod](#payload.v1.Info.Pod) - - [Info.Pods](#payload.v1.Info.Pods) - - [Insert](#payload.v1.Insert) - - [Insert.Config](#payload.v1.Insert.Config) - - [Insert.MultiObjectRequest](#payload.v1.Insert.MultiObjectRequest) - - [Insert.MultiRequest](#payload.v1.Insert.MultiRequest) - - [Insert.ObjectRequest](#payload.v1.Insert.ObjectRequest) - - [Insert.Request](#payload.v1.Insert.Request) - - [Object](#payload.v1.Object) - - [Object.Blob](#payload.v1.Object.Blob) - - [Object.Distance](#payload.v1.Object.Distance) - - [Object.ID](#payload.v1.Object.ID) - - [Object.IDs](#payload.v1.Object.IDs) - - [Object.Location](#payload.v1.Object.Location) - - [Object.Locations](#payload.v1.Object.Locations) - - [Object.ReshapeVector](#payload.v1.Object.ReshapeVector) - - [Object.StreamBlob](#payload.v1.Object.StreamBlob) - - [Object.StreamDistance](#payload.v1.Object.StreamDistance) - - [Object.StreamLocation](#payload.v1.Object.StreamLocation) - - [Object.StreamVector](#payload.v1.Object.StreamVector) - - [Object.Vector](#payload.v1.Object.Vector) - - [Object.VectorRequest](#payload.v1.Object.VectorRequest) - - [Object.Vectors](#payload.v1.Object.Vectors) - - [Remove](#payload.v1.Remove) - - [Remove.Config](#payload.v1.Remove.Config) - - [Remove.MultiRequest](#payload.v1.Remove.MultiRequest) - - [Remove.Request](#payload.v1.Remove.Request) - - [Search](#payload.v1.Search) - - [Search.Config](#payload.v1.Search.Config) - - [Search.IDRequest](#payload.v1.Search.IDRequest) - - [Search.MultiIDRequest](#payload.v1.Search.MultiIDRequest) - - [Search.MultiObjectRequest](#payload.v1.Search.MultiObjectRequest) - - [Search.MultiRequest](#payload.v1.Search.MultiRequest) - - [Search.ObjectRequest](#payload.v1.Search.ObjectRequest) - - [Search.Request](#payload.v1.Search.Request) - - [Search.Response](#payload.v1.Search.Response) - - [Search.Responses](#payload.v1.Search.Responses) - - [Search.StreamResponse](#payload.v1.Search.StreamResponse) - - [Update](#payload.v1.Update) - - [Update.Config](#payload.v1.Update.Config) - - [Update.MultiObjectRequest](#payload.v1.Update.MultiObjectRequest) - - [Update.MultiRequest](#payload.v1.Update.MultiRequest) - - [Update.ObjectRequest](#payload.v1.Update.ObjectRequest) - - [Update.Request](#payload.v1.Update.Request) - - [Upsert](#payload.v1.Upsert) - - [Upsert.Config](#payload.v1.Upsert.Config) - - [Upsert.MultiObjectRequest](#payload.v1.Upsert.MultiObjectRequest) - - [Upsert.MultiRequest](#payload.v1.Upsert.MultiRequest) - - [Upsert.ObjectRequest](#payload.v1.Upsert.ObjectRequest) - - [Upsert.Request](#payload.v1.Upsert.Request) -- [apis/proto/v1/vald/filter.proto](#apis/proto/v1/vald/filter.proto) - - [Filter](#vald.v1.Filter) -- [apis/proto/v1/vald/insert.proto](#apis/proto/v1/vald/insert.proto) - - [Insert](#vald.v1.Insert) -- [apis/proto/v1/vald/object.proto](#apis/proto/v1/vald/object.proto) - - [Object](#vald.v1.Object) -- [apis/proto/v1/vald/remove.proto](#apis/proto/v1/vald/remove.proto) - - [Remove](#vald.v1.Remove) -- [apis/proto/v1/vald/search.proto](#apis/proto/v1/vald/search.proto) - - [Search](#vald.v1.Search) -- [apis/proto/v1/vald/update.proto](#apis/proto/v1/vald/update.proto) - - [Update](#vald.v1.Update) -- [apis/proto/v1/vald/upsert.proto](#apis/proto/v1/vald/upsert.proto) - - [Upsert](#vald.v1.Upsert) +- [apis/proto/v1/agent/core/agent.proto](#apis_proto_v1_agent_core_agent-proto) + - [Agent](#core-v1-Agent) +- [apis/proto/v1/agent/sidecar/sidecar.proto](#apis_proto_v1_agent_sidecar_sidecar-proto) + - [Sidecar](#sidecar-v1-Sidecar) +- [apis/proto/v1/discoverer/discoverer.proto](#apis_proto_v1_discoverer_discoverer-proto) + - [Discoverer](#discoverer-v1-Discoverer) +- [apis/proto/v1/filter/egress/egress_filter.proto](#apis_proto_v1_filter_egress_egress_filter-proto) + - [Filter](#filter-egress-v1-Filter) +- [apis/proto/v1/filter/ingress/ingress_filter.proto](#apis_proto_v1_filter_ingress_ingress_filter-proto) + - [Filter](#filter-ingress-v1-Filter) +- [apis/proto/v1/manager/index/index_manager.proto](#apis_proto_v1_manager_index_index_manager-proto) + - [Index](#manager-index-v1-Index) +- [apis/proto/v1/payload/payload.proto](#apis_proto_v1_payload_payload-proto) + - [Control](#payload-v1-Control) + - [Control.CreateIndexRequest](#payload-v1-Control-CreateIndexRequest) + - [Discoverer](#payload-v1-Discoverer) + - [Discoverer.Request](#payload-v1-Discoverer-Request) + - [Empty](#payload-v1-Empty) + - [Filter](#payload-v1-Filter) + - [Filter.Config](#payload-v1-Filter-Config) + - [Filter.Target](#payload-v1-Filter-Target) + - [Info](#payload-v1-Info) + - [Info.CPU](#payload-v1-Info-CPU) + - [Info.IPs](#payload-v1-Info-IPs) + - [Info.Index](#payload-v1-Info-Index) + - [Info.Index.Count](#payload-v1-Info-Index-Count) + - [Info.Index.UUID](#payload-v1-Info-Index-UUID) + - [Info.Index.UUID.Committed](#payload-v1-Info-Index-UUID-Committed) + - [Info.Index.UUID.Uncommitted](#payload-v1-Info-Index-UUID-Uncommitted) + - [Info.Memory](#payload-v1-Info-Memory) + - [Info.Node](#payload-v1-Info-Node) + - [Info.Nodes](#payload-v1-Info-Nodes) + - [Info.Pod](#payload-v1-Info-Pod) + - [Info.Pods](#payload-v1-Info-Pods) + - [Insert](#payload-v1-Insert) + - [Insert.Config](#payload-v1-Insert-Config) + - [Insert.MultiObjectRequest](#payload-v1-Insert-MultiObjectRequest) + - [Insert.MultiRequest](#payload-v1-Insert-MultiRequest) + - [Insert.ObjectRequest](#payload-v1-Insert-ObjectRequest) + - [Insert.Request](#payload-v1-Insert-Request) + - [Object](#payload-v1-Object) + - [Object.Blob](#payload-v1-Object-Blob) + - [Object.Distance](#payload-v1-Object-Distance) + - [Object.ID](#payload-v1-Object-ID) + - [Object.IDs](#payload-v1-Object-IDs) + - [Object.Location](#payload-v1-Object-Location) + - [Object.Locations](#payload-v1-Object-Locations) + - [Object.ReshapeVector](#payload-v1-Object-ReshapeVector) + - [Object.StreamBlob](#payload-v1-Object-StreamBlob) + - [Object.StreamDistance](#payload-v1-Object-StreamDistance) + - [Object.StreamLocation](#payload-v1-Object-StreamLocation) + - [Object.StreamVector](#payload-v1-Object-StreamVector) + - [Object.Vector](#payload-v1-Object-Vector) + - [Object.VectorRequest](#payload-v1-Object-VectorRequest) + - [Object.Vectors](#payload-v1-Object-Vectors) + - [Remove](#payload-v1-Remove) + - [Remove.Config](#payload-v1-Remove-Config) + - [Remove.MultiRequest](#payload-v1-Remove-MultiRequest) + - [Remove.Request](#payload-v1-Remove-Request) + - [Search](#payload-v1-Search) + - [Search.Config](#payload-v1-Search-Config) + - [Search.IDRequest](#payload-v1-Search-IDRequest) + - [Search.MultiIDRequest](#payload-v1-Search-MultiIDRequest) + - [Search.MultiObjectRequest](#payload-v1-Search-MultiObjectRequest) + - [Search.MultiRequest](#payload-v1-Search-MultiRequest) + - [Search.ObjectRequest](#payload-v1-Search-ObjectRequest) + - [Search.Request](#payload-v1-Search-Request) + - [Search.Response](#payload-v1-Search-Response) + - [Search.Responses](#payload-v1-Search-Responses) + - [Search.StreamResponse](#payload-v1-Search-StreamResponse) + - [Update](#payload-v1-Update) + - [Update.Config](#payload-v1-Update-Config) + - [Update.MultiObjectRequest](#payload-v1-Update-MultiObjectRequest) + - [Update.MultiRequest](#payload-v1-Update-MultiRequest) + - [Update.ObjectRequest](#payload-v1-Update-ObjectRequest) + - [Update.Request](#payload-v1-Update-Request) + - [Upsert](#payload-v1-Upsert) + - [Upsert.Config](#payload-v1-Upsert-Config) + - [Upsert.MultiObjectRequest](#payload-v1-Upsert-MultiObjectRequest) + - [Upsert.MultiRequest](#payload-v1-Upsert-MultiRequest) + - [Upsert.ObjectRequest](#payload-v1-Upsert-ObjectRequest) + - [Upsert.Request](#payload-v1-Upsert-Request) +- [apis/proto/v1/vald/filter.proto](#apis_proto_v1_vald_filter-proto) + - [Filter](#vald-v1-Filter) +- [apis/proto/v1/vald/insert.proto](#apis_proto_v1_vald_insert-proto) + - [Insert](#vald-v1-Insert) +- [apis/proto/v1/vald/object.proto](#apis_proto_v1_vald_object-proto) + - [Object](#vald-v1-Object) +- [apis/proto/v1/vald/remove.proto](#apis_proto_v1_vald_remove-proto) + - [Remove](#vald-v1-Remove) +- [apis/proto/v1/vald/search.proto](#apis_proto_v1_vald_search-proto) + - [Search](#vald-v1-Search) +- [apis/proto/v1/vald/update.proto](#apis_proto_v1_vald_update-proto) + - [Update](#vald-v1-Update) +- [apis/proto/v1/vald/upsert.proto](#apis_proto_v1_vald_upsert-proto) + - [Upsert](#vald-v1-Upsert) - [Scalar Value Types](#scalar-value-types) - +

Top

## apis/proto/v1/agent/core/agent.proto - + ### Agent @@ -116,18 +116,18 @@ Represent the agent service. | Method Name | Request Type | Response Type | Description | | ------------------ | -------------------------------------------------------------------------------- | ------------------------------------------------------------ | ----------------------------------------------------- | -| CreateIndex | [.payload.v1.Control.CreateIndexRequest](#payload.v1.Control.CreateIndexRequest) | [.payload.v1.Empty](#payload.v1.Empty) | Represent the creating index RPC. | -| SaveIndex | [.payload.v1.Empty](#payload.v1.Empty) | [.payload.v1.Empty](#payload.v1.Empty) | Represent the saving index RPC. | -| CreateAndSaveIndex | [.payload.v1.Control.CreateIndexRequest](#payload.v1.Control.CreateIndexRequest) | [.payload.v1.Empty](#payload.v1.Empty) | Represent the creating and saving index RPC. | -| IndexInfo | [.payload.v1.Empty](#payload.v1.Empty) | [.payload.v1.Info.Index.Count](#payload.v1.Info.Index.Count) | Represent the RPC to get the agent index information. | +| CreateIndex | [.payload.v1.Control.CreateIndexRequest](#payload-v1-Control-CreateIndexRequest) | [.payload.v1.Empty](#payload-v1-Empty) | Represent the creating index RPC. | +| SaveIndex | [.payload.v1.Empty](#payload-v1-Empty) | [.payload.v1.Empty](#payload-v1-Empty) | Represent the saving index RPC. | +| CreateAndSaveIndex | [.payload.v1.Control.CreateIndexRequest](#payload-v1-Control-CreateIndexRequest) | [.payload.v1.Empty](#payload-v1-Empty) | Represent the creating and saving index RPC. | +| IndexInfo | [.payload.v1.Empty](#payload-v1-Empty) | [.payload.v1.Info.Index.Count](#payload-v1-Info-Index-Count) | Represent the RPC to get the agent index information. | - +

Top

## apis/proto/v1/agent/sidecar/sidecar.proto - + ### Sidecar @@ -136,13 +136,13 @@ Represent the agent sidecar service. | Method Name | Request Type | Response Type | Description | | ----------- | ------------ | ------------- | ----------- | - +

Top

## apis/proto/v1/discoverer/discoverer.proto - + ### Discoverer @@ -150,16 +150,16 @@ Represent the discoverer service. | Method Name | Request Type | Response Type | Description | | ----------- | ---------------------------------------------------------------- | ------------------------------------------------ | ---------------------------------------------------- | -| Pods | [.payload.v1.Discoverer.Request](#payload.v1.Discoverer.Request) | [.payload.v1.Info.Pods](#payload.v1.Info.Pods) | Represent the RPC to get the agent pods information. | -| Nodes | [.payload.v1.Discoverer.Request](#payload.v1.Discoverer.Request) | [.payload.v1.Info.Nodes](#payload.v1.Info.Nodes) | Represent the RPC to get the node information. | +| Pods | [.payload.v1.Discoverer.Request](#payload-v1-Discoverer-Request) | [.payload.v1.Info.Pods](#payload-v1-Info-Pods) | Represent the RPC to get the agent pods information. | +| Nodes | [.payload.v1.Discoverer.Request](#payload-v1-Discoverer-Request) | [.payload.v1.Info.Nodes](#payload-v1-Info-Nodes) | Represent the RPC to get the node information. | - +

Top

## apis/proto/v1/filter/egress/egress_filter.proto - + ### Filter @@ -167,16 +167,16 @@ Represent the egress filter service. | Method Name | Request Type | Response Type | Description | | -------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | ----------------------------------------- | -| FilterDistance | [.payload.v1.Object.Distance](#payload.v1.Object.Distance) | [.payload.v1.Object.Distance](#payload.v1.Object.Distance) | Represent the RPC to filter the distance. | -| FilterVector | [.payload.v1.Object.Vector](#payload.v1.Object.Vector) | [.payload.v1.Object.Vector](#payload.v1.Object.Vector) | Represent the RPC to filter the vector. | +| FilterDistance | [.payload.v1.Object.Distance](#payload-v1-Object-Distance) | [.payload.v1.Object.Distance](#payload-v1-Object-Distance) | Represent the RPC to filter the distance. | +| FilterVector | [.payload.v1.Object.Vector](#payload-v1-Object-Vector) | [.payload.v1.Object.Vector](#payload-v1-Object-Vector) | Represent the RPC to filter the vector. | - +

Top

## apis/proto/v1/filter/ingress/ingress_filter.proto - + ### Filter @@ -184,16 +184,16 @@ Represent the ingress filter service. | Method Name | Request Type | Response Type | Description | | ------------ | ------------------------------------------------------ | ------------------------------------------------------ | ----------------------------------------- | -| GenVector | [.payload.v1.Object.Blob](#payload.v1.Object.Blob) | [.payload.v1.Object.Vector](#payload.v1.Object.Vector) | Represent the RPC to generate the vector. | -| FilterVector | [.payload.v1.Object.Vector](#payload.v1.Object.Vector) | [.payload.v1.Object.Vector](#payload.v1.Object.Vector) | Represent the RPC to filter the vector. | +| GenVector | [.payload.v1.Object.Blob](#payload-v1-Object-Blob) | [.payload.v1.Object.Vector](#payload-v1-Object-Vector) | Represent the RPC to generate the vector. | +| FilterVector | [.payload.v1.Object.Vector](#payload-v1-Object-Vector) | [.payload.v1.Object.Vector](#payload-v1-Object-Vector) | Represent the RPC to filter the vector. | - +

Top

## apis/proto/v1/manager/index/index_manager.proto - + ### Index @@ -201,21 +201,21 @@ Represent the index manager service. | Method Name | Request Type | Response Type | Description | | ----------- | -------------------------------------- | ------------------------------------------------------------ | ----------------------------------------------- | -| IndexInfo | [.payload.v1.Empty](#payload.v1.Empty) | [.payload.v1.Info.Index.Count](#payload.v1.Info.Index.Count) | Represent the RPC to get the index information. | +| IndexInfo | [.payload.v1.Empty](#payload-v1-Empty) | [.payload.v1.Info.Index.Count](#payload-v1-Info-Index-Count) | Represent the RPC to get the index information. | - +

Top

## apis/proto/v1/payload/payload.proto - + ### Control Control related messages. - + ### Control.CreateIndexRequest @@ -225,13 +225,13 @@ Represent the create index request. | --------- | ----------------- | ----- | -------------------------------------------- | | pool_size | [uint32](#uint32) | | The pool size of the create index operation. | - + ### Discoverer Discoverer related messages. - + ### Discoverer.Request @@ -243,19 +243,19 @@ Represent the dicoverer request. | namespace | [string](#string) | | The namespace to be discovered. | | node | [string](#string) | | The node to be discovered. | - + ### Empty Represent an empty message. - + ### Filter Filter related messages. - + ### Filter.Config @@ -263,9 +263,9 @@ Represent filter configuration. | Field | Type | Label | Description | | ------- | ------------------------------------------ | -------- | ------------------------------------------ | -| targets | [Filter.Target](#payload.v1.Filter.Target) | repeated | Represent the filter target configuration. | +| targets | [Filter.Target](#payload-v1-Filter-Target) | repeated | Represent the filter target configuration. | - + ### Filter.Target @@ -276,13 +276,13 @@ Represent the target filter server. | host | [string](#string) | | The target hostname. | | port | [uint32](#uint32) | | The target port. | - + ### Info Info related messages. - + ### Info.CPU @@ -294,7 +294,7 @@ Represent the CPU information message. | request | [double](#double) | | The CPU resource requested. | | usage | [double](#double) | | The CPU usage. | - + ### Info.IPs @@ -304,13 +304,13 @@ Represent the multiple IP message. | ----- | ----------------- | -------- | ----------- | | ip | [string](#string) | repeated | | - + ### Info.Index Represent the index information messages. - + ### Info.Index.Count @@ -323,13 +323,13 @@ Represent the index count message. | indexing | [bool](#bool) | | The indexing index count. | | saving | [bool](#bool) | | The saving index count. | - + ### Info.Index.UUID Represent the UUID message. - + ### Info.Index.UUID.Committed @@ -339,7 +339,7 @@ The committed UUID. | ----- | ----------------- | ----- | ----------- | | uuid | [string](#string) | | | - + ### Info.Index.UUID.Uncommitted @@ -349,7 +349,7 @@ The uncommitted UUID. | ----- | ----------------- | ----- | ----------- | | uuid | [string](#string) | | | - + ### Info.Memory @@ -361,7 +361,7 @@ Represent the memory information message. | request | [double](#double) | | The memory requested. | | usage | [double](#double) | | The memory usage. | - + ### Info.Node @@ -372,11 +372,11 @@ Represent the node information message. | name | [string](#string) | | The name of the node. | | internal_addr | [string](#string) | | The internal IP address of the node. | | external_addr | [string](#string) | | The external IP address of the node. | -| cpu | [Info.CPU](#payload.v1.Info.CPU) | | The CPU information of the node. | -| memory | [Info.Memory](#payload.v1.Info.Memory) | | The memory information of the node. | -| Pods | [Info.Pods](#payload.v1.Info.Pods) | | The pod information of the node. | +| cpu | [Info.CPU](#payload-v1-Info-CPU) | | The CPU information of the node. | +| memory | [Info.Memory](#payload-v1-Info-Memory) | | The memory information of the node. | +| Pods | [Info.Pods](#payload-v1-Info-Pods) | | The pod information of the node. | - + ### Info.Nodes @@ -384,9 +384,9 @@ Represent the multiple node information message. | Field | Type | Label | Description | | ----- | ---------------------------------- | -------- | ------------------------------ | -| nodes | [Info.Node](#payload.v1.Info.Node) | repeated | The multiple node information. | +| nodes | [Info.Node](#payload-v1-Info-Node) | repeated | The multiple node information. | - + ### Info.Pod @@ -398,11 +398,11 @@ Represent the pod information message. | name | [string](#string) | | The name of the pod. | | namespace | [string](#string) | | The namespace of the pod. | | ip | [string](#string) | | The IP of the pod. | -| cpu | [Info.CPU](#payload.v1.Info.CPU) | | The CPU information of the pod. | -| memory | [Info.Memory](#payload.v1.Info.Memory) | | The memory information of the pod. | -| node | [Info.Node](#payload.v1.Info.Node) | | The node information of the pod. | +| cpu | [Info.CPU](#payload-v1-Info-CPU) | | The CPU information of the pod. | +| memory | [Info.Memory](#payload-v1-Info-Memory) | | The memory information of the pod. | +| node | [Info.Node](#payload-v1-Info-Node) | | The node information of the pod. | - + ### Info.Pods @@ -410,15 +410,15 @@ Represent the multiple pod information message. | Field | Type | Label | Description | | ----- | -------------------------------- | -------- | ----------------------------- | -| pods | [Info.Pod](#payload.v1.Info.Pod) | repeated | The multiple pod information. | +| pods | [Info.Pod](#payload-v1-Info-Pod) | repeated | The multiple pod information. | - + ### Insert Insert related messages. - + ### Insert.Config @@ -427,10 +427,10 @@ Represent insert configurations. | Field | Type | Label | Description | | ----------------------- | ------------------------------------------ | ----- | --------------------------------------------------- | | skip_strict_exist_check | [bool](#bool) | | A flag to skip exist check during insert operation. | -| filters | [Filter.Config](#payload.v1.Filter.Config) | | Filter configurations. | +| filters | [Filter.Config](#payload-v1-Filter-Config) | | Filter configurations. | | timestamp | [int64](#int64) | | Insert timestamp. | - + ### Insert.MultiObjectRequest @@ -438,9 +438,9 @@ Represent the multiple insert by binary object request. | Field | Type | Label | Description | | -------- | -------------------------------------------------------- | -------- | -------------------------------------------- | -| requests | [Insert.ObjectRequest](#payload.v1.Insert.ObjectRequest) | repeated | Represent multiple insert by object content. | +| requests | [Insert.ObjectRequest](#payload-v1-Insert-ObjectRequest) | repeated | Represent multiple insert by object content. | - + ### Insert.MultiRequest @@ -448,9 +448,9 @@ Represent the multiple insert request. | Field | Type | Label | Description | | -------- | -------------------------------------------- | -------- | ------------------------------------------ | -| requests | [Insert.Request](#payload.v1.Insert.Request) | repeated | Represent multiple insert request content. | +| requests | [Insert.Request](#payload-v1-Insert-Request) | repeated | Represent multiple insert request content. | - + ### Insert.ObjectRequest @@ -458,11 +458,11 @@ Represent the insert by binary object request. | Field | Type | Label | Description | | ---------- | ------------------------------------------ | ----- | ---------------------------------------- | -| object | [Object.Blob](#payload.v1.Object.Blob) | | The binary object to be inserted. | -| config | [Insert.Config](#payload.v1.Insert.Config) | | The configuration of the insert request. | -| vectorizer | [Filter.Target](#payload.v1.Filter.Target) | | Filter configurations. | +| object | [Object.Blob](#payload-v1-Object-Blob) | | The binary object to be inserted. | +| config | [Insert.Config](#payload-v1-Insert-Config) | | The configuration of the insert request. | +| vectorizer | [Filter.Target](#payload-v1-Filter-Target) | | Filter configurations. | - + ### Insert.Request @@ -470,16 +470,16 @@ Represent the insert request. | Field | Type | Label | Description | | ------ | ------------------------------------------ | ----- | ---------------------------------------- | -| vector | [Object.Vector](#payload.v1.Object.Vector) | | The vector to be inserted. | -| config | [Insert.Config](#payload.v1.Insert.Config) | | The configuration of the insert request. | +| vector | [Object.Vector](#payload-v1-Object-Vector) | | The vector to be inserted. | +| config | [Insert.Config](#payload-v1-Insert-Config) | | The configuration of the insert request. | - + ### Object Common messages. - + ### Object.Blob @@ -490,7 +490,7 @@ Represent the binary object. | id | [string](#string) | | The object ID. | | object | [bytes](#bytes) | | The binary object. | - + ### Object.Distance @@ -501,7 +501,7 @@ Represent the ID and distance pair. | id | [string](#string) | | The vector ID. | | distance | [float](#float) | | The distance. | - + ### Object.ID @@ -511,7 +511,7 @@ Represent the vector ID. | ----- | ----------------- | ----- | ----------- | | id | [string](#string) | | | - + ### Object.IDs @@ -521,7 +521,7 @@ Represent multiple vector IDs. | ----- | ----------------- | -------- | ----------- | | ids | [string](#string) | repeated | | - + ### Object.Location @@ -533,7 +533,7 @@ Represent the vector location. | uuid | [string](#string) | | The UUID of the vector. | | ips | [string](#string) | repeated | The IP list. | - + ### Object.Locations @@ -541,9 +541,9 @@ Represent multiple vector locations. | Field | Type | Label | Description | | --------- | ---------------------------------------------- | -------- | ----------- | -| locations | [Object.Location](#payload.v1.Object.Location) | repeated | | +| locations | [Object.Location](#payload-v1-Object-Location) | repeated | | - + ### Object.ReshapeVector @@ -554,7 +554,7 @@ Represent reshape vector. | object | [bytes](#bytes) | | The binary object. | | shape | [int32](#int32) | repeated | The new shape. | - + ### Object.StreamBlob @@ -562,10 +562,10 @@ Represent stream response of binary objects. | Field | Type | Label | Description | | ------ | --------------------------------------- | ----- | --------------------- | -| blob | [Object.Blob](#payload.v1.Object.Blob) | | The binary object. | -| status | [google.rpc.Status](#google.rpc.Status) | | The RPC error status. | +| blob | [Object.Blob](#payload-v1-Object-Blob) | | The binary object. | +| status | [google.rpc.Status](#google-rpc-Status) | | The RPC error status. | - + ### Object.StreamDistance @@ -573,10 +573,10 @@ Represent stream response of distances. | Field | Type | Label | Description | | -------- | ---------------------------------------------- | ----- | --------------------- | -| distance | [Object.Distance](#payload.v1.Object.Distance) | | The distance. | -| status | [google.rpc.Status](#google.rpc.Status) | | The RPC error status. | +| distance | [Object.Distance](#payload-v1-Object-Distance) | | The distance. | +| status | [google.rpc.Status](#google-rpc-Status) | | The RPC error status. | - + ### Object.StreamLocation @@ -584,10 +584,10 @@ Represent the stream response of the vector location. | Field | Type | Label | Description | | -------- | ---------------------------------------------- | ----- | --------------------- | -| location | [Object.Location](#payload.v1.Object.Location) | | The vector location. | -| status | [google.rpc.Status](#google.rpc.Status) | | The RPC error status. | +| location | [Object.Location](#payload-v1-Object-Location) | | The vector location. | +| status | [google.rpc.Status](#google-rpc-Status) | | The RPC error status. | - + ### Object.StreamVector @@ -595,10 +595,10 @@ Represent stream response of the vector. | Field | Type | Label | Description | | ------ | ------------------------------------------ | ----- | --------------------- | -| vector | [Object.Vector](#payload.v1.Object.Vector) | | The vector. | -| status | [google.rpc.Status](#google.rpc.Status) | | The RPC error status. | +| vector | [Object.Vector](#payload-v1-Object-Vector) | | The vector. | +| status | [google.rpc.Status](#google-rpc-Status) | | The RPC error status. | - + ### Object.Vector @@ -609,7 +609,7 @@ Represent a vector. | id | [string](#string) | | The vector ID. | | vector | [float](#float) | repeated | The vector. | - + ### Object.VectorRequest @@ -617,10 +617,10 @@ Represent a request to fetch raw vector. | Field | Type | Label | Description | | ------- | ------------------------------------------ | ----- | ---------------------------- | -| id | [Object.ID](#payload.v1.Object.ID) | | The vector ID to be fetched. | -| filters | [Filter.Config](#payload.v1.Filter.Config) | | Filter configurations. | +| id | [Object.ID](#payload-v1-Object-ID) | | The vector ID to be fetched. | +| filters | [Filter.Config](#payload-v1-Filter-Config) | | Filter configurations. | - + ### Object.Vectors @@ -628,15 +628,15 @@ Represent multiple vectors. | Field | Type | Label | Description | | ------- | ------------------------------------------ | -------- | ----------- | -| vectors | [Object.Vector](#payload.v1.Object.Vector) | repeated | | +| vectors | [Object.Vector](#payload-v1-Object-Vector) | repeated | | - + ### Remove Remove related messages. - + ### Remove.Config @@ -647,7 +647,7 @@ Represent the remove configuration. | skip_strict_exist_check | [bool](#bool) | | A flag to skip exist check during upsert operation. | | timestamp | [int64](#int64) | | Remove timestamp. | - + ### Remove.MultiRequest @@ -655,9 +655,9 @@ Represent the multiple remove request. | Field | Type | Label | Description | | -------- | -------------------------------------------- | -------- | ---------------------------------------------- | -| requests | [Remove.Request](#payload.v1.Remove.Request) | repeated | Represent the multiple remove request content. | +| requests | [Remove.Request](#payload-v1-Remove-Request) | repeated | Represent the multiple remove request content. | - + ### Remove.Request @@ -665,16 +665,16 @@ Represent the remove request. | Field | Type | Label | Description | | ------ | ------------------------------------------ | ----- | ---------------------------------------- | -| id | [Object.ID](#payload.v1.Object.ID) | | The object ID to be removed. | -| config | [Remove.Config](#payload.v1.Remove.Config) | | The configuration of the remove request. | +| id | [Object.ID](#payload-v1-Object-ID) | | The object ID to be removed. | +| config | [Remove.Config](#payload-v1-Remove-Config) | | The configuration of the remove request. | - + ### Search Search related messages. - + ### Search.Config @@ -687,11 +687,11 @@ Represent search configuration. | radius | [float](#float) | | Search radius. | | epsilon | [float](#float) | | Search coefficient. | | timeout | [int64](#int64) | | Search timeout in nanoseconds. | -| ingress_filters | [Filter.Config](#payload.v1.Filter.Config) | | Ingress filter configurations. | -| egress_filters | [Filter.Config](#payload.v1.Filter.Config) | | Egress filter configurations. | +| ingress_filters | [Filter.Config](#payload-v1-Filter-Config) | | Ingress filter configurations. | +| egress_filters | [Filter.Config](#payload-v1-Filter-Config) | | Egress filter configurations. | | min_num | [uint32](#uint32) | | Minimum number of result to be returned. | - + ### Search.IDRequest @@ -700,9 +700,9 @@ Represent a search by ID request. | Field | Type | Label | Description | | ------ | ------------------------------------------ | ----- | ---------------------------------------- | | id | [string](#string) | | The vector ID to be searched. | -| config | [Search.Config](#payload.v1.Search.Config) | | The configuration of the search request. | +| config | [Search.Config](#payload-v1-Search-Config) | | The configuration of the search request. | - + ### Search.MultiIDRequest @@ -710,9 +710,9 @@ Represent the multiple search by ID request. | Field | Type | Label | Description | | -------- | ------------------------------------------------ | -------- | ---------------------------------------------------- | -| requests | [Search.IDRequest](#payload.v1.Search.IDRequest) | repeated | Represent the multiple search by ID request content. | +| requests | [Search.IDRequest](#payload-v1-Search-IDRequest) | repeated | Represent the multiple search by ID request content. | - + ### Search.MultiObjectRequest @@ -720,9 +720,9 @@ Represent the multiple search by binary object request. | Field | Type | Label | Description | | -------- | -------------------------------------------------------- | -------- | --------------------------------------------------------------- | -| requests | [Search.ObjectRequest](#payload.v1.Search.ObjectRequest) | repeated | Represent the multiple search by binary object request content. | +| requests | [Search.ObjectRequest](#payload-v1-Search-ObjectRequest) | repeated | Represent the multiple search by binary object request content. | - + ### Search.MultiRequest @@ -730,9 +730,9 @@ Represent the multiple search request. | Field | Type | Label | Description | | -------- | -------------------------------------------- | -------- | ---------------------------------------------- | -| requests | [Search.Request](#payload.v1.Search.Request) | repeated | Represent the multiple search request content. | +| requests | [Search.Request](#payload-v1-Search-Request) | repeated | Represent the multiple search request content. | - + ### Search.ObjectRequest @@ -741,10 +741,10 @@ Represent a search by binary object request. | Field | Type | Label | Description | | ---------- | ------------------------------------------ | ----- | ---------------------------------------- | | object | [bytes](#bytes) | | The binary object to be searched. | -| config | [Search.Config](#payload.v1.Search.Config) | | The configuration of the search request. | -| vectorizer | [Filter.Target](#payload.v1.Filter.Target) | | Filter configuration. | +| config | [Search.Config](#payload-v1-Search-Config) | | The configuration of the search request. | +| vectorizer | [Filter.Target](#payload-v1-Filter-Target) | | Filter configuration. | - + ### Search.Request @@ -753,9 +753,9 @@ Represent a search request. | Field | Type | Label | Description | | ------ | ------------------------------------------ | -------- | ---------------------------------------- | | vector | [float](#float) | repeated | The vector to be searched. | -| config | [Search.Config](#payload.v1.Search.Config) | | The configuration of the search request. | +| config | [Search.Config](#payload-v1-Search-Config) | | The configuration of the search request. | - + ### Search.Response @@ -764,9 +764,9 @@ Represent a search response. | Field | Type | Label | Description | | ---------- | ---------------------------------------------- | -------- | ---------------------- | | request_id | [string](#string) | | The unique request ID. | -| results | [Object.Distance](#payload.v1.Object.Distance) | repeated | Search results. | +| results | [Object.Distance](#payload-v1-Object-Distance) | repeated | Search results. | - + ### Search.Responses @@ -774,9 +774,9 @@ Represent multiple search responses. | Field | Type | Label | Description | | --------- | ---------------------------------------------- | -------- | ----------------------------------------------- | -| responses | [Search.Response](#payload.v1.Search.Response) | repeated | Represent the multiple search response content. | +| responses | [Search.Response](#payload-v1-Search-Response) | repeated | Represent the multiple search response content. | - + ### Search.StreamResponse @@ -784,16 +784,16 @@ Represent stream search response. | Field | Type | Label | Description | | -------- | ---------------------------------------------- | ----- | ------------------------------ | -| response | [Search.Response](#payload.v1.Search.Response) | | Represent the search response. | -| status | [google.rpc.Status](#google.rpc.Status) | | The RPC error status. | +| response | [Search.Response](#payload-v1-Search-Response) | | Represent the search response. | +| status | [google.rpc.Status](#google-rpc-Status) | | The RPC error status. | - + ### Update Update related messages - + ### Update.Config @@ -802,10 +802,10 @@ Represent the update configuration. | Field | Type | Label | Description | | ----------------------- | ------------------------------------------ | ----- | --------------------------------------------------- | | skip_strict_exist_check | [bool](#bool) | | A flag to skip exist check during update operation. | -| filters | [Filter.Config](#payload.v1.Filter.Config) | | Filter configuration. | +| filters | [Filter.Config](#payload-v1-Filter-Config) | | Filter configuration. | | timestamp | [int64](#int64) | | Update timestamp. | - + ### Update.MultiObjectRequest @@ -813,9 +813,9 @@ Represent the multiple update binary object request. | Field | Type | Label | Description | | -------- | -------------------------------------------------------- | -------- | ----------------------------------------------------- | -| requests | [Update.ObjectRequest](#payload.v1.Update.ObjectRequest) | repeated | Represent the multiple update object request content. | +| requests | [Update.ObjectRequest](#payload-v1-Update-ObjectRequest) | repeated | Represent the multiple update object request content. | - + ### Update.MultiRequest @@ -823,9 +823,9 @@ Represent the multiple update request. | Field | Type | Label | Description | | -------- | -------------------------------------------- | -------- | ---------------------------------------------- | -| requests | [Update.Request](#payload.v1.Update.Request) | repeated | Represent the multiple update request content. | +| requests | [Update.Request](#payload-v1-Update-Request) | repeated | Represent the multiple update request content. | - + ### Update.ObjectRequest @@ -833,11 +833,11 @@ Represent the update binary object request. | Field | Type | Label | Description | | ---------- | ------------------------------------------ | ----- | ---------------------------------------- | -| object | [Object.Blob](#payload.v1.Object.Blob) | | The binary object to be updated. | -| config | [Update.Config](#payload.v1.Update.Config) | | The configuration of the update request. | -| vectorizer | [Filter.Target](#payload.v1.Filter.Target) | | Filter target. | +| object | [Object.Blob](#payload-v1-Object-Blob) | | The binary object to be updated. | +| config | [Update.Config](#payload-v1-Update-Config) | | The configuration of the update request. | +| vectorizer | [Filter.Target](#payload-v1-Filter-Target) | | Filter target. | - + ### Update.Request @@ -845,16 +845,16 @@ Represent the update request. | Field | Type | Label | Description | | ------ | ------------------------------------------ | ----- | ---------------------------------------- | -| vector | [Object.Vector](#payload.v1.Object.Vector) | | The vector to be updated. | -| config | [Update.Config](#payload.v1.Update.Config) | | The configuration of the update request. | +| vector | [Object.Vector](#payload-v1-Object-Vector) | | The vector to be updated. | +| config | [Update.Config](#payload-v1-Update-Config) | | The configuration of the update request. | - + ### Upsert Upsert related messages. - + ### Upsert.Config @@ -863,10 +863,10 @@ Represent the upsert configuration. | Field | Type | Label | Description | | ----------------------- | ------------------------------------------ | ----- | --------------------------------------------------- | | skip_strict_exist_check | [bool](#bool) | | A flag to skip exist check during upsert operation. | -| filters | [Filter.Config](#payload.v1.Filter.Config) | | Filter configuration. | +| filters | [Filter.Config](#payload-v1-Filter-Config) | | Filter configuration. | | timestamp | [int64](#int64) | | Upsert timestamp. | - + ### Upsert.MultiObjectRequest @@ -874,9 +874,9 @@ Represent the multiple upsert binary object request. | Field | Type | Label | Description | | -------- | -------------------------------------------------------- | -------- | ----------------------------------------------------- | -| requests | [Upsert.ObjectRequest](#payload.v1.Upsert.ObjectRequest) | repeated | Represent the multiple upsert object request content. | +| requests | [Upsert.ObjectRequest](#payload-v1-Upsert-ObjectRequest) | repeated | Represent the multiple upsert object request content. | - + ### Upsert.MultiRequest @@ -884,9 +884,9 @@ Represent mthe ultiple upsert request. | Field | Type | Label | Description | | -------- | -------------------------------------------- | -------- | ---------------------------------------------- | -| requests | [Upsert.Request](#payload.v1.Upsert.Request) | repeated | Represent the multiple upsert request content. | +| requests | [Upsert.Request](#payload-v1-Upsert-Request) | repeated | Represent the multiple upsert request content. | - + ### Upsert.ObjectRequest @@ -894,11 +894,11 @@ Represent the upsert binary object request. | Field | Type | Label | Description | | ---------- | ------------------------------------------ | ----- | ---------------------------------------- | -| object | [Object.Blob](#payload.v1.Object.Blob) | | The binary object to be upserted. | -| config | [Upsert.Config](#payload.v1.Upsert.Config) | | The configuration of the upsert request. | -| vectorizer | [Filter.Target](#payload.v1.Filter.Target) | | Filter target. | +| object | [Object.Blob](#payload-v1-Object-Blob) | | The binary object to be upserted. | +| config | [Upsert.Config](#payload-v1-Upsert-Config) | | The configuration of the upsert request. | +| vectorizer | [Filter.Target](#payload-v1-Filter-Target) | | Filter target. | - + ### Upsert.Request @@ -906,16 +906,16 @@ Represent the upsert request. | Field | Type | Label | Description | | ------ | ------------------------------------------ | ----- | ---------------------------------------- | -| vector | [Object.Vector](#payload.v1.Object.Vector) | | The vector to be upserted. | -| config | [Upsert.Config](#payload.v1.Upsert.Config) | | The configuration of the upsert request. | +| vector | [Object.Vector](#payload-v1-Object-Vector) | | The vector to be upserted. | +| config | [Upsert.Config](#payload-v1-Upsert-Config) | | The configuration of the upsert request. | - +

Top

## apis/proto/v1/vald/filter.proto - + ### Filter @@ -923,26 +923,26 @@ Filter service provides ways to connect to Vald through filter. | Method Name | Request Type | Response Type | Description | | ------------------ | ------------------------------------------------------------------------------ | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------ | -| SearchObject | [.payload.v1.Search.ObjectRequest](#payload.v1.Search.ObjectRequest) | [.payload.v1.Search.Response](#payload.v1.Search.Response) | A method to search object. | -| MultiSearchObject | [.payload.v1.Search.MultiObjectRequest](#payload.v1.Search.MultiObjectRequest) | [.payload.v1.Search.Responses](#payload.v1.Search.Responses) | A method to search multiple objects. | -| StreamSearchObject | [.payload.v1.Search.ObjectRequest](#payload.v1.Search.ObjectRequest) stream | [.payload.v1.Search.StreamResponse](#payload.v1.Search.StreamResponse) stream | A method to search object by bidirectional streaming. | -| InsertObject | [.payload.v1.Insert.ObjectRequest](#payload.v1.Insert.ObjectRequest) | [.payload.v1.Object.Location](#payload.v1.Object.Location) | A method insert object. | -| StreamInsertObject | [.payload.v1.Insert.ObjectRequest](#payload.v1.Insert.ObjectRequest) stream | [.payload.v1.Object.StreamLocation](#payload.v1.Object.StreamLocation) stream | Represent the streaming RPC to insert object by bidirectional streaming. | -| MultiInsertObject | [.payload.v1.Insert.MultiObjectRequest](#payload.v1.Insert.MultiObjectRequest) | [.payload.v1.Object.Locations](#payload.v1.Object.Locations) | A method to insert multiple objects. | -| UpdateObject | [.payload.v1.Update.ObjectRequest](#payload.v1.Update.ObjectRequest) | [.payload.v1.Object.Location](#payload.v1.Object.Location) | A method to update object. | -| StreamUpdateObject | [.payload.v1.Update.ObjectRequest](#payload.v1.Update.ObjectRequest) stream | [.payload.v1.Object.StreamLocation](#payload.v1.Object.StreamLocation) stream | A method to update object by bidirectional streaming. | -| MultiUpdateObject | [.payload.v1.Update.MultiObjectRequest](#payload.v1.Update.MultiObjectRequest) | [.payload.v1.Object.Locations](#payload.v1.Object.Locations) | A method to update multiple objects. | -| UpsertObject | [.payload.v1.Upsert.ObjectRequest](#payload.v1.Upsert.ObjectRequest) | [.payload.v1.Object.Location](#payload.v1.Object.Location) | A method to upsert object. | -| StreamUpsertObject | [.payload.v1.Upsert.ObjectRequest](#payload.v1.Upsert.ObjectRequest) stream | [.payload.v1.Object.StreamLocation](#payload.v1.Object.StreamLocation) stream | A method to upsert object by bidirectional streaming. | -| MultiUpsertObject | [.payload.v1.Upsert.MultiObjectRequest](#payload.v1.Upsert.MultiObjectRequest) | [.payload.v1.Object.Locations](#payload.v1.Object.Locations) | A method to upsert multiple objects. | - - +| SearchObject | [.payload.v1.Search.ObjectRequest](#payload-v1-Search-ObjectRequest) | [.payload.v1.Search.Response](#payload-v1-Search-Response) | A method to search object. | +| MultiSearchObject | [.payload.v1.Search.MultiObjectRequest](#payload-v1-Search-MultiObjectRequest) | [.payload.v1.Search.Responses](#payload-v1-Search-Responses) | A method to search multiple objects. | +| StreamSearchObject | [.payload.v1.Search.ObjectRequest](#payload-v1-Search-ObjectRequest) stream | [.payload.v1.Search.StreamResponse](#payload-v1-Search-StreamResponse) stream | A method to search object by bidirectional streaming. | +| InsertObject | [.payload.v1.Insert.ObjectRequest](#payload-v1-Insert-ObjectRequest) | [.payload.v1.Object.Location](#payload-v1-Object-Location) | A method insert object. | +| StreamInsertObject | [.payload.v1.Insert.ObjectRequest](#payload-v1-Insert-ObjectRequest) stream | [.payload.v1.Object.StreamLocation](#payload-v1-Object-StreamLocation) stream | Represent the streaming RPC to insert object by bidirectional streaming. | +| MultiInsertObject | [.payload.v1.Insert.MultiObjectRequest](#payload-v1-Insert-MultiObjectRequest) | [.payload.v1.Object.Locations](#payload-v1-Object-Locations) | A method to insert multiple objects. | +| UpdateObject | [.payload.v1.Update.ObjectRequest](#payload-v1-Update-ObjectRequest) | [.payload.v1.Object.Location](#payload-v1-Object-Location) | A method to update object. | +| StreamUpdateObject | [.payload.v1.Update.ObjectRequest](#payload-v1-Update-ObjectRequest) stream | [.payload.v1.Object.StreamLocation](#payload-v1-Object-StreamLocation) stream | A method to update object by bidirectional streaming. | +| MultiUpdateObject | [.payload.v1.Update.MultiObjectRequest](#payload-v1-Update-MultiObjectRequest) | [.payload.v1.Object.Locations](#payload-v1-Object-Locations) | A method to update multiple objects. | +| UpsertObject | [.payload.v1.Upsert.ObjectRequest](#payload-v1-Upsert-ObjectRequest) | [.payload.v1.Object.Location](#payload-v1-Object-Location) | A method to upsert object. | +| StreamUpsertObject | [.payload.v1.Upsert.ObjectRequest](#payload-v1-Upsert-ObjectRequest) stream | [.payload.v1.Object.StreamLocation](#payload-v1-Object-StreamLocation) stream | A method to upsert object by bidirectional streaming. | +| MultiUpsertObject | [.payload.v1.Upsert.MultiObjectRequest](#payload-v1-Upsert-MultiObjectRequest) | [.payload.v1.Object.Locations](#payload-v1-Object-Locations) | A method to upsert multiple objects. | + +

Top

## apis/proto/v1/vald/insert.proto - + ### Insert @@ -950,17 +950,17 @@ Insert service provides ways to add new vectors. | Method Name | Request Type | Response Type | Description | | ------------ | ------------------------------------------------------------------ | ----------------------------------------------------------------------------- | ---------------------------------------------------------------- | -| Insert | [.payload.v1.Insert.Request](#payload.v1.Insert.Request) | [.payload.v1.Object.Location](#payload.v1.Object.Location) | A method to add a new single vector. | -| StreamInsert | [.payload.v1.Insert.Request](#payload.v1.Insert.Request) stream | [.payload.v1.Object.StreamLocation](#payload.v1.Object.StreamLocation) stream | A method to add new multiple vectors by bidirectional streaming. | -| MultiInsert | [.payload.v1.Insert.MultiRequest](#payload.v1.Insert.MultiRequest) | [.payload.v1.Object.Locations](#payload.v1.Object.Locations) | A method to add new multiple vectors in a single request. | +| Insert | [.payload.v1.Insert.Request](#payload-v1-Insert-Request) | [.payload.v1.Object.Location](#payload-v1-Object-Location) | A method to add a new single vector. | +| StreamInsert | [.payload.v1.Insert.Request](#payload-v1-Insert-Request) stream | [.payload.v1.Object.StreamLocation](#payload-v1-Object-StreamLocation) stream | A method to add new multiple vectors by bidirectional streaming. | +| MultiInsert | [.payload.v1.Insert.MultiRequest](#payload-v1-Insert-MultiRequest) | [.payload.v1.Object.Locations](#payload-v1-Object-Locations) | A method to add new multiple vectors in a single request. | - +

Top

## apis/proto/v1/vald/object.proto - + ### Object @@ -968,17 +968,17 @@ Object service provides ways to fetch indexed vectors. | Method Name | Request Type | Response Type | Description | | --------------- | --------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ----------------------------------------------------------- | -| Exists | [.payload.v1.Object.ID](#payload.v1.Object.ID) | [.payload.v1.Object.ID](#payload.v1.Object.ID) | A method to check whether a specified ID is indexed or not. | -| GetObject | [.payload.v1.Object.VectorRequest](#payload.v1.Object.VectorRequest) | [.payload.v1.Object.Vector](#payload.v1.Object.Vector) | A method to fetch a vector. | -| StreamGetObject | [.payload.v1.Object.VectorRequest](#payload.v1.Object.VectorRequest) stream | [.payload.v1.Object.StreamVector](#payload.v1.Object.StreamVector) stream | A method to fetch vectors by bidirectional streaming. | +| Exists | [.payload.v1.Object.ID](#payload-v1-Object-ID) | [.payload.v1.Object.ID](#payload-v1-Object-ID) | A method to check whether a specified ID is indexed or not. | +| GetObject | [.payload.v1.Object.VectorRequest](#payload-v1-Object-VectorRequest) | [.payload.v1.Object.Vector](#payload-v1-Object-Vector) | A method to fetch a vector. | +| StreamGetObject | [.payload.v1.Object.VectorRequest](#payload-v1-Object-VectorRequest) stream | [.payload.v1.Object.StreamVector](#payload-v1-Object-StreamVector) stream | A method to fetch vectors by bidirectional streaming. | - +

Top

## apis/proto/v1/vald/remove.proto - + ### Remove @@ -986,17 +986,17 @@ Remove service provides ways to remove indexed vectors. | Method Name | Request Type | Response Type | Description | | ------------ | ------------------------------------------------------------------ | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------- | -| Remove | [.payload.v1.Remove.Request](#payload.v1.Remove.Request) | [.payload.v1.Object.Location](#payload.v1.Object.Location) | A method to remove an indexed vector. | -| StreamRemove | [.payload.v1.Remove.Request](#payload.v1.Remove.Request) stream | [.payload.v1.Object.StreamLocation](#payload.v1.Object.StreamLocation) stream | A method to remove multiple indexed vectors by bidirectional streaming. | -| MultiRemove | [.payload.v1.Remove.MultiRequest](#payload.v1.Remove.MultiRequest) | [.payload.v1.Object.Locations](#payload.v1.Object.Locations) | A method to remove multiple indexed vectors in a single request. | +| Remove | [.payload.v1.Remove.Request](#payload-v1-Remove-Request) | [.payload.v1.Object.Location](#payload-v1-Object-Location) | A method to remove an indexed vector. | +| StreamRemove | [.payload.v1.Remove.Request](#payload-v1-Remove-Request) stream | [.payload.v1.Object.StreamLocation](#payload-v1-Object-StreamLocation) stream | A method to remove multiple indexed vectors by bidirectional streaming. | +| MultiRemove | [.payload.v1.Remove.MultiRequest](#payload-v1-Remove-MultiRequest) | [.payload.v1.Object.Locations](#payload-v1-Object-Locations) | A method to remove multiple indexed vectors in a single request. | - +

Top

## apis/proto/v1/vald/search.proto - + ### Search @@ -1004,26 +1004,26 @@ Search service provides ways to search indexed vectors. | Method Name | Request Type | Response Type | Description | | ---------------------- | ---------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | -| Search | [.payload.v1.Search.Request](#payload.v1.Search.Request) | [.payload.v1.Search.Response](#payload.v1.Search.Response) | A method to search indexed vectors by a raw vector. | -| SearchByID | [.payload.v1.Search.IDRequest](#payload.v1.Search.IDRequest) | [.payload.v1.Search.Response](#payload.v1.Search.Response) | A method to search indexed vectors by ID. | -| StreamSearch | [.payload.v1.Search.Request](#payload.v1.Search.Request) stream | [.payload.v1.Search.StreamResponse](#payload.v1.Search.StreamResponse) stream | A method to search indexed vectors by multiple vectors. | -| StreamSearchByID | [.payload.v1.Search.IDRequest](#payload.v1.Search.IDRequest) stream | [.payload.v1.Search.StreamResponse](#payload.v1.Search.StreamResponse) stream | A method to search indexed vectors by multiple IDs. | -| MultiSearch | [.payload.v1.Search.MultiRequest](#payload.v1.Search.MultiRequest) | [.payload.v1.Search.Responses](#payload.v1.Search.Responses) | A method to search indexed vectors by multiple vectors in a single request. | -| MultiSearchByID | [.payload.v1.Search.MultiIDRequest](#payload.v1.Search.MultiIDRequest) | [.payload.v1.Search.Responses](#payload.v1.Search.Responses) | A method to search indexed vectors by multiple IDs in a single request. | -| LinearSearch | [.payload.v1.Search.Request](#payload.v1.Search.Request) | [.payload.v1.Search.Response](#payload.v1.Search.Response) | A method to linear search indexed vectors by a raw vector. | -| LinearSearchByID | [.payload.v1.Search.IDRequest](#payload.v1.Search.IDRequest) | [.payload.v1.Search.Response](#payload.v1.Search.Response) | A method to linear search indexed vectors by ID. | -| StreamLinearSearch | [.payload.v1.Search.Request](#payload.v1.Search.Request) stream | [.payload.v1.Search.StreamResponse](#payload.v1.Search.StreamResponse) stream | A method to linear search indexed vectors by multiple vectors. | -| StreamLinearSearchByID | [.payload.v1.Search.IDRequest](#payload.v1.Search.IDRequest) stream | [.payload.v1.Search.StreamResponse](#payload.v1.Search.StreamResponse) stream | A method to linear search indexed vectors by multiple IDs. | -| MultiLinearSearch | [.payload.v1.Search.MultiRequest](#payload.v1.Search.MultiRequest) | [.payload.v1.Search.Responses](#payload.v1.Search.Responses) | A method to linear search indexed vectors by multiple vectors in a single request. | -| MultiLinearSearchByID | [.payload.v1.Search.MultiIDRequest](#payload.v1.Search.MultiIDRequest) | [.payload.v1.Search.Responses](#payload.v1.Search.Responses) | A method to linear search indexed vectors by multiple IDs in a single request. | - - +| Search | [.payload.v1.Search.Request](#payload-v1-Search-Request) | [.payload.v1.Search.Response](#payload-v1-Search-Response) | A method to search indexed vectors by a raw vector. | +| SearchByID | [.payload.v1.Search.IDRequest](#payload-v1-Search-IDRequest) | [.payload.v1.Search.Response](#payload-v1-Search-Response) | A method to search indexed vectors by ID. | +| StreamSearch | [.payload.v1.Search.Request](#payload-v1-Search-Request) stream | [.payload.v1.Search.StreamResponse](#payload-v1-Search-StreamResponse) stream | A method to search indexed vectors by multiple vectors. | +| StreamSearchByID | [.payload.v1.Search.IDRequest](#payload-v1-Search-IDRequest) stream | [.payload.v1.Search.StreamResponse](#payload-v1-Search-StreamResponse) stream | A method to search indexed vectors by multiple IDs. | +| MultiSearch | [.payload.v1.Search.MultiRequest](#payload-v1-Search-MultiRequest) | [.payload.v1.Search.Responses](#payload-v1-Search-Responses) | A method to search indexed vectors by multiple vectors in a single request. | +| MultiSearchByID | [.payload.v1.Search.MultiIDRequest](#payload-v1-Search-MultiIDRequest) | [.payload.v1.Search.Responses](#payload-v1-Search-Responses) | A method to search indexed vectors by multiple IDs in a single request. | +| LinearSearch | [.payload.v1.Search.Request](#payload-v1-Search-Request) | [.payload.v1.Search.Response](#payload-v1-Search-Response) | A method to linear search indexed vectors by a raw vector. | +| LinearSearchByID | [.payload.v1.Search.IDRequest](#payload-v1-Search-IDRequest) | [.payload.v1.Search.Response](#payload-v1-Search-Response) | A method to linear search indexed vectors by ID. | +| StreamLinearSearch | [.payload.v1.Search.Request](#payload-v1-Search-Request) stream | [.payload.v1.Search.StreamResponse](#payload-v1-Search-StreamResponse) stream | A method to linear search indexed vectors by multiple vectors. | +| StreamLinearSearchByID | [.payload.v1.Search.IDRequest](#payload-v1-Search-IDRequest) stream | [.payload.v1.Search.StreamResponse](#payload-v1-Search-StreamResponse) stream | A method to linear search indexed vectors by multiple IDs. | +| MultiLinearSearch | [.payload.v1.Search.MultiRequest](#payload-v1-Search-MultiRequest) | [.payload.v1.Search.Responses](#payload-v1-Search-Responses) | A method to linear search indexed vectors by multiple vectors in a single request. | +| MultiLinearSearchByID | [.payload.v1.Search.MultiIDRequest](#payload-v1-Search-MultiIDRequest) | [.payload.v1.Search.Responses](#payload-v1-Search-Responses) | A method to linear search indexed vectors by multiple IDs in a single request. | + +

Top

## apis/proto/v1/vald/update.proto - + ### Update @@ -1031,17 +1031,17 @@ Update service provides ways to update indexed vectors. | Method Name | Request Type | Response Type | Description | | ------------ | ------------------------------------------------------------------ | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------- | -| Update | [.payload.v1.Update.Request](#payload.v1.Update.Request) | [.payload.v1.Object.Location](#payload.v1.Object.Location) | A method to update an indexed vector. | -| StreamUpdate | [.payload.v1.Update.Request](#payload.v1.Update.Request) stream | [.payload.v1.Object.StreamLocation](#payload.v1.Object.StreamLocation) stream | A method to update multiple indexed vectors by bidirectional streaming. | -| MultiUpdate | [.payload.v1.Update.MultiRequest](#payload.v1.Update.MultiRequest) | [.payload.v1.Object.Locations](#payload.v1.Object.Locations) | A method to update multiple indexed vectors in a single request. | +| Update | [.payload.v1.Update.Request](#payload-v1-Update-Request) | [.payload.v1.Object.Location](#payload-v1-Object-Location) | A method to update an indexed vector. | +| StreamUpdate | [.payload.v1.Update.Request](#payload-v1-Update-Request) stream | [.payload.v1.Object.StreamLocation](#payload-v1-Object-StreamLocation) stream | A method to update multiple indexed vectors by bidirectional streaming. | +| MultiUpdate | [.payload.v1.Update.MultiRequest](#payload-v1-Update-MultiRequest) | [.payload.v1.Object.Locations](#payload-v1-Object-Locations) | A method to update multiple indexed vectors in a single request. | - +

Top

## apis/proto/v1/vald/upsert.proto - + ### Upsert @@ -1049,9 +1049,9 @@ Upsert service provides ways to insert/update vectors. | Method Name | Request Type | Response Type | Description | | ------------ | ------------------------------------------------------------------ | ----------------------------------------------------------------------------- | ---------------------------------------------------------------------- | -| Upsert | [.payload.v1.Upsert.Request](#payload.v1.Upsert.Request) | [.payload.v1.Object.Location](#payload.v1.Object.Location) | A method to insert/update a vector. | -| StreamUpsert | [.payload.v1.Upsert.Request](#payload.v1.Upsert.Request) stream | [.payload.v1.Object.StreamLocation](#payload.v1.Object.StreamLocation) stream | A method to insert/update multiple vectors by bidirectional streaming. | -| MultiUpsert | [.payload.v1.Upsert.MultiRequest](#payload.v1.Upsert.MultiRequest) | [.payload.v1.Object.Locations](#payload.v1.Object.Locations) | A method to insert/update multiple vectors in a single request. | +| Upsert | [.payload.v1.Upsert.Request](#payload-v1-Upsert-Request) | [.payload.v1.Object.Location](#payload-v1-Object-Location) | A method to insert/update a vector. | +| StreamUpsert | [.payload.v1.Upsert.Request](#payload-v1-Upsert-Request) stream | [.payload.v1.Object.StreamLocation](#payload-v1-Object-StreamLocation) stream | A method to insert/update multiple vectors by bidirectional streaming. | +| MultiUpsert | [.payload.v1.Upsert.MultiRequest](#payload-v1-Upsert-MultiRequest) | [.payload.v1.Object.Locations](#payload-v1-Object-Locations) | A method to insert/update multiple vectors in a single request. | ## Scalar Value Types diff --git a/apis/grpc/v1/agent/core/agent.pb.go b/apis/grpc/v1/agent/core/agent.pb.go index 950cab5b6d..9b9ff65eed 100644 --- a/apis/grpc/v1/agent/core/agent.pb.go +++ b/apis/grpc/v1/agent/core/agent.pb.go @@ -17,7 +17,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v3.21.9 +// protoc v3.21.11 // source: apis/proto/v1/agent/core/agent.proto package core diff --git a/apis/grpc/v1/agent/sidecar/sidecar.pb.go b/apis/grpc/v1/agent/sidecar/sidecar.pb.go index 1826acdd65..6ba405acee 100644 --- a/apis/grpc/v1/agent/sidecar/sidecar.pb.go +++ b/apis/grpc/v1/agent/sidecar/sidecar.pb.go @@ -17,7 +17,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v3.21.9 +// protoc v3.21.11 // source: apis/proto/v1/agent/sidecar/sidecar.proto package sidecar diff --git a/apis/grpc/v1/discoverer/discoverer.pb.go b/apis/grpc/v1/discoverer/discoverer.pb.go index a87f8b9388..f36874a8d0 100644 --- a/apis/grpc/v1/discoverer/discoverer.pb.go +++ b/apis/grpc/v1/discoverer/discoverer.pb.go @@ -17,7 +17,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v3.21.9 +// protoc v3.21.11 // source: apis/proto/v1/discoverer/discoverer.proto package discoverer diff --git a/apis/grpc/v1/filter/egress/egress_filter.pb.go b/apis/grpc/v1/filter/egress/egress_filter.pb.go index 1a167e6ffa..a736aaa267 100644 --- a/apis/grpc/v1/filter/egress/egress_filter.pb.go +++ b/apis/grpc/v1/filter/egress/egress_filter.pb.go @@ -17,7 +17,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v3.21.9 +// protoc v3.21.11 // source: apis/proto/v1/filter/egress/egress_filter.proto package egress diff --git a/apis/grpc/v1/filter/ingress/ingress_filter.pb.go b/apis/grpc/v1/filter/ingress/ingress_filter.pb.go index 2cdb078d95..4b23bcebbb 100644 --- a/apis/grpc/v1/filter/ingress/ingress_filter.pb.go +++ b/apis/grpc/v1/filter/ingress/ingress_filter.pb.go @@ -17,7 +17,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v3.21.9 +// protoc v3.21.11 // source: apis/proto/v1/filter/ingress/ingress_filter.proto package ingress diff --git a/apis/grpc/v1/manager/index/index_manager.pb.go b/apis/grpc/v1/manager/index/index_manager.pb.go index 78f2d63662..3453a8956c 100644 --- a/apis/grpc/v1/manager/index/index_manager.pb.go +++ b/apis/grpc/v1/manager/index/index_manager.pb.go @@ -17,7 +17,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v3.21.9 +// protoc v3.21.11 // source: apis/proto/v1/manager/index/index_manager.proto package index diff --git a/apis/grpc/v1/payload/payload.pb.go b/apis/grpc/v1/payload/payload.pb.go index 2e35b671a9..f7a3a020f5 100644 --- a/apis/grpc/v1/payload/payload.pb.go +++ b/apis/grpc/v1/payload/payload.pb.go @@ -17,7 +17,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v3.21.9 +// protoc v3.21.11 // source: apis/proto/v1/payload/payload.proto package payload diff --git a/apis/grpc/v1/vald/filter.pb.go b/apis/grpc/v1/vald/filter.pb.go index f96eab2004..54e25fcd93 100644 --- a/apis/grpc/v1/vald/filter.pb.go +++ b/apis/grpc/v1/vald/filter.pb.go @@ -17,7 +17,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v3.21.9 +// protoc v3.21.11 // source: apis/proto/v1/vald/filter.proto package vald diff --git a/apis/grpc/v1/vald/insert.pb.go b/apis/grpc/v1/vald/insert.pb.go index ccf2f30daf..9f2e363c53 100644 --- a/apis/grpc/v1/vald/insert.pb.go +++ b/apis/grpc/v1/vald/insert.pb.go @@ -17,7 +17,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v3.21.9 +// protoc v3.21.11 // source: apis/proto/v1/vald/insert.proto package vald diff --git a/apis/grpc/v1/vald/object.pb.go b/apis/grpc/v1/vald/object.pb.go index cd1c3f90de..5cc3983af9 100644 --- a/apis/grpc/v1/vald/object.pb.go +++ b/apis/grpc/v1/vald/object.pb.go @@ -17,7 +17,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v3.21.9 +// protoc v3.21.11 // source: apis/proto/v1/vald/object.proto package vald diff --git a/apis/grpc/v1/vald/remove.pb.go b/apis/grpc/v1/vald/remove.pb.go index 682806bbde..c84c84f2a0 100644 --- a/apis/grpc/v1/vald/remove.pb.go +++ b/apis/grpc/v1/vald/remove.pb.go @@ -17,7 +17,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v3.21.9 +// protoc v3.21.11 // source: apis/proto/v1/vald/remove.proto package vald diff --git a/apis/grpc/v1/vald/search.pb.go b/apis/grpc/v1/vald/search.pb.go index aadaf00c3f..2a5dbacbb1 100644 --- a/apis/grpc/v1/vald/search.pb.go +++ b/apis/grpc/v1/vald/search.pb.go @@ -17,7 +17,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v3.21.9 +// protoc v3.21.11 // source: apis/proto/v1/vald/search.proto package vald diff --git a/apis/grpc/v1/vald/update.pb.go b/apis/grpc/v1/vald/update.pb.go index cd0d4cab7d..fb43e1eed2 100644 --- a/apis/grpc/v1/vald/update.pb.go +++ b/apis/grpc/v1/vald/update.pb.go @@ -17,7 +17,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v3.21.9 +// protoc v3.21.11 // source: apis/proto/v1/vald/update.proto package vald diff --git a/apis/grpc/v1/vald/upsert.pb.go b/apis/grpc/v1/vald/upsert.pb.go index 0b207b11c5..721e9aee44 100644 --- a/apis/grpc/v1/vald/upsert.pb.go +++ b/apis/grpc/v1/vald/upsert.pb.go @@ -17,7 +17,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v3.21.9 +// protoc v3.21.11 // source: apis/proto/v1/vald/upsert.proto package vald diff --git a/dockers/agent/core/ngt/Dockerfile b/dockers/agent/core/ngt/Dockerfile index f3a5c95429..eb34578484 100644 --- a/dockers/agent/core/ngt/Dockerfile +++ b/dockers/agent/core/ngt/Dockerfile @@ -41,12 +41,15 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates \ build-essential \ cmake \ - upx \ curl \ - unzip \ - git \ - gcc \ g++ \ + gcc \ + git \ + liblapack-dev \ + libomp-dev \ + libopenblas-dev \ + unzip \ + upx \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* diff --git a/dockers/ci/base/Dockerfile b/dockers/ci/base/Dockerfile index 940c77bfad..8b8d2c59af 100644 --- a/dockers/ci/base/Dockerfile +++ b/dockers/ci/base/Dockerfile @@ -48,6 +48,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ graphviz \ jq \ libhdf5-dev \ + liblapack-dev \ + libomp-dev \ + libopenblas-dev \ nodejs \ npm \ sed \ diff --git a/dockers/dev/Dockerfile b/dockers/dev/Dockerfile index 2a264f2c7f..bc3e924d2b 100644 --- a/dockers/dev/Dockerfile +++ b/dockers/dev/Dockerfile @@ -37,18 +37,21 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ cmake \ curl \ - libhdf5-dev \ g++ \ gawk \ gcc \ git \ graphviz \ + jq \ + libhdf5-dev \ + liblapack-dev \ + libomp-dev \ + libopenblas-dev \ nodejs \ npm \ - jq \ sed \ - zip \ unzip \ + zip \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* diff --git a/example/client/go.mod b/example/client/go.mod index 7d5b8d2e51..24ddb7eb9d 100644 --- a/example/client/go.mod +++ b/example/client/go.mod @@ -8,10 +8,10 @@ replace ( github.com/golang/protobuf => github.com/golang/protobuf v1.5.2 github.com/kpango/glg => github.com/kpango/glg v1.6.14 github.com/pkg/sftp => github.com/pkg/sftp v1.13.5 - golang.org/x/crypto => golang.org/x/crypto v0.3.0 - golang.org/x/net => golang.org/x/net v0.3.0 + golang.org/x/crypto => golang.org/x/crypto v0.4.0 + golang.org/x/net => golang.org/x/net v0.4.0 golang.org/x/text => golang.org/x/text v0.5.0 - google.golang.org/genproto => google.golang.org/genproto v0.0.0-20221205194025-8222ab48f5fc + google.golang.org/genproto => google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 google.golang.org/grpc => google.golang.org/grpc v1.51.0 google.golang.org/protobuf => google.golang.org/protobuf v1.28.1 gopkg.in/yaml.v2 => gopkg.in/yaml.v2 v2.4.0 @@ -23,7 +23,7 @@ require ( github.com/kpango/glg v1.6.14 github.com/vdaas/vald-client-go v1.6.3 gonum.org/v1/hdf5 v0.0.0-20210714002203-8c5d23bc6946 - google.golang.org/grpc v1.50.1 + google.golang.org/grpc v1.51.0 ) require ( diff --git a/example/client/go.sum b/example/client/go.sum index 07d4abf337..8902f8b245 100644 --- a/example/client/go.sum +++ b/example/client/go.sum @@ -18,8 +18,8 @@ github.com/vdaas/vald-client-go v1.6.3/go.mod h1:WiE3uVM1gjAEi4wbQi3S7lwfASR4BMi go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/zap v1.23.0 h1:OjGQ5KQDEUawVHxNwQgPpiypGHOxo2mNZsOqTak4fFY= -golang.org/x/net v0.3.0 h1:VWL6FNY2bEEmsGVKabSlHu5Irp34xmMRoqb/9lF9lxk= -golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= +golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU= +golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM= @@ -28,8 +28,8 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= gonum.org/v1/hdf5 v0.0.0-20210714002203-8c5d23bc6946 h1:vJpL69PeUullhJyKtTjHjENEmZU3BkO4e+fod7nKzgM= gonum.org/v1/hdf5 v0.0.0-20210714002203-8c5d23bc6946/go.mod h1:BQUWDHIAygjdt1HnUPQ0eWqLN2n5FwJycrpYUVUOx2I= -google.golang.org/genproto v0.0.0-20221205194025-8222ab48f5fc h1:nUKKji0AarrQKh6XpFEpG3p1TNztxhe7C8TcUvDgXqw= -google.golang.org/genproto v0.0.0-20221205194025-8222ab48f5fc/go.mod h1:1dOng4TWOomJrDGhpXjfCD35wQC6jnC7HpRmOFRqEV0= +google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 h1:jmIfw8+gSvXcZSgaFAGyInDXeWzUhvYH57G/5GKMn70= +google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= google.golang.org/grpc v1.51.0 h1:E1eGv1FTqoLIdnBCZufiSHgKjlqG6fKFf6pPWtMTh8U= google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= diff --git a/go.mod b/go.mod index 2829c098c8..60c31c5472 100755 --- a/go.mod +++ b/go.mod @@ -60,13 +60,13 @@ replace ( github.com/armon/go-radix => github.com/armon/go-radix v1.0.0 github.com/armon/go-socks5 => github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 github.com/asaskevich/govalidator => github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d - github.com/aws/aws-sdk-go => github.com/aws/aws-sdk-go v1.44.162 + github.com/aws/aws-sdk-go => github.com/aws/aws-sdk-go v1.44.167 github.com/aws/aws-sdk-go-v2 => github.com/aws/aws-sdk-go-v2 v1.17.3 github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream => github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 - github.com/aws/aws-sdk-go-v2/config => github.com/aws/aws-sdk-go-v2/config v1.18.5 - github.com/aws/aws-sdk-go-v2/credentials => github.com/aws/aws-sdk-go-v2/credentials v1.13.5 + github.com/aws/aws-sdk-go-v2/config => github.com/aws/aws-sdk-go-v2/config v1.18.7 + github.com/aws/aws-sdk-go-v2/credentials => github.com/aws/aws-sdk-go-v2/credentials v1.13.7 github.com/aws/aws-sdk-go-v2/feature/ec2/imds => github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.21 - github.com/aws/aws-sdk-go-v2/feature/s3/manager => github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.44 + github.com/aws/aws-sdk-go-v2/feature/s3/manager => github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.46 github.com/aws/aws-sdk-go-v2/internal/configsources => github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.27 github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 => github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.21 github.com/aws/aws-sdk-go-v2/internal/ini => github.com/aws/aws-sdk-go-v2/internal/ini v1.3.28 @@ -76,11 +76,11 @@ replace ( github.com/aws/aws-sdk-go-v2/service/internal/s3shared => github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.13.21 github.com/aws/aws-sdk-go-v2/service/kms => github.com/aws/aws-sdk-go-v2/service/kms v1.19.4 github.com/aws/aws-sdk-go-v2/service/s3 => github.com/aws/aws-sdk-go-v2/service/s3 v1.29.6 - github.com/aws/aws-sdk-go-v2/service/secretsmanager => github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.16.10 + github.com/aws/aws-sdk-go-v2/service/secretsmanager => github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.16.11 github.com/aws/aws-sdk-go-v2/service/sns => github.com/aws/aws-sdk-go-v2/service/sns v1.18.8 github.com/aws/aws-sdk-go-v2/service/sqs => github.com/aws/aws-sdk-go-v2/service/sqs v1.19.17 - github.com/aws/aws-sdk-go-v2/service/ssm => github.com/aws/aws-sdk-go-v2/service/ssm v1.33.3 - github.com/aws/aws-sdk-go-v2/service/sso => github.com/aws/aws-sdk-go-v2/service/sso v1.11.27 + github.com/aws/aws-sdk-go-v2/service/ssm => github.com/aws/aws-sdk-go-v2/service/ssm v1.33.4 + github.com/aws/aws-sdk-go-v2/service/sso => github.com/aws/aws-sdk-go-v2/service/sso v1.11.28 github.com/aws/aws-sdk-go-v2/service/sts => github.com/aws/aws-sdk-go-v2/service/sts v1.17.7 github.com/aws/smithy-go => github.com/aws/smithy-go v1.13.5 github.com/benbjohnson/clock => github.com/benbjohnson/clock v1.3.0 @@ -110,7 +110,7 @@ replace ( github.com/containerd/btrfs => github.com/containerd/btrfs v1.0.0 github.com/containerd/cgroups => github.com/containerd/cgroups v1.0.4 github.com/containerd/console => github.com/containerd/console v1.0.3 - github.com/containerd/containerd => github.com/containerd/containerd v1.6.13 + github.com/containerd/containerd => github.com/containerd/containerd v1.6.14 github.com/containerd/continuity => github.com/containerd/continuity v0.3.0 github.com/containerd/fifo => github.com/containerd/fifo v1.0.0 github.com/containerd/go-cni => github.com/containerd/go-cni v1.1.7 @@ -170,7 +170,7 @@ replace ( github.com/fsnotify/fsnotify => github.com/fsnotify/fsnotify v1.6.0 github.com/ghodss/yaml => github.com/ghodss/yaml v1.0.0 github.com/gin-contrib/sse => github.com/gin-contrib/sse v0.1.0 - github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.8.1 + github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.8.2 github.com/go-errors/errors => github.com/go-errors/errors v1.4.2 github.com/go-fonts/dejavu => github.com/go-fonts/dejavu v0.1.0 github.com/go-fonts/latin-modern => github.com/go-fonts/latin-modern v0.2.0 @@ -213,7 +213,7 @@ replace ( github.com/gobwas/pool => github.com/gobwas/pool v0.2.1 github.com/gobwas/ws => github.com/gobwas/ws v1.1.0 github.com/goccy/go-json => github.com/goccy/go-json v0.10.0 - github.com/goccy/go-yaml => github.com/goccy/go-yaml v1.9.7 + github.com/goccy/go-yaml => github.com/goccy/go-yaml v1.9.8 github.com/gocql/gocql => github.com/gocql/gocql v1.3.1 github.com/gocraft/dbr/v2 => github.com/gocraft/dbr/v2 v2.7.3 github.com/godbus/dbus/v5 => github.com/godbus/dbus/v5 v5.1.0 @@ -239,7 +239,7 @@ replace ( github.com/google/gofuzz => github.com/google/gofuzz v1.2.0 github.com/google/martian => github.com/google/martian v2.1.0+incompatible github.com/google/martian/v3 => github.com/google/martian/v3 v3.3.2 - github.com/google/pprof => github.com/google/pprof v0.0.0-20221212185716-aee1124e3a93 + github.com/google/pprof => github.com/google/pprof v0.0.0-20221219190121-3cb0bae90811 github.com/google/shlex => github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 github.com/google/subcommands => github.com/google/subcommands v1.2.0 github.com/google/uuid => github.com/google/uuid v1.3.0 @@ -256,7 +256,7 @@ replace ( github.com/grpc-ecosystem/go-grpc-middleware => github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 github.com/grpc-ecosystem/go-grpc-prometheus => github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 github.com/grpc-ecosystem/grpc-gateway => github.com/grpc-ecosystem/grpc-gateway v1.16.0 - github.com/grpc-ecosystem/grpc-gateway/v2 => github.com/grpc-ecosystem/grpc-gateway/v2 v2.14.0 + github.com/grpc-ecosystem/grpc-gateway/v2 => github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0 github.com/hailocab/go-hostpool => github.com/kpango/go-hostpool v0.0.0-20210303030322-aab80263dcd0 github.com/hanwen/go-fuse => github.com/hanwen/go-fuse v1.0.0 github.com/hanwen/go-fuse/v2 => github.com/hanwen/go-fuse/v2 v2.2.0 @@ -308,7 +308,7 @@ replace ( github.com/julienschmidt/httprouter => github.com/julienschmidt/httprouter v1.3.0 github.com/kisielk/errcheck => github.com/kisielk/errcheck v1.6.2 github.com/kisielk/gotool => github.com/kisielk/gotool v1.0.0 - github.com/klauspost/compress => github.com/klauspost/compress v1.15.14-0.20221213101442-1f355e838e87 + github.com/klauspost/compress => github.com/klauspost/compress v1.15.14-0.20221219154243-272fbc74c600 github.com/klauspost/cpuid/v2 => github.com/klauspost/cpuid/v2 v2.2.2 github.com/kolo/xmlrpc => github.com/kolo/xmlrpc v0.0.0-20220921171641-a4b6fa1dd06b github.com/kpango/fastime => github.com/kpango/fastime v1.1.6 @@ -323,7 +323,7 @@ replace ( github.com/leodido/go-urn => github.com/leodido/go-urn v1.2.1 github.com/lib/pq => github.com/lib/pq v1.10.7 github.com/liggitt/tabwriter => github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de - github.com/linode/linodego => github.com/linode/linodego v1.9.3 + github.com/linode/linodego => github.com/linode/linodego v1.10.0 github.com/linuxkit/virtsock => github.com/linuxkit/virtsock v0.0.0-20220523201153-1a23e78aa7a2 github.com/lucasb-eyer/go-colorful => github.com/lucasb-eyer/go-colorful v1.2.0 github.com/lyft/protoc-gen-star => github.com/lyft/protoc-gen-star v0.6.2 @@ -383,14 +383,14 @@ replace ( github.com/posener/complete => github.com/posener/complete v1.2.3 github.com/pquerna/cachecontrol => github.com/pquerna/cachecontrol v0.1.0 github.com/prashantv/gostub => github.com/prashantv/gostub v1.1.0 - github.com/prometheus/alertmanager => github.com/prometheus/alertmanager v0.24.0 + github.com/prometheus/alertmanager => github.com/prometheus/alertmanager v0.25.0 github.com/prometheus/client_golang => github.com/prometheus/client_golang v1.14.0 github.com/prometheus/client_model => github.com/prometheus/client_model v0.3.0 github.com/prometheus/common => github.com/prometheus/common v0.39.0 github.com/prometheus/common/assets => github.com/prometheus/common/assets v0.2.0 github.com/prometheus/common/sigv4 => github.com/prometheus/common/sigv4 v0.1.0 github.com/prometheus/exporter-toolkit => github.com/prometheus/exporter-toolkit v0.8.2 - github.com/prometheus/procfs => github.com/prometheus/procfs v0.8.0 + github.com/prometheus/procfs => github.com/prometheus/procfs v0.9.0 github.com/prometheus/prometheus => github.com/prometheus/prometheus v1.99.0 github.com/prometheus/prometheus/v2 => github.com/prometheus/prometheus/v2 v2.35.0-retract github.com/quasilyte/go-ruleguard => github.com/quasilyte/go-ruleguard v0.3.18 @@ -486,8 +486,8 @@ replace ( go4.org/unsafe/assume-no-moving-gc => go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760 gocloud.dev => gocloud.dev v0.27.0 golang.org/x/crypto => golang.org/x/crypto v0.4.0 - golang.org/x/exp => golang.org/x/exp v0.0.0-20221215174704-0915cd710c24 - golang.org/x/exp/typeparams => golang.org/x/exp/typeparams v0.0.0-20221215174704-0915cd710c24 + golang.org/x/exp => golang.org/x/exp v0.0.0-20221217163422-3c43f8badb15 + golang.org/x/exp/typeparams => golang.org/x/exp/typeparams v0.0.0-20221217163422-3c43f8badb15 golang.org/x/image => golang.org/x/image v0.2.0 golang.org/x/lint => golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 golang.org/x/mobile => golang.org/x/mobile v0.0.0-20221110043201-43a038452099 @@ -543,7 +543,7 @@ replace ( k8s.io/metrics => k8s.io/metrics v0.26.0 nhooyr.io/websocket => nhooyr.io/websocket v1.8.7 rsc.io/pdf => rsc.io/pdf v0.1.1 - sigs.k8s.io/apiserver-network-proxy/konnectivity-client => sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.33 + sigs.k8s.io/apiserver-network-proxy/konnectivity-client => sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.34 sigs.k8s.io/controller-runtime => sigs.k8s.io/controller-runtime v0.14.0 sigs.k8s.io/json => sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd sigs.k8s.io/kustomize => sigs.k8s.io/kustomize v2.0.3+incompatible @@ -563,6 +563,7 @@ require ( github.com/gocql/gocql v0.0.0-20200131111108-92af2e088537 github.com/gocraft/dbr/v2 v2.0.0-00010101000000-000000000000 github.com/google/go-cmp v0.5.9 + github.com/google/uuid v1.3.0 github.com/gorilla/mux v0.0.0-00010101000000-000000000000 github.com/hashicorp/go-version v0.0.0-00010101000000-000000000000 github.com/klauspost/compress v1.15.1 @@ -599,7 +600,7 @@ require ( golang.org/x/tools v0.4.0 gonum.org/v1/hdf5 v0.0.0-00010101000000-000000000000 gonum.org/v1/plot v0.0.0-00010101000000-000000000000 - google.golang.org/genproto v0.0.0-20221206210731-b1a01be3a5f6 + google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 google.golang.org/grpc v1.51.0 google.golang.org/protobuf v1.28.1 gopkg.in/yaml.v2 v2.4.0 @@ -647,7 +648,6 @@ require ( github.com/google/gnostic v0.5.7-v3refs // indirect github.com/google/gofuzz v1.1.0 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect - github.com/google/uuid v1.3.0 // indirect github.com/google/wire v0.5.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.0 // indirect github.com/googleapis/gax-go/v2 v2.7.0 // indirect diff --git a/go.sum b/go.sum index 9f9065e622..6937137e83 100644 --- a/go.sum +++ b/go.sum @@ -183,20 +183,20 @@ github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b/go.mod h1:1KcenG0jGW github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= -github.com/aws/aws-sdk-go v1.44.162 h1:hKAd+X+/BLxVMzH+4zKxbQcQQGrk2UhFX0OTu1Mhon8= -github.com/aws/aws-sdk-go v1.44.162/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.167 h1:kQmBhGdZkQLU7AiHShSkBJ15zr8agy0QeaxXduvyp2E= +github.com/aws/aws-sdk-go v1.44.167/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.17.3 h1:shN7NlnVzvDUgPQ+1rLMSxY8OWRNDRYtiqe0p/PgrhY= github.com/aws/aws-sdk-go-v2 v1.17.3/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 h1:dK82zF6kkPeCo8J1e+tGx4JdvDIQzj7ygIoLg8WMuGs= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10/go.mod h1:VeTZetY5KRJLuD/7fkQXMU6Mw7H5m/KP2J5Iy9osMno= -github.com/aws/aws-sdk-go-v2/config v1.18.5 h1:teGdDCAT3gX99FIKNt6HsvLaeOVdCFiCQDlH8UV6Xvg= -github.com/aws/aws-sdk-go-v2/config v1.18.5/go.mod h1:0g4tGVHeUTxekZIkO5Glw2AemETlmnkQvFqkdv3HBAA= -github.com/aws/aws-sdk-go-v2/credentials v1.13.5 h1:vrPwnKCdQlUyxXDZtPpb6Hc3GbTndqaGtEOwm/lF5tI= -github.com/aws/aws-sdk-go-v2/credentials v1.13.5/go.mod h1:sS/NgdbdkQ6XhVkGY/yEmNwxzpRVxLT3Ns+42W37p6g= +github.com/aws/aws-sdk-go-v2/config v1.18.7 h1:V94lTcix6jouwmAsgQMAEBozVAGJMFhVj+6/++xfe3E= +github.com/aws/aws-sdk-go-v2/config v1.18.7/go.mod h1:OZYsyHFL5PB9UpyS78NElgKs11qI/B5KJau2XOJDXHA= +github.com/aws/aws-sdk-go-v2/credentials v1.13.7 h1:qUUcNS5Z1092XBFT66IJM7mYkMwgZ8fcC8YDIbEwXck= +github.com/aws/aws-sdk-go-v2/credentials v1.13.7/go.mod h1:AdCcbZXHQCjJh6NaH3pFaw8LUeBFn5+88BZGMVGuBT8= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.21 h1:j9wi1kQ8b+e0FBVHxCqCGo4kxDU175hoDHcWAi0sauU= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.21/go.mod h1:ugwW57Z5Z48bpvUyZuaPy4Kv+vEfJWnIrky7RmkBvJg= -github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.44 h1:BXBHQeRh4fGFiiMZZd/WI/aAPwjhUCrWDhRDbuOZPIM= -github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.44/go.mod h1:yFjq/63PmWzfzHk66kMsouDqS/ilrjFKWu269GWE6iw= +github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.46 h1:OCX1pQ4pcqhsDV7B92HzdLWjHWOQsILvjLinpaUWhcc= +github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.46/go.mod h1:MxCBOcyNXGJRvfpPiH+L6n/BF9zbowthGSUZdDvQF/c= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.27 h1:I3cakv2Uy1vNmmhRQmFptYDxOvBnwCdNwyw63N0RaRU= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.27/go.mod h1:a1/UpzeyBBerajpnP5nGZa9mGzsBn5cOKxm6NWQsvoI= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.21 h1:5NbbMrIzmUn/TXFqAle6mgrH5m9cOvMLRGL7pnG8tRE= @@ -216,14 +216,14 @@ github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.13.21/go.mod h1:WZvNXT github.com/aws/aws-sdk-go-v2/service/kms v1.19.4/go.mod h1:13sjgMH7Xu4e46+0BEDhSnNh+cImHSYS5PpBjV3oXcU= github.com/aws/aws-sdk-go-v2/service/s3 v1.29.6 h1:W8pLcSn6Uy0eXgDBUUl8M8Kxv7JCoP68ZKTD04OXLEA= github.com/aws/aws-sdk-go-v2/service/s3 v1.29.6/go.mod h1:L2l2/q76teehcW7YEsgsDjqdsDTERJeX3nOMIFlgGUE= -github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.16.10/go.mod h1:jAeo/PdIJZuDSwsvxJS94G4d6h8tStj7WXVuKwLHWU8= +github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.16.11/go.mod h1:jAeo/PdIJZuDSwsvxJS94G4d6h8tStj7WXVuKwLHWU8= github.com/aws/aws-sdk-go-v2/service/sns v1.18.8/go.mod h1:iTh9DgwDnFqF5LfFHNXWAxLe9zV0/XcWaMCWXIRDqXA= github.com/aws/aws-sdk-go-v2/service/sqs v1.19.17/go.mod h1:jQhN5f4p3PALMNlUtfb/0wGIFlV7vGtJlPDVfxfNfPY= -github.com/aws/aws-sdk-go-v2/service/ssm v1.33.3/go.mod h1:Hf7wSogKP1XCJ9GgW8erZDL6IZ1NLwLN7bYdV/Gn/LI= -github.com/aws/aws-sdk-go-v2/service/sso v1.11.27 h1:Nmvn0DJKg00TBmoBweK253Kdsuy4V5Rs68yL/H15uBQ= -github.com/aws/aws-sdk-go-v2/service/sso v1.11.27/go.mod h1:wo/B7uUm/7zw/dWhBJ4FXuw1sySU5lyIhVg1Bu2yL9A= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.10 h1:tGOUUjINuqI8sD6pn+Ku0/f/4UfRDlK+jJUOaxEbWuQ= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.10/go.mod h1:TZSH7xLO7+phDtViY/KUp9WGCJMQkLJ/VpgkTFd5gh8= +github.com/aws/aws-sdk-go-v2/service/ssm v1.33.4/go.mod h1:Hf7wSogKP1XCJ9GgW8erZDL6IZ1NLwLN7bYdV/Gn/LI= +github.com/aws/aws-sdk-go-v2/service/sso v1.11.28 h1:gItLq3zBYyRDPmqAClgzTH8PBjDQGeyptYGHIwtYYNA= +github.com/aws/aws-sdk-go-v2/service/sso v1.11.28/go.mod h1:wo/B7uUm/7zw/dWhBJ4FXuw1sySU5lyIhVg1Bu2yL9A= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.11 h1:KCacyVSs/wlcPGx37hcbT3IGYO8P8Jx+TgSDhAXtQMY= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.11/go.mod h1:TZSH7xLO7+phDtViY/KUp9WGCJMQkLJ/VpgkTFd5gh8= github.com/aws/aws-sdk-go-v2/service/sts v1.17.7 h1:9Mtq1KM6nD8/+HStvWcvYnixJ5N85DX+P+OY3kI3W2k= github.com/aws/aws-sdk-go-v2/service/sts v1.17.7/go.mod h1:+lGbb3+1ugwKrNTWcf2RT05Xmp543B06zDFTwiTLp7I= github.com/aws/smithy-go v1.13.5 h1:hgz0X/DX0dGqTYpGALqXJoRKRj5oQ7150i5FdTePzO8= @@ -286,7 +286,7 @@ github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4 github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/fyne-io/mobile v0.1.2/go.mod h1:/kOrWrZB6sasLbEy2JIvr4arEzQTXBTZGb3Y96yWbHY= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= +github.com/gin-gonic/gin v1.8.2/go.mod h1:qw5AYuDrzRTnhvusDsrov+fDIxp9Dleuu12h8nfB398= github.com/gioui/uax v0.2.1-0.20220325163150-e3d987515a12/go.mod h1:kDhBRTA/i3H46PVdhqcw26TdGSIj42TOKNWKY+Kipnw= github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= @@ -381,7 +381,7 @@ github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPg github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.3.2 h1:IqNFLAmvJOgVlpdEBiQbDc2EwKW77amAycfTuWKdfvw= github.com/google/martian/v3 v3.3.2/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= -github.com/google/pprof v0.0.0-20221212185716-aee1124e3a93/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo= +github.com/google/pprof v0.0.0-20221219190121-3cb0bae90811/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= @@ -400,8 +400,8 @@ github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB7 github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 h1:+ngKgrYPPJrOjhax5N+uePQ0Fh1Z7PheYoUI/0nzkPA= github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.14.0 h1:t7uX3JBHdVwAi3G7sSSdbsk8NfgA+LnUS88V/2EKaA0= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.14.0/go.mod h1:4OGVnY4qf2+gw+ssiHbW+pq4mo2yko94YxxMmXZ7jCA= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0 h1:1JYBfzqrWPcCclBwxFCPAou9n+q86mfnu7NAeHfte7A= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0/go.mod h1:YDZoGHuwE+ov0c8smSH49WLF3F2LaWnYYuDVd+EWrc0= github.com/hanwen/go-fuse/v2 v2.2.0/go.mod h1:B1nGE/6RBFyBRC1RRnf23UpwCdyJ31eukw34oAKukAc= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= @@ -437,8 +437,8 @@ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHm github.com/jstemmer/go-junit-report v1.0.0/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/kisielk/errcheck v1.6.2/go.mod h1:nXw/i/MfnvRHqXa7XXmQMUB0oNFGuBrNI8d8NLy0LPw= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.15.14-0.20221213101442-1f355e838e87 h1:yZGrmRQR4ju5ja96AB9MPHYkwoodBre49bpWBp93wlg= -github.com/klauspost/compress v1.15.14-0.20221213101442-1f355e838e87/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= +github.com/klauspost/compress v1.15.14-0.20221219154243-272fbc74c600 h1:D8nziFSzb1WUvz6fxSccsNOJoQj94Gw4vF3e+6O84GQ= +github.com/klauspost/compress v1.15.14-0.20221219154243-272fbc74c600/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= github.com/klauspost/cpuid/v2 v2.2.2 h1:xPMwiykqNK9VK0NYC3+jTMYv9I6Vl3YdjZgPZKG3zO0= github.com/klauspost/cpuid/v2 v2.2.2/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= github.com/kpango/fastime v1.1.6 h1:lAw1Tiwnlbsx1xZs6W9eM7/8niwabknewbmLkh/yTVo= @@ -502,7 +502,7 @@ github.com/onsi/ginkgo/v2 v2.6.1 h1:1xQPCjcqYw/J5LchOcp4/2q/jzJFjiAOc25chhnDw+Q= github.com/onsi/ginkgo/v2 v2.6.1/go.mod h1:yjiuMwPokqY1XauOgju45q3sJt6VzQ/Fict1LFVcsAo= github.com/onsi/gomega v1.24.2 h1:J/tulyYK6JwBldPViHJReihxxZ+22FHs0piGjQAvoUE= github.com/onsi/gomega v1.24.2/go.mod h1:gs3J10IS7Z7r7eXRoNJIrNqU4ToQukCJhFtKrWgHWnk= -github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= +github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek= github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY= @@ -524,8 +524,8 @@ github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvq github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= github.com/prometheus/common v0.39.0 h1:oOyhkDq05hPZKItWVBkJ6g6AtGxi+fy7F4JvUV8uhsI= github.com/prometheus/common v0.39.0/go.mod h1:6XBZ7lYdLCbkAVhwRsWTZn+IN5AB9F/NXd5w0BbEX0Y= -github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= -github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= +github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= +github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= github.com/prometheus/prometheus v1.99.0/go.mod h1:Sw35iJlN8dvKz51BtqxhXpNLIfqNn9IFAo64r7XL9Bw= github.com/quasilyte/go-ruleguard v0.3.18 h1:sd+abO1PEI9fkYennwzHn9kl3nqP6M5vE7FiOzZ+5CE= github.com/quasilyte/go-ruleguard v0.3.18/go.mod h1:lOIzcYlgxrQ2sGJ735EHXmf/e9MJ516j16K/Ifcttvs= @@ -628,10 +628,10 @@ gocloud.dev v0.27.0 h1:j0WTUsnKTxCsWO7y8T+YCiBZUmLl9w/WIowqAY3yo0g= gocloud.dev v0.27.0/go.mod h1:YlYKhYsY5/1JdHGWQDkAuqkezVKowu7qbe9aIeUF6p0= golang.org/x/crypto v0.4.0 h1:UVQgzMY87xqpKNgb+kDsll2Igd33HszWHFLmpaRMq/8= golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80= -golang.org/x/exp v0.0.0-20221215174704-0915cd710c24 h1:6w3iSY8IIkp5OQtbYj8NeuKG1jS9d+kYaubXqsoOiQ8= -golang.org/x/exp v0.0.0-20221215174704-0915cd710c24/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= -golang.org/x/exp/typeparams v0.0.0-20221215174704-0915cd710c24 h1:+iZuikSm1jIhtO1dsw9jQcYCoGFEDDVXp236qRsnqK4= -golang.org/x/exp/typeparams v0.0.0-20221215174704-0915cd710c24/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= +golang.org/x/exp v0.0.0-20221217163422-3c43f8badb15 h1:5oN1Pz/eDhCpbMbLstvIPa0b/BEQo6g6nwV3pLjfM6w= +golang.org/x/exp v0.0.0-20221217163422-3c43f8badb15/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/exp/typeparams v0.0.0-20221217163422-3c43f8badb15 h1:WumQqbro49zP5y7xSPDDdBZBwiUrWNZ7ZbKUQst9RiA= +golang.org/x/exp/typeparams v0.0.0-20221217163422-3c43f8badb15/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/image v0.2.0 h1:/DcQ0w3VHKCC5p0/P2B0JpAZ9Z++V2KOo2fyU89CXBQ= golang.org/x/image v0.2.0/go.mod h1:la7oBXb9w3YFjBqaAwtynVioc1ZvOnNteUNrifGNmAI= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug= diff --git a/internal/config/compress_test.go b/internal/config/compress_test.go index 1f72fad8c1..217d87400c 100644 --- a/internal/config/compress_test.go +++ b/internal/config/compress_test.go @@ -563,3 +563,79 @@ func TestCompressorRegisterer_Bind(t *testing.T) { }) } } + +func TestCompressAlgorithm_String(t *testing.T) { + type want struct { + want string + } + type test struct { + name string + ca CompressAlgorithm + want want + checkFunc func(want, string) error + beforeFunc func(*testing.T) + afterFunc func(*testing.T) + } + defaultCheckFunc := func(w want, got string) error { + if !reflect.DeepEqual(got, w.want) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc(tt) + } + if test.afterFunc != nil { + defer test.afterFunc(tt) + } + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + + got := test.ca.String() + if err := checkFunc(test.want, got); err != nil { + tt.Errorf("error = %v", err) + } + }) + } +} diff --git a/internal/errors/redis_test.go b/internal/errors/redis_test.go index 1b10f33418..24734d30e8 100644 --- a/internal/errors/redis_test.go +++ b/internal/errors/redis_test.go @@ -939,3 +939,91 @@ func TestIsRedisNotFoundError(t *testing.T) { }) } } + +func TestRedisNotFoundIdentityError_Unwrap(t *testing.T) { + type fields struct { + err error + } + type want struct { + err error + } + type test struct { + name string + fields fields + want want + checkFunc func(want, error) error + beforeFunc func(*testing.T) + afterFunc func(*testing.T) + } + defaultCheckFunc := func(w want, err error) error { + if !Is(err, w.err) { + return Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + fields: fields { + err: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + fields: fields { + err: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc(tt) + } + if test.afterFunc != nil { + defer test.afterFunc(tt) + } + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + e := &RedisNotFoundIdentityError{ + err: test.fields.err, + } + + err := e.Unwrap() + if err := checkFunc(test.want, err); err != nil { + tt.Errorf("error = %v", err) + } + }) + } +} diff --git a/internal/file/file_test.go b/internal/file/file_test.go index a6551f5dd7..05090db6ee 100644 --- a/internal/file/file_test.go +++ b/internal/file/file_test.go @@ -1845,3 +1845,97 @@ func TestReadFile(t *testing.T) { }) } } + +func Test_doMoveDir(t *testing.T) { + type args struct { + ctx context.Context + src string + dst string + rollback bool + } + type want struct { + err error + } + type test struct { + name string + args args + want want + checkFunc func(want, error) error + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) + } + defaultCheckFunc := func(w want, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + ctx: nil, + src: "", + dst: "", + rollback: false, + }, + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + src: "", + dst: "", + rollback: false, + }, + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc(tt, test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(tt, test.args) + } + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + + err := doMoveDir(test.args.ctx, test.args.src, test.args.dst, test.args.rollback) + if err := checkFunc(test.want, err); err != nil { + tt.Errorf("error = %v", err) + } + }) + } +} diff --git a/internal/observability/exporter/otlp/option_test.go b/internal/observability/exporter/otlp/option_test.go new file mode 100644 index 0000000000..216481d618 --- /dev/null +++ b/internal/observability/exporter/otlp/option_test.go @@ -0,0 +1,1061 @@ +// Copyright (C) 2019-2022 vdaas.org vald team +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package otlp + +import ( + "testing" + + "github.com/vdaas/vald/internal/observability/attribute" + "github.com/vdaas/vald/internal/test/goleak" +) + +func TestWithAttributes(t *testing.T) { + // Change interface type to the type of object you are testing + type T = interface{} + type args struct { + attrs []attribute.KeyValue + } + type want struct { + obj *T + // Uncomment this line if the option returns an error, otherwise delete it + // err error + } + type test struct { + name string + args args + want want + // Use the first line if the option returns an error. otherwise use the second line + // checkFunc func(want, *T, error) error + // checkFunc func(want, *T) error + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) + } + + // Uncomment this block if the option returns an error, otherwise delete it + /* + defaultCheckFunc := func(w want, obj *T, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) + } + return nil + } + */ + + // Uncomment this block if the option do not returns an error, otherwise delete it + /* + defaultCheckFunc := func(w want, obj *T) error { + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) + } + return nil + } + */ + + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + attrs: nil, + }, + want: want { + obj: new(T), + }, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + attrs: nil, + }, + want: want { + obj: new(T), + }, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc(tt, test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(tt, test.args) + } + + // Uncomment this block if the option returns an error, otherwise delete it + /* + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + + got := WithAttributes(test.args.attrs...) + obj := new(T) + if err := checkFunc(test.want, obj, got(obj)); err != nil { + tt.Errorf("error = %v", err) + } + */ + + // Uncomment this block if the option do not return an error, otherwise delete it + /* + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + got := WithAttributes(test.args.attrs...) + obj := new(T) + got(obj) + if err := checkFunc(test.want, obj); err != nil { + tt.Errorf("error = %v", err) + } + */ + }) + } +} + +func TestWithCollectorEndpoint(t *testing.T) { + // Change interface type to the type of object you are testing + type T = interface{} + type args struct { + ep string + } + type want struct { + obj *T + // Uncomment this line if the option returns an error, otherwise delete it + // err error + } + type test struct { + name string + args args + want want + // Use the first line if the option returns an error. otherwise use the second line + // checkFunc func(want, *T, error) error + // checkFunc func(want, *T) error + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) + } + + // Uncomment this block if the option returns an error, otherwise delete it + /* + defaultCheckFunc := func(w want, obj *T, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) + } + return nil + } + */ + + // Uncomment this block if the option do not returns an error, otherwise delete it + /* + defaultCheckFunc := func(w want, obj *T) error { + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) + } + return nil + } + */ + + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + ep: "", + }, + want: want { + obj: new(T), + }, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ep: "", + }, + want: want { + obj: new(T), + }, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc(tt, test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(tt, test.args) + } + + // Uncomment this block if the option returns an error, otherwise delete it + /* + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + + got := WithCollectorEndpoint(test.args.ep) + obj := new(T) + if err := checkFunc(test.want, obj, got(obj)); err != nil { + tt.Errorf("error = %v", err) + } + */ + + // Uncomment this block if the option do not return an error, otherwise delete it + /* + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + got := WithCollectorEndpoint(test.args.ep) + obj := new(T) + got(obj) + if err := checkFunc(test.want, obj); err != nil { + tt.Errorf("error = %v", err) + } + */ + }) + } +} + +func TestWithTraceBatchTimeout(t *testing.T) { + // Change interface type to the type of object you are testing + type T = interface{} + type args struct { + s string + } + type want struct { + obj *T + // Uncomment this line if the option returns an error, otherwise delete it + // err error + } + type test struct { + name string + args args + want want + // Use the first line if the option returns an error. otherwise use the second line + // checkFunc func(want, *T, error) error + // checkFunc func(want, *T) error + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) + } + + // Uncomment this block if the option returns an error, otherwise delete it + /* + defaultCheckFunc := func(w want, obj *T, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) + } + return nil + } + */ + + // Uncomment this block if the option do not returns an error, otherwise delete it + /* + defaultCheckFunc := func(w want, obj *T) error { + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) + } + return nil + } + */ + + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + s: "", + }, + want: want { + obj: new(T), + }, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + s: "", + }, + want: want { + obj: new(T), + }, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc(tt, test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(tt, test.args) + } + + // Uncomment this block if the option returns an error, otherwise delete it + /* + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + + got := WithTraceBatchTimeout(test.args.s) + obj := new(T) + if err := checkFunc(test.want, obj, got(obj)); err != nil { + tt.Errorf("error = %v", err) + } + */ + + // Uncomment this block if the option do not return an error, otherwise delete it + /* + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + got := WithTraceBatchTimeout(test.args.s) + obj := new(T) + got(obj) + if err := checkFunc(test.want, obj); err != nil { + tt.Errorf("error = %v", err) + } + */ + }) + } +} + +func TestWithTraceExportTimeout(t *testing.T) { + // Change interface type to the type of object you are testing + type T = interface{} + type args struct { + s string + } + type want struct { + obj *T + // Uncomment this line if the option returns an error, otherwise delete it + // err error + } + type test struct { + name string + args args + want want + // Use the first line if the option returns an error. otherwise use the second line + // checkFunc func(want, *T, error) error + // checkFunc func(want, *T) error + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) + } + + // Uncomment this block if the option returns an error, otherwise delete it + /* + defaultCheckFunc := func(w want, obj *T, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) + } + return nil + } + */ + + // Uncomment this block if the option do not returns an error, otherwise delete it + /* + defaultCheckFunc := func(w want, obj *T) error { + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) + } + return nil + } + */ + + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + s: "", + }, + want: want { + obj: new(T), + }, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + s: "", + }, + want: want { + obj: new(T), + }, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc(tt, test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(tt, test.args) + } + + // Uncomment this block if the option returns an error, otherwise delete it + /* + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + + got := WithTraceExportTimeout(test.args.s) + obj := new(T) + if err := checkFunc(test.want, obj, got(obj)); err != nil { + tt.Errorf("error = %v", err) + } + */ + + // Uncomment this block if the option do not return an error, otherwise delete it + /* + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + got := WithTraceExportTimeout(test.args.s) + obj := new(T) + got(obj) + if err := checkFunc(test.want, obj); err != nil { + tt.Errorf("error = %v", err) + } + */ + }) + } +} + +func TestWithTraceMaxExportBatchSize(t *testing.T) { + // Change interface type to the type of object you are testing + type T = interface{} + type args struct { + size int + } + type want struct { + obj *T + // Uncomment this line if the option returns an error, otherwise delete it + // err error + } + type test struct { + name string + args args + want want + // Use the first line if the option returns an error. otherwise use the second line + // checkFunc func(want, *T, error) error + // checkFunc func(want, *T) error + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) + } + + // Uncomment this block if the option returns an error, otherwise delete it + /* + defaultCheckFunc := func(w want, obj *T, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) + } + return nil + } + */ + + // Uncomment this block if the option do not returns an error, otherwise delete it + /* + defaultCheckFunc := func(w want, obj *T) error { + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) + } + return nil + } + */ + + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + size: 0, + }, + want: want { + obj: new(T), + }, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + size: 0, + }, + want: want { + obj: new(T), + }, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc(tt, test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(tt, test.args) + } + + // Uncomment this block if the option returns an error, otherwise delete it + /* + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + + got := WithTraceMaxExportBatchSize(test.args.size) + obj := new(T) + if err := checkFunc(test.want, obj, got(obj)); err != nil { + tt.Errorf("error = %v", err) + } + */ + + // Uncomment this block if the option do not return an error, otherwise delete it + /* + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + got := WithTraceMaxExportBatchSize(test.args.size) + obj := new(T) + got(obj) + if err := checkFunc(test.want, obj); err != nil { + tt.Errorf("error = %v", err) + } + */ + }) + } +} + +func TestWithTraceMaxQueueSize(t *testing.T) { + // Change interface type to the type of object you are testing + type T = interface{} + type args struct { + size int + } + type want struct { + obj *T + // Uncomment this line if the option returns an error, otherwise delete it + // err error + } + type test struct { + name string + args args + want want + // Use the first line if the option returns an error. otherwise use the second line + // checkFunc func(want, *T, error) error + // checkFunc func(want, *T) error + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) + } + + // Uncomment this block if the option returns an error, otherwise delete it + /* + defaultCheckFunc := func(w want, obj *T, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) + } + return nil + } + */ + + // Uncomment this block if the option do not returns an error, otherwise delete it + /* + defaultCheckFunc := func(w want, obj *T) error { + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) + } + return nil + } + */ + + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + size: 0, + }, + want: want { + obj: new(T), + }, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + size: 0, + }, + want: want { + obj: new(T), + }, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc(tt, test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(tt, test.args) + } + + // Uncomment this block if the option returns an error, otherwise delete it + /* + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + + got := WithTraceMaxQueueSize(test.args.size) + obj := new(T) + if err := checkFunc(test.want, obj, got(obj)); err != nil { + tt.Errorf("error = %v", err) + } + */ + + // Uncomment this block if the option do not return an error, otherwise delete it + /* + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + got := WithTraceMaxQueueSize(test.args.size) + obj := new(T) + got(obj) + if err := checkFunc(test.want, obj); err != nil { + tt.Errorf("error = %v", err) + } + */ + }) + } +} + +func TestWithMetricsExportInterval(t *testing.T) { + // Change interface type to the type of object you are testing + type T = interface{} + type args struct { + s string + } + type want struct { + obj *T + // Uncomment this line if the option returns an error, otherwise delete it + // err error + } + type test struct { + name string + args args + want want + // Use the first line if the option returns an error. otherwise use the second line + // checkFunc func(want, *T, error) error + // checkFunc func(want, *T) error + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) + } + + // Uncomment this block if the option returns an error, otherwise delete it + /* + defaultCheckFunc := func(w want, obj *T, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) + } + return nil + } + */ + + // Uncomment this block if the option do not returns an error, otherwise delete it + /* + defaultCheckFunc := func(w want, obj *T) error { + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) + } + return nil + } + */ + + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + s: "", + }, + want: want { + obj: new(T), + }, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + s: "", + }, + want: want { + obj: new(T), + }, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc(tt, test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(tt, test.args) + } + + // Uncomment this block if the option returns an error, otherwise delete it + /* + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + + got := WithMetricsExportInterval(test.args.s) + obj := new(T) + if err := checkFunc(test.want, obj, got(obj)); err != nil { + tt.Errorf("error = %v", err) + } + */ + + // Uncomment this block if the option do not return an error, otherwise delete it + /* + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + got := WithMetricsExportInterval(test.args.s) + obj := new(T) + got(obj) + if err := checkFunc(test.want, obj); err != nil { + tt.Errorf("error = %v", err) + } + */ + }) + } +} + +func TestWithMetricsExportTimeout(t *testing.T) { + // Change interface type to the type of object you are testing + type T = interface{} + type args struct { + s string + } + type want struct { + obj *T + // Uncomment this line if the option returns an error, otherwise delete it + // err error + } + type test struct { + name string + args args + want want + // Use the first line if the option returns an error. otherwise use the second line + // checkFunc func(want, *T, error) error + // checkFunc func(want, *T) error + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) + } + + // Uncomment this block if the option returns an error, otherwise delete it + /* + defaultCheckFunc := func(w want, obj *T, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) + } + return nil + } + */ + + // Uncomment this block if the option do not returns an error, otherwise delete it + /* + defaultCheckFunc := func(w want, obj *T) error { + if !reflect.DeepEqual(obj, w.obj) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) + } + return nil + } + */ + + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + s: "", + }, + want: want { + obj: new(T), + }, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + s: "", + }, + want: want { + obj: new(T), + }, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc(tt, test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(tt, test.args) + } + + // Uncomment this block if the option returns an error, otherwise delete it + /* + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + + got := WithMetricsExportTimeout(test.args.s) + obj := new(T) + if err := checkFunc(test.want, obj, got(obj)); err != nil { + tt.Errorf("error = %v", err) + } + */ + + // Uncomment this block if the option do not return an error, otherwise delete it + /* + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + got := WithMetricsExportTimeout(test.args.s) + obj := new(T) + got(obj) + if err := checkFunc(test.want, obj); err != nil { + tt.Errorf("error = %v", err) + } + */ + }) + } +} diff --git a/internal/observability/exporter/otlp/otlp.go b/internal/observability/exporter/otlp/otlp.go index 7f88b4b45d..a602d45552 100644 --- a/internal/observability/exporter/otlp/otlp.go +++ b/internal/observability/exporter/otlp/otlp.go @@ -18,6 +18,11 @@ import ( "reflect" "time" + "github.com/vdaas/vald/internal/errors" + "github.com/vdaas/vald/internal/log" + "github.com/vdaas/vald/internal/observability/attribute" + "github.com/vdaas/vald/internal/observability/exporter" + "github.com/vdaas/vald/internal/observability/metrics" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc" "go.opentelemetry.io/otel/exporters/otlp/otlptrace" @@ -28,12 +33,6 @@ import ( "go.opentelemetry.io/otel/sdk/resource" "go.opentelemetry.io/otel/sdk/trace" semconv "go.opentelemetry.io/otel/semconv/v1.4.0" - - "github.com/vdaas/vald/internal/errors" - "github.com/vdaas/vald/internal/log" - "github.com/vdaas/vald/internal/observability/attribute" - "github.com/vdaas/vald/internal/observability/exporter" - "github.com/vdaas/vald/internal/observability/metrics" ) // Metrics and Trace attribute keys. diff --git a/internal/observability/exporter/otlp/otlp_test.go b/internal/observability/exporter/otlp/otlp_test.go new file mode 100644 index 0000000000..83c8e4e655 --- /dev/null +++ b/internal/observability/exporter/otlp/otlp_test.go @@ -0,0 +1,719 @@ +// Copyright (C) 2019-2022 vdaas.org vald team +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package otlp + +import ( + "context" + "reflect" + "testing" + "time" + + "github.com/vdaas/vald/internal/errors" + "github.com/vdaas/vald/internal/observability/attribute" + "github.com/vdaas/vald/internal/observability/exporter" + "github.com/vdaas/vald/internal/observability/metrics" + "github.com/vdaas/vald/internal/test/goleak" + "go.opentelemetry.io/otel/exporters/otlp/otlptrace" + "go.opentelemetry.io/otel/sdk/metric" + "go.opentelemetry.io/otel/sdk/trace" +) + +func TestNew(t *testing.T) { + type args struct { + opts []Option + } + type want struct { + want exporter.Exporter + err error + } + type test struct { + name string + args args + want want + checkFunc func(want, exporter.Exporter, error) error + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) + } + defaultCheckFunc := func(w want, got exporter.Exporter, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + if !reflect.DeepEqual(got, w.want) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + opts: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + opts: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc(tt, test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(tt, test.args) + } + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + + got, err := New(test.args.opts...) + if err := checkFunc(test.want, got, err); err != nil { + tt.Errorf("error = %v", err) + } + }) + } +} + +func Test_exp_initTracer(t *testing.T) { + type args struct { + ctx context.Context + } + type fields struct { + serviceName string + collectorEndpoint string + traceExporter *otlptrace.Exporter + traceProvider *trace.TracerProvider + tBatchTimeout time.Duration + tExportTimeout time.Duration + tMaxExportBatchSize int + tMaxQueueSize int + metricsExporter metric.Exporter + meterProvider *metric.MeterProvider + metricsViews []metrics.View + mExportInterval time.Duration + mExportTimeout time.Duration + attributes []attribute.KeyValue + } + type want struct { + err error + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want, error) error + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) + } + defaultCheckFunc := func(w want, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + ctx: nil, + }, + fields: fields { + serviceName: "", + collectorEndpoint: "", + traceExporter: nil, + traceProvider: nil, + tBatchTimeout: nil, + tExportTimeout: nil, + tMaxExportBatchSize: 0, + tMaxQueueSize: 0, + metricsExporter: nil, + meterProvider: nil, + metricsViews: nil, + mExportInterval: nil, + mExportTimeout: nil, + attributes: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + }, + fields: fields { + serviceName: "", + collectorEndpoint: "", + traceExporter: nil, + traceProvider: nil, + tBatchTimeout: nil, + tExportTimeout: nil, + tMaxExportBatchSize: 0, + tMaxQueueSize: 0, + metricsExporter: nil, + meterProvider: nil, + metricsViews: nil, + mExportInterval: nil, + mExportTimeout: nil, + attributes: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc(tt, test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(tt, test.args) + } + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + e := &exp{ + serviceName: test.fields.serviceName, + collectorEndpoint: test.fields.collectorEndpoint, + traceExporter: test.fields.traceExporter, + traceProvider: test.fields.traceProvider, + tBatchTimeout: test.fields.tBatchTimeout, + tExportTimeout: test.fields.tExportTimeout, + tMaxExportBatchSize: test.fields.tMaxExportBatchSize, + tMaxQueueSize: test.fields.tMaxQueueSize, + metricsExporter: test.fields.metricsExporter, + meterProvider: test.fields.meterProvider, + metricsViews: test.fields.metricsViews, + mExportInterval: test.fields.mExportInterval, + mExportTimeout: test.fields.mExportTimeout, + attributes: test.fields.attributes, + } + + err := e.initTracer(test.args.ctx) + if err := checkFunc(test.want, err); err != nil { + tt.Errorf("error = %v", err) + } + }) + } +} + +func Test_exp_initMeter(t *testing.T) { + type args struct { + ctx context.Context + } + type fields struct { + serviceName string + collectorEndpoint string + traceExporter *otlptrace.Exporter + traceProvider *trace.TracerProvider + tBatchTimeout time.Duration + tExportTimeout time.Duration + tMaxExportBatchSize int + tMaxQueueSize int + metricsExporter metric.Exporter + meterProvider *metric.MeterProvider + metricsViews []metrics.View + mExportInterval time.Duration + mExportTimeout time.Duration + attributes []attribute.KeyValue + } + type want struct { + err error + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want, error) error + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) + } + defaultCheckFunc := func(w want, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + ctx: nil, + }, + fields: fields { + serviceName: "", + collectorEndpoint: "", + traceExporter: nil, + traceProvider: nil, + tBatchTimeout: nil, + tExportTimeout: nil, + tMaxExportBatchSize: 0, + tMaxQueueSize: 0, + metricsExporter: nil, + meterProvider: nil, + metricsViews: nil, + mExportInterval: nil, + mExportTimeout: nil, + attributes: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + }, + fields: fields { + serviceName: "", + collectorEndpoint: "", + traceExporter: nil, + traceProvider: nil, + tBatchTimeout: nil, + tExportTimeout: nil, + tMaxExportBatchSize: 0, + tMaxQueueSize: 0, + metricsExporter: nil, + meterProvider: nil, + metricsViews: nil, + mExportInterval: nil, + mExportTimeout: nil, + attributes: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc(tt, test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(tt, test.args) + } + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + e := &exp{ + serviceName: test.fields.serviceName, + collectorEndpoint: test.fields.collectorEndpoint, + traceExporter: test.fields.traceExporter, + traceProvider: test.fields.traceProvider, + tBatchTimeout: test.fields.tBatchTimeout, + tExportTimeout: test.fields.tExportTimeout, + tMaxExportBatchSize: test.fields.tMaxExportBatchSize, + tMaxQueueSize: test.fields.tMaxQueueSize, + metricsExporter: test.fields.metricsExporter, + meterProvider: test.fields.meterProvider, + metricsViews: test.fields.metricsViews, + mExportInterval: test.fields.mExportInterval, + mExportTimeout: test.fields.mExportTimeout, + attributes: test.fields.attributes, + } + + err := e.initMeter(test.args.ctx) + if err := checkFunc(test.want, err); err != nil { + tt.Errorf("error = %v", err) + } + }) + } +} + +func Test_exp_Start(t *testing.T) { + type args struct { + ctx context.Context + } + type fields struct { + serviceName string + collectorEndpoint string + traceExporter *otlptrace.Exporter + traceProvider *trace.TracerProvider + tBatchTimeout time.Duration + tExportTimeout time.Duration + tMaxExportBatchSize int + tMaxQueueSize int + metricsExporter metric.Exporter + meterProvider *metric.MeterProvider + metricsViews []metrics.View + mExportInterval time.Duration + mExportTimeout time.Duration + attributes []attribute.KeyValue + } + type want struct { + err error + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want, error) error + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) + } + defaultCheckFunc := func(w want, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + ctx: nil, + }, + fields: fields { + serviceName: "", + collectorEndpoint: "", + traceExporter: nil, + traceProvider: nil, + tBatchTimeout: nil, + tExportTimeout: nil, + tMaxExportBatchSize: 0, + tMaxQueueSize: 0, + metricsExporter: nil, + meterProvider: nil, + metricsViews: nil, + mExportInterval: nil, + mExportTimeout: nil, + attributes: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + }, + fields: fields { + serviceName: "", + collectorEndpoint: "", + traceExporter: nil, + traceProvider: nil, + tBatchTimeout: nil, + tExportTimeout: nil, + tMaxExportBatchSize: 0, + tMaxQueueSize: 0, + metricsExporter: nil, + meterProvider: nil, + metricsViews: nil, + mExportInterval: nil, + mExportTimeout: nil, + attributes: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc(tt, test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(tt, test.args) + } + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + e := &exp{ + serviceName: test.fields.serviceName, + collectorEndpoint: test.fields.collectorEndpoint, + traceExporter: test.fields.traceExporter, + traceProvider: test.fields.traceProvider, + tBatchTimeout: test.fields.tBatchTimeout, + tExportTimeout: test.fields.tExportTimeout, + tMaxExportBatchSize: test.fields.tMaxExportBatchSize, + tMaxQueueSize: test.fields.tMaxQueueSize, + metricsExporter: test.fields.metricsExporter, + meterProvider: test.fields.meterProvider, + metricsViews: test.fields.metricsViews, + mExportInterval: test.fields.mExportInterval, + mExportTimeout: test.fields.mExportTimeout, + attributes: test.fields.attributes, + } + + err := e.Start(test.args.ctx) + if err := checkFunc(test.want, err); err != nil { + tt.Errorf("error = %v", err) + } + }) + } +} + +func Test_exp_Stop(t *testing.T) { + type args struct { + ctx context.Context + } + type fields struct { + serviceName string + collectorEndpoint string + traceExporter *otlptrace.Exporter + traceProvider *trace.TracerProvider + tBatchTimeout time.Duration + tExportTimeout time.Duration + tMaxExportBatchSize int + tMaxQueueSize int + metricsExporter metric.Exporter + meterProvider *metric.MeterProvider + metricsViews []metrics.View + mExportInterval time.Duration + mExportTimeout time.Duration + attributes []attribute.KeyValue + } + type want struct { + err error + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want, error) error + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) + } + defaultCheckFunc := func(w want, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + ctx: nil, + }, + fields: fields { + serviceName: "", + collectorEndpoint: "", + traceExporter: nil, + traceProvider: nil, + tBatchTimeout: nil, + tExportTimeout: nil, + tMaxExportBatchSize: 0, + tMaxQueueSize: 0, + metricsExporter: nil, + meterProvider: nil, + metricsViews: nil, + mExportInterval: nil, + mExportTimeout: nil, + attributes: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + ctx: nil, + }, + fields: fields { + serviceName: "", + collectorEndpoint: "", + traceExporter: nil, + traceProvider: nil, + tBatchTimeout: nil, + tExportTimeout: nil, + tMaxExportBatchSize: 0, + tMaxQueueSize: 0, + metricsExporter: nil, + meterProvider: nil, + metricsViews: nil, + mExportInterval: nil, + mExportTimeout: nil, + attributes: nil, + }, + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc(tt, test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(tt, test.args) + } + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + e := &exp{ + serviceName: test.fields.serviceName, + collectorEndpoint: test.fields.collectorEndpoint, + traceExporter: test.fields.traceExporter, + traceProvider: test.fields.traceProvider, + tBatchTimeout: test.fields.tBatchTimeout, + tExportTimeout: test.fields.tExportTimeout, + tMaxExportBatchSize: test.fields.tMaxExportBatchSize, + tMaxQueueSize: test.fields.tMaxQueueSize, + metricsExporter: test.fields.metricsExporter, + meterProvider: test.fields.meterProvider, + metricsViews: test.fields.metricsViews, + mExportInterval: test.fields.mExportInterval, + mExportTimeout: test.fields.mExportTimeout, + attributes: test.fields.attributes, + } + + err := e.Stop(test.args.ctx) + if err := checkFunc(test.want, err); err != nil { + tt.Errorf("error = %v", err) + } + }) + } +} diff --git a/internal/test/data/vector/gen.go b/internal/test/data/vector/gen.go index f7c461f822..8105e4a295 100644 --- a/internal/test/data/vector/gen.go +++ b/internal/test/data/vector/gen.go @@ -16,6 +16,7 @@ package vector import ( "math" "math/rand" + "time" "github.com/vdaas/vald/internal/errors" irand "github.com/vdaas/vald/internal/rand" @@ -30,13 +31,14 @@ type ( const ( Gaussian Distribution = iota Uniform + NegativeUniform // NOTE: mean:128, sigma:128/3, all of 99.7% are in [0, 255]. gaussianMean float64 = 128 gaussianSigma float64 = 128 / 3 ) -// ErrUnknownDistritbution represents an error which the distribution is unknown. +// ErrUnknownDistribution represents an error which the distribution is unknown. var ErrUnknownDistribution = errors.New("Unknown distribution generator type") // Float32VectorGenerator returns float32 vector generator function which has selected distribution @@ -46,6 +48,8 @@ func Float32VectorGenerator(d Distribution) (Float32VectorGeneratorFunc, error) return GaussianDistributedFloat32VectorGenerator, nil case Uniform: return UniformDistributedFloat32VectorGenerator, nil + case NegativeUniform: + return NegativeUniformDistributedFloat32VectorGenerator, nil default: return nil, ErrUnknownDistribution } @@ -82,6 +86,25 @@ func UniformDistributedFloat32VectorGenerator(n, dim int) [][]float32 { return genF32Slice(n, dim, rand.Float32) } +// NegativeUniformDistributedFloat32VectorGenerator returns n float32 vectors with dim dimension and their values under Uniform distribution +func NegativeUniformDistributedFloat32VectorGenerator(n, dim int) (vecs [][]float32) { + left, right := dim/2, dim-dim/2 + lvs := genF32Slice(n, left, func() float32 { + return -rand.Float32() + }) + rvs := UniformDistributedFloat32VectorGenerator(n, right) + vecs = make([][]float32, 0, n) + // skipcq: GO-S1033 + rand.Seed(time.Now().UnixNano()) + for i := 0; i < n; i++ { + // skipcq: CRT-D0001 + vs := append(lvs[i], rvs[i]...) + rand.Shuffle(len(vs), func(i, j int) { vs[i], vs[j] = vs[j], vs[i] }) + vecs = append(vecs, vs) + } + return vecs +} + // GaussianDistributedFloat32VectorGenerator returns n float32 vectors with dim dimension and their values under Gaussian distribution func GaussianDistributedFloat32VectorGenerator(n, dim int) [][]float32 { return genF32Slice(n, dim, func() float32 { diff --git a/internal/test/data/vector/gen_test.go b/internal/test/data/vector/gen_test.go index 1014e368d9..81208d5ba0 100644 --- a/internal/test/data/vector/gen_test.go +++ b/internal/test/data/vector/gen_test.go @@ -1167,3 +1167,91 @@ func TestConvertVectorsUint8ToFloat32(t *testing.T) { }) } } + +func TestNegativeUniformDistributedFloat32VectorGenerator(t *testing.T) { + type args struct { + n int + dim int + } + type want struct { + wantVecs [][]float32 + } + type test struct { + name string + args args + want want + checkFunc func(want, [][]float32) error + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) + } + defaultCheckFunc := func(w want, gotVecs [][]float32) error { + if !reflect.DeepEqual(gotVecs, w.wantVecs) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotVecs, w.wantVecs) + } + return nil + } + tests := []test{ + // TODO test cases + /* + { + name: "test_case_1", + args: args { + n: 0, + dim: 0, + }, + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + }, + */ + + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + n: 0, + dim: 0, + }, + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + } + }(), + */ + } + + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc(tt, test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(tt, test.args) + } + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + + gotVecs := NegativeUniformDistributedFloat32VectorGenerator(test.args.n, test.args.dim) + if err := checkFunc(test.want, gotVecs); err != nil { + tt.Errorf("error = %v", err) + } + }) + } +} diff --git a/pkg/agent/core/ngt/handler/grpc/handler_test.go b/pkg/agent/core/ngt/handler/grpc/handler_test.go index e54a424f02..dfb7880df2 100644 --- a/pkg/agent/core/ngt/handler/grpc/handler_test.go +++ b/pkg/agent/core/ngt/handler/grpc/handler_test.go @@ -41,20 +41,14 @@ func TestMain(m *testing.M) { goleak.VerifyTestMain(m) } -func buildIndex(ctx context.Context, t request.ObjectType, dist vector.Distribution, num int, insertCfg *payload.Insert_Config, +func newIndexedNGTService(ctx context.Context, eg errgroup.Group, t request.ObjectType, dist vector.Distribution, num int, insertCfg *payload.Insert_Config, ngtCfg *config.NGT, ngtOpts []service.Option, overwriteIDs []string, overwriteVectors [][]float32, -) (Server, error) { - eg, ctx := errgroup.New(ctx) +) (service.NGT, error) { ngt, err := service.New(ngtCfg, append(ngtOpts, service.WithErrGroup(eg), service.WithEnableInMemoryMode(true))...) if err != nil { return nil, err } - s, err := New(WithErrGroup(eg), WithNGT(ngt)) - if err != nil { - return nil, err - } - if num > 0 { // gen insert request reqs, err := request.GenMultiInsertReq(t, dist, num, ngtCfg.Dimension, insertCfg) @@ -73,17 +67,19 @@ func buildIndex(ctx context.Context, t request.ObjectType, dist vector.Distribut } // insert and create index - if _, err := s.MultiInsert(ctx, reqs); err != nil { - return nil, err + for _, req := range reqs.GetRequests() { + err := ngt.Insert(req.GetVector().GetId(), req.GetVector().GetVector()) + if err != nil { + return nil, err + } } - if _, err := s.CreateIndex(ctx, &payload.Control_CreateIndexRequest{ - PoolSize: 100, - }); err != nil { + err = ngt.CreateIndex(ctx, 1000) + if err != nil { return nil, err } } - return s, nil + return ngt, nil } func TestNew(t *testing.T) { diff --git a/pkg/agent/core/ngt/handler/grpc/index.go b/pkg/agent/core/ngt/handler/grpc/index.go index f97ad336f1..28f20c5bb3 100644 --- a/pkg/agent/core/ngt/handler/grpc/index.go +++ b/pkg/agent/core/ngt/handler/grpc/index.go @@ -21,6 +21,7 @@ import ( "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/info" "github.com/vdaas/vald/internal/log" + "github.com/vdaas/vald/internal/net/grpc/codes" "github.com/vdaas/vald/internal/net/grpc/errdetails" "github.com/vdaas/vald/internal/net/grpc/status" "github.com/vdaas/vald/internal/observability/trace" @@ -36,8 +37,9 @@ func (s *server) CreateIndex(ctx context.Context, c *payload.Control_CreateIndex res = new(payload.Empty) err = s.ngt.CreateIndex(ctx, c.GetPoolSize()) if err != nil { - if errors.Is(err, errors.ErrUncommittedIndexNotFound) { - err = status.WrapWithFailedPrecondition(fmt.Sprintf("CreateIndex API failed to create indexes pool_size = %d", c.GetPoolSize()), err, + var ( + code codes.Code + details = []interface{}{ &errdetails.RequestInfo{ ServingData: errdetails.Serialize(c), }, @@ -45,34 +47,35 @@ func (s *server) CreateIndex(ctx context.Context, c *payload.Control_CreateIndex ResourceType: ngtResourceType + "/ngt.CreateIndex", ResourceName: fmt.Sprintf("%s: %s(%s)", apiName, s.name, s.ip), }, - &errdetails.PreconditionFailure{ + } + ) + + switch { + case errors.Is(err, errors.ErrUncommittedIndexNotFound): + err = status.WrapWithFailedPrecondition(fmt.Sprintf("CreateIndex API failed to create indexes pool_size = %d due to the precondition failure, error: %v", c.GetPoolSize(), err), err, + append(details, &errdetails.PreconditionFailure{ Violations: []*errdetails.PreconditionFailureViolation{ { Type: "uncommitted index is empty", Subject: "failed to CreateIndex operation caused by empty uncommitted indices", }, }, - }, info.Get()) - if span != nil { - span.RecordError(err) - span.SetAttributes(trace.StatusCodeFailedPrecondition(err.Error())...) - span.SetStatus(trace.StatusError, err.Error()) - } - return nil, err + }, info.Get())...) + code = codes.FailedPrecondition + case errors.Is(err, context.Canceled): + err = status.WrapWithCanceled(fmt.Sprintf("CreateIndex API canceled to create indexes pool_size = %d, error: %v", c.GetPoolSize(), err), err, details...) + code = codes.Canceled + case errors.Is(err, context.DeadlineExceeded): + err = status.WrapWithDeadlineExceeded(fmt.Sprintf("CreateIndex API deadline exceeded to create indexes pool_size = %d, error: %v", c.GetPoolSize(), err), err, details...) + code = codes.DeadlineExceeded + default: + err = status.WrapWithInternal(fmt.Sprintf("CreateIndex API failed to create indexes pool_size = %d, error: %v", c.GetPoolSize(), err), err, append(details, info.Get())...) + code = codes.Internal } log.Error(err) - err = status.WrapWithInternal(fmt.Sprintf("CreateIndex API failed to create indexes pool_size = %d", c.GetPoolSize()), err, - &errdetails.RequestInfo{ - ServingData: errdetails.Serialize(c), - }, - &errdetails.ResourceInfo{ - ResourceType: ngtResourceType + "/ngt.CreateIndex", - ResourceName: fmt.Sprintf("%s: %s(%s)", apiName, s.name, s.ip), - }, info.Get()) - log.Error(err) if span != nil { span.RecordError(err) - span.SetAttributes(trace.StatusCodeInternal(err.Error())...) + span.SetAttributes(trace.FromGRPCStatus(code, err.Error())...) span.SetStatus(trace.StatusError, err.Error()) } return nil, err @@ -117,8 +120,9 @@ func (s *server) CreateAndSaveIndex(ctx context.Context, c *payload.Control_Crea res = new(payload.Empty) err = s.ngt.CreateAndSaveIndex(ctx, c.GetPoolSize()) if err != nil { - if errors.Is(err, errors.ErrUncommittedIndexNotFound) { - err = status.WrapWithFailedPrecondition(fmt.Sprintf("CreateAndSaveIndex API failed to create indexes pool_size = %d", c.GetPoolSize()), err, + var ( + code codes.Code + details = []interface{}{ &errdetails.RequestInfo{ ServingData: errdetails.Serialize(c), }, @@ -126,36 +130,37 @@ func (s *server) CreateAndSaveIndex(ctx context.Context, c *payload.Control_Crea ResourceType: ngtResourceType + "/ngt.CreateAndSaveIndex", ResourceName: fmt.Sprintf("%s: %s(%s)", apiName, s.name, s.ip), }, - &errdetails.PreconditionFailure{ + } + ) + + switch { + case errors.Is(err, errors.ErrUncommittedIndexNotFound): + err = status.WrapWithFailedPrecondition(fmt.Sprintf("CreateAndSaveIndex API failed to create indexes pool_size = %d due to the precondition failure, error: %v", c.GetPoolSize(), err), err, + append(details, &errdetails.PreconditionFailure{ Violations: []*errdetails.PreconditionFailureViolation{ { Type: "uncommitted index is empty", Subject: "failed to CreateAndSaveIndex operation caused by empty uncommitted indices", }, }, - }, info.Get()) - if span != nil { - span.RecordError(err) - span.SetAttributes(trace.StatusCodeFailedPrecondition(err.Error())...) - span.SetStatus(trace.StatusError, err.Error()) - } - return nil, err + }, info.Get())...) + code = codes.FailedPrecondition + case errors.Is(err, context.Canceled): + err = status.WrapWithCanceled(fmt.Sprintf("CreateAndSaveIndex API canceled to create indexes pool_size = %d, error: %v", c.GetPoolSize(), err), err, details...) + code = codes.Canceled + case errors.Is(err, context.DeadlineExceeded): + err = status.WrapWithDeadlineExceeded(fmt.Sprintf("CreateAndSaveIndex API deadline exceeded to create indexes pool_size = %d, error: %v", c.GetPoolSize(), err), err, details...) + code = codes.DeadlineExceeded + default: + err = status.WrapWithInternal(fmt.Sprintf("CreateAndSaveIndex API failed to create indexes pool_size = %d, error: %v", c.GetPoolSize(), err), err, append(details, info.Get())...) + code = codes.Internal } - err = status.WrapWithInternal(fmt.Sprintf("CreateAndSaveIndex API failed to create indexes pool_size = %d", c.GetPoolSize()), err, - &errdetails.RequestInfo{ - ServingData: errdetails.Serialize(c), - }, - &errdetails.ResourceInfo{ - ResourceType: ngtResourceType + "/ngt.CreateAndSaveIndex", - ResourceName: fmt.Sprintf("%s: %s(%s)", apiName, s.name, s.ip), - }, info.Get()) log.Error(err) if span != nil { span.RecordError(err) - span.SetAttributes(trace.StatusCodeInternal(err.Error())...) + span.SetAttributes(trace.FromGRPCStatus(code, err.Error())...) span.SetStatus(trace.StatusError, err.Error()) } - return nil, err } return res, nil } diff --git a/pkg/agent/core/ngt/handler/grpc/object_test.go b/pkg/agent/core/ngt/handler/grpc/object_test.go index d2d1591777..c1dd97a348 100644 --- a/pkg/agent/core/ngt/handler/grpc/object_test.go +++ b/pkg/agent/core/ngt/handler/grpc/object_test.go @@ -97,7 +97,16 @@ func Test_server_Exists(t *testing.T) { SkipStrictExistCheck: true, } defaultBeforeFunc := func(ctx context.Context, a args) (Server, error) { - return buildIndex(ctx, request.Float, vector.Gaussian, insertNum, defaultInsertConfig, defaultNgtConfig, nil, []string{a.indexID}, nil) + eg, ctx := errgroup.New(ctx) + ngt, err := newIndexedNGTService(ctx, eg, request.Float, vector.Gaussian, insertNum, defaultInsertConfig, defaultNgtConfig, nil, []string{a.indexID}, nil) + if err != nil { + return nil, err + } + s, err := New(WithErrGroup(eg), WithNGT(ngt)) + if err != nil { + return nil, err + } + return s, nil } /* diff --git a/pkg/agent/core/ngt/handler/grpc/remove_test.go b/pkg/agent/core/ngt/handler/grpc/remove_test.go index 217c6f17a5..c771f60e64 100644 --- a/pkg/agent/core/ngt/handler/grpc/remove_test.go +++ b/pkg/agent/core/ngt/handler/grpc/remove_test.go @@ -100,7 +100,16 @@ func Test_server_Remove(t *testing.T) { SkipStrictExistCheck: true, } defaultBeforeFunc := func(ctx context.Context, a args) (Server, error) { - return buildIndex(ctx, request.Float, vector.Gaussian, insertNum, defaultInsertConfig, defaultNgtConfig, nil, []string{a.indexID}, nil) + eg, ctx := errgroup.New(ctx) + ngt, err := newIndexedNGTService(ctx, eg, request.Float, vector.Gaussian, insertNum, defaultInsertConfig, defaultNgtConfig, nil, []string{a.indexID}, nil) + if err != nil { + return nil, err + } + s, err := New(WithErrGroup(eg), WithNGT(ngt)) + if err != nil { + return nil, err + } + return s, nil } /* diff --git a/pkg/agent/core/ngt/handler/grpc/search_test.go b/pkg/agent/core/ngt/handler/grpc/search_test.go index 0ef45898ec..cdc69b509d 100644 --- a/pkg/agent/core/ngt/handler/grpc/search_test.go +++ b/pkg/agent/core/ngt/handler/grpc/search_test.go @@ -72,7 +72,16 @@ func Test_server_Search(t *testing.T) { SkipStrictExistCheck: true, } defaultBeforeFunc := func(ctx context.Context, f fields, a args) (Server, error) { - return buildIndex(ctx, f.objectType, f.distribution, a.insertNum, defaultInsertConfig, f.ngtCfg, f.ngtOpts, nil, f.overwriteVec) + eg, ctx := errgroup.New(ctx) + ngt, err := newIndexedNGTService(ctx, eg, f.objectType, f.distribution, a.insertNum, defaultInsertConfig, f.ngtCfg, f.ngtOpts, nil, f.overwriteVec) + if err != nil { + return nil, err + } + s, err := New(WithErrGroup(eg), WithNGT(ngt)) + if err != nil { + return nil, err + } + return s, nil } defaultCheckFunc := func(w want, gotRes *payload.Search_Response, err error) error { if err != nil { @@ -789,11 +798,7 @@ func Test_server_Search(t *testing.T) { func Test_server_SearchByID(t *testing.T) { t.Parallel() - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - type args struct { - ctx context.Context indexID string searchID string } @@ -806,7 +811,7 @@ func Test_server_SearchByID(t *testing.T) { args args want want checkFunc func(want, *payload.Search_Response, error) error - beforeFunc func(args) (Server, error) + beforeFunc func(context.Context, args) (Server, error) afterFunc func(args) } defaultCheckFunc := func(w want, gotRes *payload.Search_Response, err error) error { @@ -838,7 +843,6 @@ func Test_server_SearchByID(t *testing.T) { if err != nil { t.Error(err) } - defaultNgtConfig := &config.NGT{ Dimension: 128, DistanceType: ngt.L2.String(), @@ -852,12 +856,22 @@ func Test_server_SearchByID(t *testing.T) { InsertBufferPoolSize: 1000, DeleteBufferPoolSize: 1000, }, + EnableInMemoryMode: true, } defaultInsertConfig := &payload.Insert_Config{ SkipStrictExistCheck: true, } - defaultBeforeFunc := func(a args) (Server, error) { - return buildIndex(a.ctx, request.Float, vector.Gaussian, insertNum, defaultInsertConfig, defaultNgtConfig, nil, []string{a.indexID}, nil) + defaultBeforeFunc := func(ctx context.Context, a args) (Server, error) { + eg, ctx := errgroup.New(ctx) + ngt, err := newIndexedNGTService(ctx, eg, request.Float, vector.Gaussian, insertNum, defaultInsertConfig, defaultNgtConfig, nil, []string{a.indexID}, nil) + if err != nil { + return nil, err + } + s, err := New(WithErrGroup(eg), WithNGT(ngt)) + if err != nil { + return nil, err + } + return s, nil } defaultSearch_Config := &payload.Search_Config{ Num: 10, @@ -896,7 +910,6 @@ func Test_server_SearchByID(t *testing.T) { { name: "Equivalence Class Testing case 1.1: success search vector", args: args{ - ctx: ctx, indexID: "test", searchID: "test", }, @@ -907,7 +920,6 @@ func Test_server_SearchByID(t *testing.T) { { name: "Equivalence Class Testing case 2.1: fail search with non-existent ID", args: args{ - ctx: ctx, indexID: "test", searchID: "non-existent", }, @@ -919,7 +931,6 @@ func Test_server_SearchByID(t *testing.T) { { name: "Boundary Value Testing case 1.1: fail search with \"\"", args: args{ - ctx: ctx, indexID: "test", searchID: "", }, @@ -931,7 +942,6 @@ func Test_server_SearchByID(t *testing.T) { { name: "Boundary Value Testing case 2.1: success search with ^@", args: args{ - ctx: ctx, indexID: string([]byte{0}), searchID: string([]byte{0}), }, @@ -942,7 +952,6 @@ func Test_server_SearchByID(t *testing.T) { { name: "Boundary Value Testing case 2.2: success search with ^I", args: args{ - ctx: ctx, indexID: "\t", searchID: "\t", }, @@ -953,7 +962,6 @@ func Test_server_SearchByID(t *testing.T) { { name: "Boundary Value Testing case 2.3: success search with ^J", args: args{ - ctx: ctx, indexID: "\n", searchID: "\n", }, @@ -964,7 +972,6 @@ func Test_server_SearchByID(t *testing.T) { { name: "Boundary Value Testing case 2.4: success search with ^M", args: args{ - ctx: ctx, indexID: "\r", searchID: "\r", }, @@ -975,7 +982,6 @@ func Test_server_SearchByID(t *testing.T) { { name: "Boundary Value Testing case 2.5: success search with ^[", args: args{ - ctx: ctx, indexID: string([]byte{27}), searchID: string([]byte{27}), }, @@ -986,7 +992,6 @@ func Test_server_SearchByID(t *testing.T) { { name: "Boundary Value Testing case 2.6: success search with ^?", args: args{ - ctx: ctx, indexID: string([]byte{127}), searchID: string([]byte{127}), }, @@ -997,7 +1002,6 @@ func Test_server_SearchByID(t *testing.T) { { name: "Boundary Value Testing case 3.1: success search with utf-8 ID from utf-8 index", args: args{ - ctx: ctx, indexID: utf8Str, searchID: utf8Str, }, @@ -1008,7 +1012,6 @@ func Test_server_SearchByID(t *testing.T) { { name: "Boundary Value Testing case 3.2: fail search with utf-8 ID from s-jis index", args: args{ - ctx: ctx, indexID: sjisStr, searchID: utf8Str, }, @@ -1020,7 +1023,6 @@ func Test_server_SearchByID(t *testing.T) { { name: "Boundary Value Testing case 3.3: fail search with utf-8 ID from euc-jp index", args: args{ - ctx: ctx, indexID: eucjpStr, searchID: utf8Str, }, @@ -1032,7 +1034,6 @@ func Test_server_SearchByID(t *testing.T) { { name: "Boundary Value Testing case 3.4: fail search with s-jis ID from utf-8 index", args: args{ - ctx: ctx, indexID: utf8Str, searchID: sjisStr, }, @@ -1044,7 +1045,6 @@ func Test_server_SearchByID(t *testing.T) { { name: "Boundary Value Testing case 3.5: success search with s-jis ID from s-jis index", args: args{ - ctx: ctx, indexID: sjisStr, searchID: sjisStr, }, @@ -1055,7 +1055,6 @@ func Test_server_SearchByID(t *testing.T) { { name: "Boundary Value Testing case 3.6: fail search with s-jis ID from euc-jp index", args: args{ - ctx: ctx, indexID: eucjpStr, searchID: sjisStr, }, @@ -1067,7 +1066,6 @@ func Test_server_SearchByID(t *testing.T) { { name: "Boundary Value Testing case 3.7: fail search with euc-jp ID from utf-8 index", args: args{ - ctx: ctx, indexID: utf8Str, searchID: eucjpStr, }, @@ -1079,7 +1077,6 @@ func Test_server_SearchByID(t *testing.T) { { name: "Boundary Value Testing case 3.8: fail search with euc-jp ID from s-jis index", args: args{ - ctx: ctx, indexID: sjisStr, searchID: eucjpStr, }, @@ -1091,7 +1088,6 @@ func Test_server_SearchByID(t *testing.T) { { name: "Boundary Value Testing case 3.9: success search with euc-jp ID from euc-jp index", args: args{ - ctx: ctx, indexID: eucjpStr, searchID: eucjpStr, }, @@ -1102,7 +1098,6 @@ func Test_server_SearchByID(t *testing.T) { { name: "Boundary Value Testing case 4.1: success search with 😀", args: args{ - ctx: ctx, indexID: "😀", searchID: "😀", }, @@ -1116,10 +1111,13 @@ func Test_server_SearchByID(t *testing.T) { test := tc t.Run(test.name, func(tt *testing.T) { tt.Parallel() + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + if test.beforeFunc == nil { test.beforeFunc = defaultBeforeFunc } - s, err := test.beforeFunc(test.args) + s, err := test.beforeFunc(ctx, test.args) if err != nil { tt.Errorf("error = %v", err) } @@ -1135,7 +1133,7 @@ func Test_server_SearchByID(t *testing.T) { Id: test.args.searchID, Config: defaultSearch_Config, } - gotRes, err := s.SearchByID(test.args.ctx, req) + gotRes, err := s.SearchByID(ctx, req) if err := checkFunc(test.want, gotRes, err); err != nil { tt.Errorf("error = %v", err) } diff --git a/pkg/agent/core/ngt/handler/grpc/update_test.go b/pkg/agent/core/ngt/handler/grpc/update_test.go index 057f72d9fb..fd8332c0bc 100644 --- a/pkg/agent/core/ngt/handler/grpc/update_test.go +++ b/pkg/agent/core/ngt/handler/grpc/update_test.go @@ -122,7 +122,17 @@ func Test_server_Update(t *testing.T) { a.indexVector, } } - return buildIndex(ctx, request.Float, vector.Gaussian, insertNum, defaultInsertConfig, cfg, nil, []string{a.indexID}, overwriteVec) + + eg, ctx := errgroup.New(ctx) + ngt, err := newIndexedNGTService(ctx, eg, request.Float, vector.Gaussian, insertNum, defaultInsertConfig, cfg, nil, []string{a.indexID}, overwriteVec) + if err != nil { + return nil, err + } + s, err := New(WithErrGroup(eg), WithNGT(ngt)) + if err != nil { + return nil, err + } + return s, nil } } diff --git a/pkg/agent/core/ngt/handler/grpc/upsert_test.go b/pkg/agent/core/ngt/handler/grpc/upsert_test.go index 64f2407b2d..b3dbc1fed7 100644 --- a/pkg/agent/core/ngt/handler/grpc/upsert_test.go +++ b/pkg/agent/core/ngt/handler/grpc/upsert_test.go @@ -125,7 +125,17 @@ func Test_server_Upsert(t *testing.T) { opt.vec, } } - return buildIndex(ctx, request.Float, vector.Gaussian, insertNum, defaultInsertConfig, cfg, nil, overwriteID, overwriteVec) + + eg, ctx := errgroup.New(ctx) + ngt, err := newIndexedNGTService(ctx, eg, request.Float, vector.Gaussian, insertNum, defaultInsertConfig, cfg, nil, overwriteID, overwriteVec) + if err != nil { + return nil, err + } + s, err := New(WithErrGroup(eg), WithNGT(ngt)) + if err != nil { + return nil, err + } + return s, nil } } diff --git a/pkg/agent/core/ngt/service/ngt.go b/pkg/agent/core/ngt/service/ngt.go index 15e2b24a60..902fb2bd22 100644 --- a/pkg/agent/core/ngt/service/ngt.go +++ b/pkg/agent/core/ngt/service/ngt.go @@ -99,6 +99,7 @@ type ngt struct { // counters nocie uint64 // number of create index execution nogce uint64 // number of proactive GC execution + wfci uint64 // wait for create indexing // configurations inMem bool // in-memory mode @@ -202,11 +203,7 @@ func New(cfg *config.NGT, opts ...Option) (nn NGT, err error) { n.dcd = true } if n.vq == nil { - n.vq, err = vqueue.New( - vqueue.WithErrGroup(n.eg), - vqueue.WithInsertBufferPoolSize(cfg.VQueue.InsertBufferPoolSize), - vqueue.WithDeleteBufferPoolSize(cfg.VQueue.DeleteBufferPoolSize), - ) + n.vq, err = vqueue.New() if err != nil { return nil, err } @@ -827,6 +824,12 @@ func (n *ngt) CreateIndex(ctx context.Context, poolSize uint32) (err error) { if ic == 0 { return errors.ErrUncommittedIndexNotFound } + wf := atomic.AddUint64(&n.wfci, 1) + if wf > 1 { + atomic.AddUint64(&n.wfci, ^uint64(0)) + log.Debugf("concurrent create index waiting detected this request will be ignored, concurrent: %d", wf) + return nil + } err = func() error { ticker := time.NewTicker(time.Millisecond * 100) defer ticker.Stop() @@ -835,10 +838,12 @@ func (n *ngt) CreateIndex(ctx context.Context, poolSize uint32) (err error) { runtime.Gosched() select { case <-ctx.Done(): + atomic.AddUint64(&n.wfci, ^uint64(0)) return ctx.Err() case <-ticker.C: } } + atomic.AddUint64(&n.wfci, ^uint64(0)) return nil }() if err != nil { @@ -857,17 +862,20 @@ func (n *ngt) CreateIndex(ctx context.Context, poolSize uint32) (err error) { log.Infof("create index operation started, uncommitted indexes = %d", ic) log.Debug("create index delete phase started") n.vq.RangePopDelete(ctx, now, func(uuid string) bool { + log.Debugf("start delete operation for kvsdb id: %s", uuid) oid, ok := n.kvs.Delete(uuid) if !ok { log.Warn(errors.ErrObjectIDNotFound(uuid)) return true } + log.Debugf("start remove operation for ngt index id: %s, oid: %d", uuid, oid) if err := n.core.Remove(uint(oid)); err != nil { log.Errorf("failed to remove oid: %d from ngt index. error: %v", oid, err) n.fmu.Lock() n.fmap[uuid] = oid n.fmu.Unlock() } + log.Debugf("removed from ngt index and kvsdb id: %s, oid: %d", uuid, oid) return true }) log.Debug("create index delete phase finished") @@ -875,28 +883,31 @@ func (n *ngt) CreateIndex(ctx context.Context, poolSize uint32) (err error) { log.Debug("create index insert phase started") var icnt uint32 n.vq.RangePopInsert(ctx, now, func(uuid string, vector []float32) bool { + log.Debugf("start insert operation for ngt index id: %s", uuid) oid, err := n.core.Insert(vector) if err != nil { log.Warnf("failed to insert vector uuid: %s vec: %v to ngt index. error: %v", uuid, vector, err) - if !errors.Is(err, errors.ErrIncompatibleDimensionSize(len(vector), n.dim)) { - oid, err = n.core.Insert(vector) - if err != nil { - log.Errorf("failed to retry insert vector uuid: %s vec: %v to ngt index. error: %v", uuid, vector, err) - return true - } - n.kvs.Set(uuid, uint32(oid)) - atomic.AddUint32(&icnt, 1) + if errors.Is(err, errors.ErrIncompatibleDimensionSize(len(vector), n.dim)) { + log.Error(err) + return true + } + oid, err = n.core.Insert(vector) + if err != nil { + log.Errorf("failed to retry insert vector uuid: %s vec: %v to ngt index. error: %v", uuid, vector, err) + return true } - } else { - n.kvs.Set(uuid, uint32(oid)) - atomic.AddUint32(&icnt, 1) } + log.Debugf("start insert operation for kvsdb id: %s, oid: %d", uuid, oid) + n.kvs.Set(uuid, uint32(oid)) + atomic.AddUint32(&icnt, 1) + n.fmu.Lock() _, ok := n.fmap[uuid] if ok { delete(n.fmap, uuid) } n.fmu.Unlock() + log.Debugf("inserted to ngt index and kvsdb id: %s, oid: %d", uuid, oid) return true }) if poolSize <= 0 { @@ -1187,8 +1198,11 @@ func (n *ngt) Exists(uuid string) (oid uint32, ok bool) { return 0, false } if n.vq.DVExists(uuid) { - log.Debugf("Exists\tuuid: %s's data found in kvsdb and not found in insert vqueue, but delete vqueue data exists. the object will be delete soon\terror: %v", - uuid, errors.ErrObjectIDNotFound(uuid)) + log.Debugf( + "Exists\tuuid: %s's data found in kvsdb and not found in insert vqueue, but delete vqueue data exists. the object will be delete soon\terror: %v", + uuid, + errors.ErrObjectIDNotFound(uuid), + ) return 0, false } } diff --git a/pkg/agent/core/ngt/service/ngt_test.go b/pkg/agent/core/ngt/service/ngt_test.go index efcb994ead..fdd6793dbf 100644 --- a/pkg/agent/core/ngt/service/ngt_test.go +++ b/pkg/agent/core/ngt/service/ngt_test.go @@ -19,19 +19,28 @@ package service import ( "context" + "fmt" + "math" "reflect" + "sync" "sync/atomic" "testing" "time" + "github.com/google/uuid" + "github.com/vdaas/vald/apis/grpc/v1/payload" + "github.com/vdaas/vald/internal/client/v1/client/vald" "github.com/vdaas/vald/internal/config" core "github.com/vdaas/vald/internal/core/algorithm/ngt" "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/internal/errors" + "github.com/vdaas/vald/internal/log" + "github.com/vdaas/vald/internal/test/data/vector" "github.com/vdaas/vald/internal/test/goleak" "github.com/vdaas/vald/pkg/agent/core/ngt/model" "github.com/vdaas/vald/pkg/agent/core/ngt/service/kvs" "github.com/vdaas/vald/pkg/agent/core/ngt/service/vqueue" + "google.golang.org/grpc" ) func TestNew(t *testing.T) { @@ -48,8 +57,8 @@ func TestNew(t *testing.T) { args args want want checkFunc func(want, NGT, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, gotNn NGT, err error) error { if !errors.Is(err, w.err) { @@ -71,6 +80,12 @@ func TestNew(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -85,6 +100,12 @@ func TestNew(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -96,10 +117,10 @@ func TestNew(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -163,8 +184,8 @@ func Test_ngt_load(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -218,6 +239,12 @@ func Test_ngt_load(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -267,6 +294,12 @@ func Test_ngt_load(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -278,10 +311,10 @@ func Test_ngt_load(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -377,8 +410,8 @@ func Test_ngt_initNGT(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -430,6 +463,12 @@ func Test_ngt_initNGT(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -477,6 +516,12 @@ func Test_ngt_initNGT(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -488,10 +533,10 @@ func Test_ngt_initNGT(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -587,8 +632,8 @@ func Test_ngt_loadKVS(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -640,6 +685,12 @@ func Test_ngt_loadKVS(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -687,6 +738,12 @@ func Test_ngt_loadKVS(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -698,10 +755,10 @@ func Test_ngt_loadKVS(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -797,8 +854,8 @@ func Test_ngt_Start(t *testing.T) { fields fields want want checkFunc func(want, <-chan error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, got <-chan error) error { if !reflect.DeepEqual(got, w.want) { @@ -850,6 +907,12 @@ func Test_ngt_Start(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -897,6 +960,12 @@ func Test_ngt_Start(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -908,10 +977,10 @@ func Test_ngt_Start(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -1011,8 +1080,8 @@ func Test_ngt_Search(t *testing.T) { fields fields want want checkFunc func(want, []model.Distance, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, got []model.Distance, err error) error { if !errors.Is(err, w.err) { @@ -1070,6 +1139,12 @@ func Test_ngt_Search(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -1120,6 +1195,12 @@ func Test_ngt_Search(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -1131,10 +1212,10 @@ func Test_ngt_Search(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -1235,8 +1316,8 @@ func Test_ngt_SearchByID(t *testing.T) { fields fields want want checkFunc func(want, []float32, []model.Distance, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, gotVec []float32, gotDst []model.Distance, err error) error { if !errors.Is(err, w.err) { @@ -1297,6 +1378,12 @@ func Test_ngt_SearchByID(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -1347,6 +1434,12 @@ func Test_ngt_SearchByID(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -1358,10 +1451,10 @@ func Test_ngt_SearchByID(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -1459,8 +1552,8 @@ func Test_ngt_LinearSearch(t *testing.T) { fields fields want want checkFunc func(want, []model.Distance, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, got []model.Distance, err error) error { if !errors.Is(err, w.err) { @@ -1516,6 +1609,12 @@ func Test_ngt_LinearSearch(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -1564,6 +1663,12 @@ func Test_ngt_LinearSearch(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -1575,10 +1680,10 @@ func Test_ngt_LinearSearch(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -1677,8 +1782,8 @@ func Test_ngt_LinearSearchByID(t *testing.T) { fields fields want want checkFunc func(want, []float32, []model.Distance, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, gotVec []float32, gotDst []model.Distance, err error) error { if !errors.Is(err, w.err) { @@ -1737,6 +1842,12 @@ func Test_ngt_LinearSearchByID(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -1785,6 +1896,12 @@ func Test_ngt_LinearSearchByID(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -1796,10 +1913,10 @@ func Test_ngt_LinearSearchByID(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -1896,8 +2013,8 @@ func Test_ngt_Insert(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -1950,6 +2067,12 @@ func Test_ngt_Insert(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -1998,6 +2121,12 @@ func Test_ngt_Insert(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -2009,10 +2138,10 @@ func Test_ngt_Insert(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -2110,8 +2239,8 @@ func Test_ngt_InsertWithTime(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -2165,6 +2294,12 @@ func Test_ngt_InsertWithTime(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -2214,6 +2349,12 @@ func Test_ngt_InsertWithTime(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -2225,10 +2366,10 @@ func Test_ngt_InsertWithTime(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -2327,8 +2468,8 @@ func Test_ngt_insert(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -2383,6 +2524,12 @@ func Test_ngt_insert(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -2433,6 +2580,12 @@ func Test_ngt_insert(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -2444,10 +2597,10 @@ func Test_ngt_insert(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -2543,8 +2696,8 @@ func Test_ngt_InsertMultiple(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -2596,6 +2749,12 @@ func Test_ngt_InsertMultiple(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -2643,6 +2802,12 @@ func Test_ngt_InsertMultiple(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -2654,10 +2819,10 @@ func Test_ngt_InsertMultiple(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -2754,8 +2919,8 @@ func Test_ngt_InsertMultipleWithTime(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -2808,6 +2973,12 @@ func Test_ngt_InsertMultipleWithTime(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -2856,6 +3027,12 @@ func Test_ngt_InsertMultipleWithTime(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -2867,10 +3044,10 @@ func Test_ngt_InsertMultipleWithTime(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -2968,8 +3145,8 @@ func Test_ngt_insertMultiple(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -3023,6 +3200,12 @@ func Test_ngt_insertMultiple(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -3072,6 +3255,12 @@ func Test_ngt_insertMultiple(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -3083,10 +3272,10 @@ func Test_ngt_insertMultiple(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -3183,8 +3372,8 @@ func Test_ngt_Update(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -3237,6 +3426,12 @@ func Test_ngt_Update(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -3285,6 +3480,12 @@ func Test_ngt_Update(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -3296,10 +3497,10 @@ func Test_ngt_Update(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -3397,8 +3598,8 @@ func Test_ngt_UpdateWithTime(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -3452,6 +3653,12 @@ func Test_ngt_UpdateWithTime(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -3501,6 +3708,12 @@ func Test_ngt_UpdateWithTime(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -3512,10 +3725,10 @@ func Test_ngt_UpdateWithTime(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -3613,8 +3826,8 @@ func Test_ngt_update(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -3668,6 +3881,12 @@ func Test_ngt_update(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -3717,6 +3936,12 @@ func Test_ngt_update(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -3728,10 +3953,10 @@ func Test_ngt_update(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -3827,8 +4052,8 @@ func Test_ngt_UpdateMultiple(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -3880,6 +4105,12 @@ func Test_ngt_UpdateMultiple(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -3927,6 +4158,12 @@ func Test_ngt_UpdateMultiple(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -3938,10 +4175,10 @@ func Test_ngt_UpdateMultiple(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -4038,8 +4275,8 @@ func Test_ngt_UpdateMultipleWithTime(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -4092,6 +4329,12 @@ func Test_ngt_UpdateMultipleWithTime(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -4140,6 +4383,12 @@ func Test_ngt_UpdateMultipleWithTime(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -4151,10 +4400,10 @@ func Test_ngt_UpdateMultipleWithTime(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -4251,8 +4500,8 @@ func Test_ngt_updateMultiple(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -4305,6 +4554,12 @@ func Test_ngt_updateMultiple(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -4353,6 +4608,12 @@ func Test_ngt_updateMultiple(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -4364,10 +4625,10 @@ func Test_ngt_updateMultiple(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -4463,8 +4724,8 @@ func Test_ngt_Delete(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -4516,6 +4777,12 @@ func Test_ngt_Delete(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -4563,6 +4830,12 @@ func Test_ngt_Delete(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -4574,10 +4847,10 @@ func Test_ngt_Delete(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -4674,8 +4947,8 @@ func Test_ngt_DeleteWithTime(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -4728,6 +5001,12 @@ func Test_ngt_DeleteWithTime(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -4776,6 +5055,12 @@ func Test_ngt_DeleteWithTime(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -4787,10 +5072,10 @@ func Test_ngt_DeleteWithTime(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -4888,8 +5173,8 @@ func Test_ngt_delete(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -4943,6 +5228,12 @@ func Test_ngt_delete(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -4992,6 +5283,12 @@ func Test_ngt_delete(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -5003,10 +5300,10 @@ func Test_ngt_delete(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -5102,8 +5399,8 @@ func Test_ngt_DeleteMultiple(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -5155,6 +5452,12 @@ func Test_ngt_DeleteMultiple(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -5202,6 +5505,12 @@ func Test_ngt_DeleteMultiple(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -5213,10 +5522,10 @@ func Test_ngt_DeleteMultiple(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -5313,8 +5622,8 @@ func Test_ngt_DeleteMultipleWithTime(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -5367,6 +5676,12 @@ func Test_ngt_DeleteMultipleWithTime(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -5415,6 +5730,12 @@ func Test_ngt_DeleteMultipleWithTime(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -5426,10 +5747,10 @@ func Test_ngt_DeleteMultipleWithTime(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -5527,8 +5848,8 @@ func Test_ngt_deleteMultiple(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -5582,6 +5903,12 @@ func Test_ngt_deleteMultiple(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -5631,6 +5958,12 @@ func Test_ngt_deleteMultiple(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -5642,10 +5975,10 @@ func Test_ngt_deleteMultiple(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -5742,8 +6075,8 @@ func Test_ngt_CreateIndex(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -5796,6 +6129,12 @@ func Test_ngt_CreateIndex(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -5844,6 +6183,12 @@ func Test_ngt_CreateIndex(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -5855,10 +6200,10 @@ func Test_ngt_CreateIndex(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -5952,8 +6297,8 @@ func Test_ngt_removeInvalidIndex(t *testing.T) { fields fields want want checkFunc func(want) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want) error { return nil @@ -6002,6 +6347,12 @@ func Test_ngt_removeInvalidIndex(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -6049,6 +6400,12 @@ func Test_ngt_removeInvalidIndex(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -6060,10 +6417,10 @@ func Test_ngt_removeInvalidIndex(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -6159,8 +6516,8 @@ func Test_ngt_SaveIndex(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -6212,6 +6569,12 @@ func Test_ngt_SaveIndex(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -6259,6 +6622,12 @@ func Test_ngt_SaveIndex(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -6270,10 +6639,10 @@ func Test_ngt_SaveIndex(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -6369,8 +6738,8 @@ func Test_ngt_saveIndex(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -6422,6 +6791,12 @@ func Test_ngt_saveIndex(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -6469,6 +6844,12 @@ func Test_ngt_saveIndex(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -6480,10 +6861,10 @@ func Test_ngt_saveIndex(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -6580,8 +6961,8 @@ func Test_ngt_CreateAndSaveIndex(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -6634,6 +7015,12 @@ func Test_ngt_CreateAndSaveIndex(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -6682,6 +7069,12 @@ func Test_ngt_CreateAndSaveIndex(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -6693,10 +7086,10 @@ func Test_ngt_CreateAndSaveIndex(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -6792,8 +7185,8 @@ func Test_ngt_moveAndSwitchSavedData(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -6845,6 +7238,12 @@ func Test_ngt_moveAndSwitchSavedData(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -6892,6 +7291,12 @@ func Test_ngt_moveAndSwitchSavedData(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -6903,10 +7308,10 @@ func Test_ngt_moveAndSwitchSavedData(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -6998,8 +7403,8 @@ func Test_ngt_mktmp(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func() - afterFunc func() + beforeFunc func(*testing.T) + afterFunc func(*testing.T) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -7048,6 +7453,12 @@ func Test_ngt_mktmp(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, }, */ @@ -7092,6 +7503,12 @@ func Test_ngt_mktmp(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, } }(), */ @@ -7103,10 +7520,10 @@ func Test_ngt_mktmp(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc() + test.beforeFunc(tt) } if test.afterFunc != nil { - defer test.afterFunc() + defer test.afterFunc(tt) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -7203,8 +7620,8 @@ func Test_ngt_Exists(t *testing.T) { fields fields want want checkFunc func(want, uint32, bool) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, gotOid uint32, gotOk bool) error { if !reflect.DeepEqual(gotOid, w.wantOid) { @@ -7259,6 +7676,12 @@ func Test_ngt_Exists(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -7306,6 +7729,12 @@ func Test_ngt_Exists(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -7317,10 +7746,10 @@ func Test_ngt_Exists(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -7417,8 +7846,8 @@ func Test_ngt_GetObject(t *testing.T) { fields fields want want checkFunc func(want, []float32, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, gotVec []float32, err error) error { if !errors.Is(err, w.err) { @@ -7473,6 +7902,12 @@ func Test_ngt_GetObject(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -7520,6 +7955,12 @@ func Test_ngt_GetObject(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -7531,10 +7972,10 @@ func Test_ngt_GetObject(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -7631,8 +8072,8 @@ func Test_ngt_readyForUpdate(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -7685,6 +8126,12 @@ func Test_ngt_readyForUpdate(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -7733,6 +8180,12 @@ func Test_ngt_readyForUpdate(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -7744,10 +8197,10 @@ func Test_ngt_readyForUpdate(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -7839,8 +8292,8 @@ func Test_ngt_IsSaving(t *testing.T) { fields fields want want checkFunc func(want, bool) error - beforeFunc func() - afterFunc func() + beforeFunc func(*testing.T) + afterFunc func(*testing.T) } defaultCheckFunc := func(w want, got bool) error { if !reflect.DeepEqual(got, w.want) { @@ -7889,6 +8342,12 @@ func Test_ngt_IsSaving(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, }, */ @@ -7933,6 +8392,12 @@ func Test_ngt_IsSaving(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, } }(), */ @@ -7944,10 +8409,10 @@ func Test_ngt_IsSaving(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc() + test.beforeFunc(tt) } if test.afterFunc != nil { - defer test.afterFunc() + defer test.afterFunc(tt) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -8039,8 +8504,8 @@ func Test_ngt_IsIndexing(t *testing.T) { fields fields want want checkFunc func(want, bool) error - beforeFunc func() - afterFunc func() + beforeFunc func(*testing.T) + afterFunc func(*testing.T) } defaultCheckFunc := func(w want, got bool) error { if !reflect.DeepEqual(got, w.want) { @@ -8089,6 +8554,12 @@ func Test_ngt_IsIndexing(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, }, */ @@ -8133,6 +8604,12 @@ func Test_ngt_IsIndexing(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, } }(), */ @@ -8144,10 +8621,10 @@ func Test_ngt_IsIndexing(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc() + test.beforeFunc(tt) } if test.afterFunc != nil { - defer test.afterFunc() + defer test.afterFunc(tt) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -8243,8 +8720,8 @@ func Test_ngt_UUIDs(t *testing.T) { fields fields want want checkFunc func(want, []string) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, gotUuids []string) error { if !reflect.DeepEqual(gotUuids, w.wantUuids) { @@ -8296,6 +8773,12 @@ func Test_ngt_UUIDs(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -8343,6 +8826,12 @@ func Test_ngt_UUIDs(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -8354,10 +8843,10 @@ func Test_ngt_UUIDs(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -8449,8 +8938,8 @@ func Test_ngt_NumberOfCreateIndexExecution(t *testing.T) { fields fields want want checkFunc func(want, uint64) error - beforeFunc func() - afterFunc func() + beforeFunc func(*testing.T) + afterFunc func(*testing.T) } defaultCheckFunc := func(w want, got uint64) error { if !reflect.DeepEqual(got, w.want) { @@ -8499,6 +8988,12 @@ func Test_ngt_NumberOfCreateIndexExecution(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, }, */ @@ -8543,6 +9038,12 @@ func Test_ngt_NumberOfCreateIndexExecution(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, } }(), */ @@ -8554,10 +9055,10 @@ func Test_ngt_NumberOfCreateIndexExecution(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc() + test.beforeFunc(tt) } if test.afterFunc != nil { - defer test.afterFunc() + defer test.afterFunc(tt) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -8649,8 +9150,8 @@ func Test_ngt_NumberOfProactiveGCExecution(t *testing.T) { fields fields want want checkFunc func(want, uint64) error - beforeFunc func() - afterFunc func() + beforeFunc func(*testing.T) + afterFunc func(*testing.T) } defaultCheckFunc := func(w want, got uint64) error { if !reflect.DeepEqual(got, w.want) { @@ -8699,6 +9200,12 @@ func Test_ngt_NumberOfProactiveGCExecution(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, }, */ @@ -8743,6 +9250,12 @@ func Test_ngt_NumberOfProactiveGCExecution(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, } }(), */ @@ -8754,10 +9267,10 @@ func Test_ngt_NumberOfProactiveGCExecution(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc() + test.beforeFunc(tt) } if test.afterFunc != nil { - defer test.afterFunc() + defer test.afterFunc(tt) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -8847,8 +9360,8 @@ func Test_ngt_gc(t *testing.T) { fields fields want want checkFunc func(want) error - beforeFunc func() - afterFunc func() + beforeFunc func(*testing.T) + afterFunc func(*testing.T) } defaultCheckFunc := func(w want) error { return nil @@ -8894,6 +9407,12 @@ func Test_ngt_gc(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, }, */ @@ -8938,6 +9457,12 @@ func Test_ngt_gc(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, } }(), */ @@ -8949,10 +9474,10 @@ func Test_ngt_gc(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc() + test.beforeFunc(tt) } if test.afterFunc != nil { - defer test.afterFunc() + defer test.afterFunc(tt) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -9044,8 +9569,8 @@ func Test_ngt_Len(t *testing.T) { fields fields want want checkFunc func(want, uint64) error - beforeFunc func() - afterFunc func() + beforeFunc func(*testing.T) + afterFunc func(*testing.T) } defaultCheckFunc := func(w want, got uint64) error { if !reflect.DeepEqual(got, w.want) { @@ -9094,6 +9619,12 @@ func Test_ngt_Len(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, }, */ @@ -9138,6 +9669,12 @@ func Test_ngt_Len(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, } }(), */ @@ -9149,10 +9686,10 @@ func Test_ngt_Len(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc() + test.beforeFunc(tt) } if test.afterFunc != nil { - defer test.afterFunc() + defer test.afterFunc(tt) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -9244,8 +9781,8 @@ func Test_ngt_InsertVQueueBufferLen(t *testing.T) { fields fields want want checkFunc func(want, uint64) error - beforeFunc func() - afterFunc func() + beforeFunc func(*testing.T) + afterFunc func(*testing.T) } defaultCheckFunc := func(w want, got uint64) error { if !reflect.DeepEqual(got, w.want) { @@ -9294,6 +9831,12 @@ func Test_ngt_InsertVQueueBufferLen(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, }, */ @@ -9338,6 +9881,12 @@ func Test_ngt_InsertVQueueBufferLen(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, } }(), */ @@ -9349,10 +9898,10 @@ func Test_ngt_InsertVQueueBufferLen(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc() + test.beforeFunc(tt) } if test.afterFunc != nil { - defer test.afterFunc() + defer test.afterFunc(tt) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -9444,8 +9993,8 @@ func Test_ngt_DeleteVQueueBufferLen(t *testing.T) { fields fields want want checkFunc func(want, uint64) error - beforeFunc func() - afterFunc func() + beforeFunc func(*testing.T) + afterFunc func(*testing.T) } defaultCheckFunc := func(w want, got uint64) error { if !reflect.DeepEqual(got, w.want) { @@ -9494,6 +10043,12 @@ func Test_ngt_DeleteVQueueBufferLen(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, }, */ @@ -9538,6 +10093,12 @@ func Test_ngt_DeleteVQueueBufferLen(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, } }(), */ @@ -9549,10 +10110,10 @@ func Test_ngt_DeleteVQueueBufferLen(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc() + test.beforeFunc(tt) } if test.afterFunc != nil { - defer test.afterFunc() + defer test.afterFunc(tt) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -9644,8 +10205,8 @@ func Test_ngt_GetDimensionSize(t *testing.T) { fields fields want want checkFunc func(want, int) error - beforeFunc func() - afterFunc func() + beforeFunc func(*testing.T) + afterFunc func(*testing.T) } defaultCheckFunc := func(w want, got int) error { if !reflect.DeepEqual(got, w.want) { @@ -9694,6 +10255,12 @@ func Test_ngt_GetDimensionSize(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, }, */ @@ -9738,6 +10305,12 @@ func Test_ngt_GetDimensionSize(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, } }(), */ @@ -9749,10 +10322,10 @@ func Test_ngt_GetDimensionSize(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc() + test.beforeFunc(tt) } if test.afterFunc != nil { - defer test.afterFunc() + defer test.afterFunc(tt) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -9848,8 +10421,8 @@ func Test_ngt_Close(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -9901,6 +10474,12 @@ func Test_ngt_Close(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -9948,6 +10527,12 @@ func Test_ngt_Close(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -9959,10 +10544,10 @@ func Test_ngt_Close(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -10010,3 +10595,377 @@ func Test_ngt_Close(t *testing.T) { }) } } + +type index struct { + uuid string + vec []float32 +} + +func Test_ngt_InsertUpsert(t *testing.T) { + if testing.Short() { + t.Skip("The execution of this test takes a lot of time, so it is not performed during the short test\ttest: Test_ngt_InsertUpsert") + return + } + type args struct { + idxes []index + poolSize uint32 + bulkSize int + } + type fields struct { + svcCfg *config.NGT + svcOpts []Option + + core core.NGT + eg errgroup.Group + kvs kvs.BidiMap + fmu sync.Mutex + fmap map[string]uint32 + vq vqueue.Queue + indexing atomic.Value + saving atomic.Value + cimu sync.Mutex + lastNocie uint64 + nocie uint64 + nogce uint64 + inMem bool + dim int + alen int + lim time.Duration + dur time.Duration + sdur time.Duration + minLit time.Duration + maxLit time.Duration + litFactor time.Duration + enableProactiveGC bool + enableCopyOnWrite bool + path string + smu sync.Mutex + tmpPath atomic.Value + oldPath string + basePath string + cowmu sync.Mutex + backupGen uint64 + poolSize uint32 + radius float32 + epsilon float32 + idelay time.Duration + dcd bool + kvsdbConcurrency int + } + type want struct { + err error + } + type test struct { + name string + args args + fields fields + want want + checkFunc func(want, error) error + beforeFunc func(args) + afterFunc func(args) + } + defaultCheckFunc := func(w want, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + return nil + } + var ( + // default NGT configuration for test + kvsdbCfg = &config.KVSDB{} + vqueueCfg = &config.VQueue{} + ) + tests := []test{ + { + name: "insert & upsert 10000000 random and 11 digits added to each vector element", + args: args{ + idxes: createRandomData(10000000, &createRandomDataConfig{ + additionaldigits: 11, + }), + poolSize: 100000, + bulkSize: 100000, + }, + fields: fields{ + svcCfg: &config.NGT{ + Dimension: 128, + DistanceType: core.Cosine.String(), + ObjectType: core.Uint8.String(), + KVSDB: kvsdbCfg, + VQueue: vqueueCfg, + }, + svcOpts: []Option{ + WithEnableInMemoryMode(true), + }, + }, + }, + } + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + // defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + + eg, _ := errgroup.New(ctx) + n, err := New(test.fields.svcCfg, append(test.fields.svcOpts, WithErrGroup(eg))...) + if err != nil { + tt.Errorf("failed to init ngt service, error = %v", err) + } + var wg sync.WaitGroup + count := 0 + for _, idx := range test.args.idxes { + count++ + err = n.Insert(idx.uuid, idx.vec) + if err := checkFunc(test.want, err); err != nil { + tt.Errorf("error = %v", err) + } + + if count >= test.args.bulkSize { + wg.Add(1) + eg.Go(func() error { + defer wg.Done() + err = n.CreateAndSaveIndex(ctx, test.args.poolSize) + if err != nil { + tt.Errorf("error creating index: %v", err) + } + return nil + }) + count = 0 + } + } + wg.Wait() + + log.Warn("start create index operation") + err = n.CreateAndSaveIndex(ctx, test.args.poolSize) + if err != nil { + tt.Errorf("error creating index: %v", err) + } + log.Warn("start update operation") + for i := 0; i < 100; i++ { + idx := i + eg.Go(func() error { + log.Warnf("started %d-1", idx) + var wgu sync.WaitGroup + count = 0 + for _, idx := range test.args.idxes[:len(test.args.idxes)/3] { + count++ + _ = n.Delete(idx.uuid) + _ = n.Insert(idx.uuid, idx.vec) + } + wgu.Wait() + log.Warnf("finished %d-1", idx) + return nil + }) + + eg.Go(func() error { + log.Warnf("started %d-2", idx) + var wgu sync.WaitGroup + count = 0 + for _, idx := range test.args.idxes[len(test.args.idxes)/3 : 2*len(test.args.idxes)/3] { + count++ + _ = n.Delete(idx.uuid) + _ = n.Insert(idx.uuid, idx.vec) + } + wgu.Wait() + log.Warnf("finished %d-2", idx) + return nil + }) + + eg.Go(func() error { + log.Warnf("started %d-3", idx) + var wgu sync.WaitGroup + count = 0 + for _, idx := range test.args.idxes[2*len(test.args.idxes)/3:] { + count++ + _ = n.Delete(idx.uuid) + _ = n.Insert(idx.uuid, idx.vec) + } + wgu.Wait() + log.Warnf("finished %d-3", idx) + return nil + }) + } + eg.Wait() + + log.Warn("start final create index operation") + err = n.CreateAndSaveIndex(ctx, test.args.poolSize) + if err != nil { + tt.Errorf("error creating index: %v", err) + } + }) + } +} + +// NOTE: After moving this implementation to the e2e package, remove this test function. +func Test_ngt_E2E(t *testing.T) { + if testing.Short() { + t.Skip("The execution of this test takes a lot of time, so it is not performed during the short test\ttest: Test_ngt_E2E") + return + } + type args struct { + requests []*payload.Upsert_MultiRequest + + addr string + dialOpts []grpc.DialOption + } + type want struct { + err error + } + type test struct { + name string + args args + want want + checkFunc func(want, error) error + beforeFunc func(args) + afterFunc func(args) + } + defaultCheckFunc := func(w want, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) + } + return nil + } + multiUpsertRequestGenFunc := func(idxes []index, chunk int) (res []*payload.Upsert_MultiRequest) { + reqs := make([]*payload.Upsert_Request, 0, chunk) + for i := 0; i < len(idxes); i++ { + if len(reqs) == chunk-1 { + res = append(res, &payload.Upsert_MultiRequest{ + Requests: reqs, + }) + reqs = make([]*payload.Upsert_Request, 0, chunk) + } else { + reqs = append(reqs, &payload.Upsert_Request{ + Vector: &payload.Object_Vector{ + Id: idxes[i].uuid, + Vector: idxes[i].vec, + }, + Config: &payload.Upsert_Config{ + SkipStrictExistCheck: true, + }, + }) + } + } + if len(reqs) > 0 { + res = append(res, &payload.Upsert_MultiRequest{ + Requests: reqs, + }) + } + return res + } + + tests := []test{ + { + name: "insert & upsert 100 random", + args: args{ + requests: multiUpsertRequestGenFunc( + createRandomData(500000, new(createRandomDataConfig)), + 50, + ), + addr: "127.0.0.1:8080", + dialOpts: []grpc.DialOption{ + grpc.WithInsecure(), + }, + }, + }, + } + for _, tc := range tests { + test := tc + t.Run(test.name, func(tt *testing.T) { + tt.Parallel() + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + if test.beforeFunc != nil { + test.beforeFunc(test.args) + } + if test.afterFunc != nil { + defer test.afterFunc(test.args) + } + checkFunc := test.checkFunc + if test.checkFunc == nil { + checkFunc = defaultCheckFunc + } + conn, err := grpc.DialContext(ctx, test.args.addr, test.args.dialOpts...) + if err := checkFunc(test.want, err); err != nil { + t.Fatal(err) + } + defer func() { + if err := conn.Close(); err != nil { + t.Error(err) + } + }() + client := vald.NewValdClient(conn) + + for i := 0; i < 2; i++ { + for _, req := range test.args.requests { + _, err := client.MultiUpsert(ctx, req) + if err != nil { + t.Error(err) + } + } + log.Info("%d step: finished all requests", i+1) + time.Sleep(3 * time.Second) + } + }) + } +} + +type createRandomDataConfig struct { + additionaldigits int +} + +func (cfg *createRandomDataConfig) verify() *createRandomDataConfig { + if cfg == nil { + cfg = new(createRandomDataConfig) + } + if cfg.additionaldigits < 0 { + cfg.additionaldigits = 0 + } + return cfg +} + +func createRandomData(num int, cfg *createRandomDataConfig) []index { + cfg = cfg.verify() + + var ad float32 = 1.0 + for i := 0; i < cfg.additionaldigits; i++ { + ad = ad * 0.1 + } + + result := make([]index, 0) + f32s, _ := vector.GenF32Vec(vector.NegativeUniform, num, 128) + + for idx, vec := range f32s { + for i := range vec { + if f := vec[i] * ad; f == 0.0 { + if vec[i] > 0.0 { + vec[i] = math.MaxFloat32 + } else if vec[i] < 0.0 { + vec[i] = math.SmallestNonzeroFloat32 + } + continue + } + vec[i] = vec[i] * ad + } + result = append(result, index{ + uuid: fmt.Sprintf("%s_%s-%s:%d:%d,%d", uuid.New().String(), uuid.New().String(), uuid.New().String(), idx, idx/100, idx%100), + vec: vec, + }) + } + + return result +} diff --git a/pkg/agent/core/ngt/service/vqueue/uninserted_index_map.go b/pkg/agent/core/ngt/service/vqueue/indexmap.go similarity index 59% rename from pkg/agent/core/ngt/service/vqueue/uninserted_index_map.go rename to pkg/agent/core/ngt/service/vqueue/indexmap.go index a0a6a80f85..2dcd1497ad 100644 --- a/pkg/agent/core/ngt/service/vqueue/uninserted_index_map.go +++ b/pkg/agent/core/ngt/service/vqueue/indexmap.go @@ -19,40 +19,38 @@ import ( "unsafe" ) -type uiim struct { - mu sync.Mutex - - read atomic.Value - - dirty map[string]*entryUiim - +type indexMap struct { + mu sync.Mutex + read atomic.Value + dirty map[string]*entryIndexMap misses int } -type readOnlyUiim struct { - m map[string]*entryUiim +type readOnlyIndexMap struct { + m map[string]*entryIndexMap amended bool } // skipcq: GSC-G103 -var expungedUiim = unsafe.Pointer(new(index)) +var expungedIndexMap = unsafe.Pointer(new(index)) -type entryUiim struct { +type entryIndexMap struct { + // skipcq: GSC-G103 p unsafe.Pointer } -func newEntryUiim(i index) *entryUiim { +func newEntryIndexMap(i index) *entryIndexMap { // skipcq: GSC-G103 - return &entryUiim{p: unsafe.Pointer(&i)} + return &entryIndexMap{p: unsafe.Pointer(&i)} } -func (m *uiim) Load(key string) (value index, ok bool) { - read, _ := m.read.Load().(readOnlyUiim) +func (m *indexMap) Load(key string) (value index, ok bool) { + read, _ := m.read.Load().(readOnlyIndexMap) e, ok := read.m[key] if !ok && read.amended { m.mu.Lock() - read, _ = m.read.Load().(readOnlyUiim) + read, _ = m.read.Load().(readOnlyIndexMap) e, ok = read.m[key] if !ok && read.amended { e, ok = m.dirty[key] @@ -67,22 +65,22 @@ func (m *uiim) Load(key string) (value index, ok bool) { return e.load() } -func (e *entryUiim) load() (value index, ok bool) { +func (e *entryIndexMap) load() (value index, ok bool) { p := atomic.LoadPointer(&e.p) - if p == nil || p == expungedUiim { + if p == nil || p == expungedIndexMap { return value, false } return *(*index)(p), true } -func (m *uiim) Store(key string, value index) { - read, _ := m.read.Load().(readOnlyUiim) +func (m *indexMap) Store(key string, value index) { + read, _ := m.read.Load().(readOnlyIndexMap) if e, ok := read.m[key]; ok && e.tryStore(&value) { return } m.mu.Lock() - read, _ = m.read.Load().(readOnlyUiim) + read, _ = m.read.Load().(readOnlyIndexMap) if e, ok := read.m[key]; ok { if e.unexpungeLocked() { m.dirty[key] = e @@ -94,17 +92,17 @@ func (m *uiim) Store(key string, value index) { if !read.amended { m.dirtyLocked() - m.read.Store(readOnlyUiim{m: read.m, amended: true}) + m.read.Store(readOnlyIndexMap{m: read.m, amended: true}) } - m.dirty[key] = newEntryUiim(value) + m.dirty[key] = newEntryIndexMap(value) } m.mu.Unlock() } -func (e *entryUiim) tryStore(i *index) bool { +func (e *entryIndexMap) tryStore(i *index) bool { for { p := atomic.LoadPointer(&e.p) - if p == expungedUiim { + if p == expungedIndexMap { return false } // skipcq: GSC-G103 @@ -114,17 +112,17 @@ func (e *entryUiim) tryStore(i *index) bool { } } -func (e *entryUiim) unexpungeLocked() (wasExpunged bool) { - return atomic.CompareAndSwapPointer(&e.p, expungedUiim, nil) +func (e *entryIndexMap) unexpungeLocked() (wasExpunged bool) { + return atomic.CompareAndSwapPointer(&e.p, expungedIndexMap, nil) } -func (e *entryUiim) storeLocked(i *index) { +func (e *entryIndexMap) storeLocked(i *index) { // skipcq: GSC-G103 atomic.StorePointer(&e.p, unsafe.Pointer(i)) } -func (m *uiim) LoadOrStore(key string, value index) (actual index, loaded bool) { - read, _ := m.read.Load().(readOnlyUiim) +func (m *indexMap) LoadOrStore(key string, value index) (actual index, loaded bool) { + read, _ := m.read.Load().(readOnlyIndexMap) if e, ok := read.m[key]; ok { actual, loaded, ok := e.tryLoadOrStore(value) if ok { @@ -133,7 +131,7 @@ func (m *uiim) LoadOrStore(key string, value index) (actual index, loaded bool) } m.mu.Lock() - read, _ = m.read.Load().(readOnlyUiim) + read, _ = m.read.Load().(readOnlyIndexMap) if e, ok := read.m[key]; ok { if e.unexpungeLocked() { m.dirty[key] = e @@ -146,9 +144,9 @@ func (m *uiim) LoadOrStore(key string, value index) (actual index, loaded bool) if !read.amended { m.dirtyLocked() - m.read.Store(readOnlyUiim{m: read.m, amended: true}) + m.read.Store(readOnlyIndexMap{m: read.m, amended: true}) } - m.dirty[key] = newEntryUiim(value) + m.dirty[key] = newEntryIndexMap(value) actual, loaded = value, false } m.mu.Unlock() @@ -156,9 +154,9 @@ func (m *uiim) LoadOrStore(key string, value index) (actual index, loaded bool) return actual, loaded } -func (e *entryUiim) tryLoadOrStore(i index) (actual index, loaded, ok bool) { +func (e *entryIndexMap) tryLoadOrStore(i index) (actual index, loaded, ok bool) { p := atomic.LoadPointer(&e.p) - if p == expungedUiim { + if p == expungedIndexMap { return actual, false, false } if p != nil { @@ -167,12 +165,13 @@ func (e *entryUiim) tryLoadOrStore(i index) (actual index, loaded, ok bool) { ic := i for { + // skipcq: GSC-G103 if atomic.CompareAndSwapPointer(&e.p, nil, unsafe.Pointer(&ic)) { return i, false, true } p = atomic.LoadPointer(&e.p) - if p == expungedUiim { + if p == expungedIndexMap { return actual, false, false } if p != nil { @@ -181,12 +180,12 @@ func (e *entryUiim) tryLoadOrStore(i index) (actual index, loaded, ok bool) { } } -func (m *uiim) LoadAndDelete(key string) (value index, loaded bool) { - read, _ := m.read.Load().(readOnlyUiim) +func (m *indexMap) LoadAndDelete(key string) (value index, loaded bool) { + read, _ := m.read.Load().(readOnlyIndexMap) e, ok := read.m[key] if !ok && read.amended { m.mu.Lock() - read, _ = m.read.Load().(readOnlyUiim) + read, _ = m.read.Load().(readOnlyIndexMap) e, ok = read.m[key] if !ok && read.amended { e, ok = m.dirty[key] @@ -202,14 +201,14 @@ func (m *uiim) LoadAndDelete(key string) (value index, loaded bool) { return value, false } -func (m *uiim) Delete(key string) { +func (m *indexMap) Delete(key string) { m.LoadAndDelete(key) } -func (e *entryUiim) delete() (value index, ok bool) { +func (e *entryIndexMap) delete() (value index, ok bool) { for { p := atomic.LoadPointer(&e.p) - if p == nil || p == expungedUiim { + if p == nil || p == expungedIndexMap { return value, false } if atomic.CompareAndSwapPointer(&e.p, p, nil) { @@ -218,14 +217,14 @@ func (e *entryUiim) delete() (value index, ok bool) { } } -func (m *uiim) Range(f func(key string, value index) bool) { - read, _ := m.read.Load().(readOnlyUiim) +func (m *indexMap) Range(f func(key string, value index) bool) { + read, _ := m.read.Load().(readOnlyIndexMap) if read.amended { m.mu.Lock() - read, _ = m.read.Load().(readOnlyUiim) + read, _ = m.read.Load().(readOnlyIndexMap) if read.amended { - read = readOnlyUiim{m: m.dirty} + read = readOnlyIndexMap{m: m.dirty} m.read.Store(read) m.dirty = nil m.misses = 0 @@ -244,23 +243,23 @@ func (m *uiim) Range(f func(key string, value index) bool) { } } -func (m *uiim) missLocked() { +func (m *indexMap) missLocked() { m.misses++ if m.misses < len(m.dirty) { return } - m.read.Store(readOnlyUiim{m: m.dirty}) + m.read.Store(readOnlyIndexMap{m: m.dirty}) m.dirty = nil m.misses = 0 } -func (m *uiim) dirtyLocked() { +func (m *indexMap) dirtyLocked() { if m.dirty != nil { return } - read, _ := m.read.Load().(readOnlyUiim) - m.dirty = make(map[string]*entryUiim, len(read.m)) + read, _ := m.read.Load().(readOnlyIndexMap) + m.dirty = make(map[string]*entryIndexMap, len(read.m)) for k, e := range read.m { if !e.tryExpungeLocked() { m.dirty[k] = e @@ -268,13 +267,13 @@ func (m *uiim) dirtyLocked() { } } -func (e *entryUiim) tryExpungeLocked() (isExpunged bool) { +func (e *entryIndexMap) tryExpungeLocked() (isExpunged bool) { p := atomic.LoadPointer(&e.p) for p == nil { - if atomic.CompareAndSwapPointer(&e.p, nil, expungedUiim) { + if atomic.CompareAndSwapPointer(&e.p, nil, expungedIndexMap) { return true } p = atomic.LoadPointer(&e.p) } - return p == expungedUiim + return p == expungedIndexMap } diff --git a/pkg/agent/core/ngt/service/vqueue/uninserted_index_map_test.go b/pkg/agent/core/ngt/service/vqueue/indexmap_test.go similarity index 71% rename from pkg/agent/core/ngt/service/vqueue/uninserted_index_map_test.go rename to pkg/agent/core/ngt/service/vqueue/indexmap_test.go index b38df48df2..18a5af8056 100644 --- a/pkg/agent/core/ngt/service/vqueue/uninserted_index_map_test.go +++ b/pkg/agent/core/ngt/service/vqueue/indexmap_test.go @@ -1,20 +1,24 @@ +// // Copyright (C) 2019-2022 vdaas.org vald team // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// https://www.apache.org/licenses/LICENSE-2.0 +// https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +// + package vqueue import ( "reflect" + "sync" "sync/atomic" "testing" "unsafe" @@ -23,22 +27,22 @@ import ( "github.com/vdaas/vald/internal/test/goleak" ) -func Test_newEntryUiim(t *testing.T) { +func Test_newEntryIndexMap(t *testing.T) { type args struct { i index } type want struct { - want *entryUiim + want *entryIndexMap } type test struct { name string args args want want - checkFunc func(want, *entryUiim) error - beforeFunc func(args) - afterFunc func(args) + checkFunc func(want, *entryIndexMap) error + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } - defaultCheckFunc := func(w want, got *entryUiim) error { + defaultCheckFunc := func(w want, got *entryIndexMap) error { if !reflect.DeepEqual(got, w.want) { return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) } @@ -54,6 +58,12 @@ func Test_newEntryUiim(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -67,6 +77,12 @@ func Test_newEntryUiim(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -78,17 +94,17 @@ func Test_newEntryUiim(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { checkFunc = defaultCheckFunc } - got := newEntryUiim(test.args.i) + got := newEntryIndexMap(test.args.i) if err := checkFunc(test.want, got); err != nil { tt.Errorf("error = %v", err) } @@ -96,13 +112,14 @@ func Test_newEntryUiim(t *testing.T) { } } -func Test_uiim_Load(t *testing.T) { +func Test_indexMap_Load(t *testing.T) { type args struct { key string } type fields struct { + mu sync.Mutex read atomic.Value - dirty map[string]*entryUiim + dirty map[string]*entryIndexMap misses int } type want struct { @@ -115,8 +132,8 @@ func Test_uiim_Load(t *testing.T) { fields fields want want checkFunc func(want, index, bool) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, gotValue index, gotOk bool) error { if !reflect.DeepEqual(gotValue, w.wantValue) { @@ -136,12 +153,19 @@ func Test_uiim_Load(t *testing.T) { key: "", }, fields: fields { + mu: sync.Mutex{}, read: nil, dirty: nil, misses: 0, }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -154,12 +178,19 @@ func Test_uiim_Load(t *testing.T) { key: "", }, fields: fields { + mu: sync.Mutex{}, read: nil, dirty: nil, misses: 0, }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -171,16 +202,17 @@ func Test_uiim_Load(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { checkFunc = defaultCheckFunc } - m := &uiim{ + m := &indexMap{ + mu: test.fields.mu, read: test.fields.read, dirty: test.fields.dirty, misses: test.fields.misses, @@ -194,7 +226,7 @@ func Test_uiim_Load(t *testing.T) { } } -func Test_entryUiim_load(t *testing.T) { +func Test_entryIndexMap_load(t *testing.T) { type fields struct { p unsafe.Pointer } @@ -207,8 +239,8 @@ func Test_entryUiim_load(t *testing.T) { fields fields want want checkFunc func(want, index, bool) error - beforeFunc func() - afterFunc func() + beforeFunc func(*testing.T) + afterFunc func(*testing.T) } defaultCheckFunc := func(w want, gotValue index, gotOk bool) error { if !reflect.DeepEqual(gotValue, w.wantValue) { @@ -229,6 +261,12 @@ func Test_entryUiim_load(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, }, */ @@ -242,6 +280,12 @@ func Test_entryUiim_load(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, } }(), */ @@ -253,16 +297,16 @@ func Test_entryUiim_load(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc() + test.beforeFunc(tt) } if test.afterFunc != nil { - defer test.afterFunc() + defer test.afterFunc(tt) } checkFunc := test.checkFunc if test.checkFunc == nil { checkFunc = defaultCheckFunc } - e := &entryUiim{ + e := &entryIndexMap{ p: test.fields.p, } @@ -274,14 +318,15 @@ func Test_entryUiim_load(t *testing.T) { } } -func Test_uiim_Store(t *testing.T) { +func Test_indexMap_Store(t *testing.T) { type args struct { key string value index } type fields struct { + mu sync.Mutex read atomic.Value - dirty map[string]*entryUiim + dirty map[string]*entryIndexMap misses int } type want struct{} @@ -291,8 +336,8 @@ func Test_uiim_Store(t *testing.T) { fields fields want want checkFunc func(want) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want) error { return nil @@ -307,12 +352,19 @@ func Test_uiim_Store(t *testing.T) { value: index{}, }, fields: fields { + mu: sync.Mutex{}, read: nil, dirty: nil, misses: 0, }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -326,12 +378,19 @@ func Test_uiim_Store(t *testing.T) { value: index{}, }, fields: fields { + mu: sync.Mutex{}, read: nil, dirty: nil, misses: 0, }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -343,16 +402,17 @@ func Test_uiim_Store(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { checkFunc = defaultCheckFunc } - m := &uiim{ + m := &indexMap{ + mu: test.fields.mu, read: test.fields.read, dirty: test.fields.dirty, misses: test.fields.misses, @@ -366,7 +426,7 @@ func Test_uiim_Store(t *testing.T) { } } -func Test_entryUiim_tryStore(t *testing.T) { +func Test_entryIndexMap_tryStore(t *testing.T) { type args struct { i *index } @@ -382,8 +442,8 @@ func Test_entryUiim_tryStore(t *testing.T) { fields fields want want checkFunc func(want, bool) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, got bool) error { if !reflect.DeepEqual(got, w.want) { @@ -404,6 +464,12 @@ func Test_entryUiim_tryStore(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -420,6 +486,12 @@ func Test_entryUiim_tryStore(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -431,16 +503,16 @@ func Test_entryUiim_tryStore(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { checkFunc = defaultCheckFunc } - e := &entryUiim{ + e := &entryIndexMap{ p: test.fields.p, } @@ -452,7 +524,7 @@ func Test_entryUiim_tryStore(t *testing.T) { } } -func Test_entryUiim_unexpungeLocked(t *testing.T) { +func Test_entryIndexMap_unexpungeLocked(t *testing.T) { type fields struct { p unsafe.Pointer } @@ -464,8 +536,8 @@ func Test_entryUiim_unexpungeLocked(t *testing.T) { fields fields want want checkFunc func(want, bool) error - beforeFunc func() - afterFunc func() + beforeFunc func(*testing.T) + afterFunc func(*testing.T) } defaultCheckFunc := func(w want, gotWasExpunged bool) error { if !reflect.DeepEqual(gotWasExpunged, w.wantWasExpunged) { @@ -483,6 +555,12 @@ func Test_entryUiim_unexpungeLocked(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, }, */ @@ -496,6 +574,12 @@ func Test_entryUiim_unexpungeLocked(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, } }(), */ @@ -507,16 +591,16 @@ func Test_entryUiim_unexpungeLocked(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc() + test.beforeFunc(tt) } if test.afterFunc != nil { - defer test.afterFunc() + defer test.afterFunc(tt) } checkFunc := test.checkFunc if test.checkFunc == nil { checkFunc = defaultCheckFunc } - e := &entryUiim{ + e := &entryIndexMap{ p: test.fields.p, } @@ -528,7 +612,7 @@ func Test_entryUiim_unexpungeLocked(t *testing.T) { } } -func Test_entryUiim_storeLocked(t *testing.T) { +func Test_entryIndexMap_storeLocked(t *testing.T) { type args struct { i *index } @@ -542,8 +626,8 @@ func Test_entryUiim_storeLocked(t *testing.T) { fields fields want want checkFunc func(want) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want) error { return nil @@ -561,6 +645,12 @@ func Test_entryUiim_storeLocked(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -577,6 +667,12 @@ func Test_entryUiim_storeLocked(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -588,16 +684,16 @@ func Test_entryUiim_storeLocked(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { checkFunc = defaultCheckFunc } - e := &entryUiim{ + e := &entryIndexMap{ p: test.fields.p, } @@ -609,14 +705,15 @@ func Test_entryUiim_storeLocked(t *testing.T) { } } -func Test_uiim_LoadOrStore(t *testing.T) { +func Test_indexMap_LoadOrStore(t *testing.T) { type args struct { key string value index } type fields struct { + mu sync.Mutex read atomic.Value - dirty map[string]*entryUiim + dirty map[string]*entryIndexMap misses int } type want struct { @@ -629,8 +726,8 @@ func Test_uiim_LoadOrStore(t *testing.T) { fields fields want want checkFunc func(want, index, bool) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, gotActual index, gotLoaded bool) error { if !reflect.DeepEqual(gotActual, w.wantActual) { @@ -651,12 +748,19 @@ func Test_uiim_LoadOrStore(t *testing.T) { value: index{}, }, fields: fields { + mu: sync.Mutex{}, read: nil, dirty: nil, misses: 0, }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -670,12 +774,19 @@ func Test_uiim_LoadOrStore(t *testing.T) { value: index{}, }, fields: fields { + mu: sync.Mutex{}, read: nil, dirty: nil, misses: 0, }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -687,16 +798,17 @@ func Test_uiim_LoadOrStore(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { checkFunc = defaultCheckFunc } - m := &uiim{ + m := &indexMap{ + mu: test.fields.mu, read: test.fields.read, dirty: test.fields.dirty, misses: test.fields.misses, @@ -710,7 +822,7 @@ func Test_uiim_LoadOrStore(t *testing.T) { } } -func Test_entryUiim_tryLoadOrStore(t *testing.T) { +func Test_entryIndexMap_tryLoadOrStore(t *testing.T) { type args struct { i index } @@ -728,8 +840,8 @@ func Test_entryUiim_tryLoadOrStore(t *testing.T) { fields fields want want checkFunc func(want, index, bool, bool) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, gotActual index, gotLoaded bool, gotOk bool) error { if !reflect.DeepEqual(gotActual, w.wantActual) { @@ -756,6 +868,12 @@ func Test_entryUiim_tryLoadOrStore(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -772,6 +890,12 @@ func Test_entryUiim_tryLoadOrStore(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -783,16 +907,16 @@ func Test_entryUiim_tryLoadOrStore(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { checkFunc = defaultCheckFunc } - e := &entryUiim{ + e := &entryIndexMap{ p: test.fields.p, } @@ -804,13 +928,14 @@ func Test_entryUiim_tryLoadOrStore(t *testing.T) { } } -func Test_uiim_LoadAndDelete(t *testing.T) { +func Test_indexMap_LoadAndDelete(t *testing.T) { type args struct { key string } type fields struct { + mu sync.Mutex read atomic.Value - dirty map[string]*entryUiim + dirty map[string]*entryIndexMap misses int } type want struct { @@ -823,8 +948,8 @@ func Test_uiim_LoadAndDelete(t *testing.T) { fields fields want want checkFunc func(want, index, bool) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, gotValue index, gotLoaded bool) error { if !reflect.DeepEqual(gotValue, w.wantValue) { @@ -844,12 +969,19 @@ func Test_uiim_LoadAndDelete(t *testing.T) { key: "", }, fields: fields { + mu: sync.Mutex{}, read: nil, dirty: nil, misses: 0, }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -862,12 +994,19 @@ func Test_uiim_LoadAndDelete(t *testing.T) { key: "", }, fields: fields { + mu: sync.Mutex{}, read: nil, dirty: nil, misses: 0, }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -879,16 +1018,17 @@ func Test_uiim_LoadAndDelete(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { checkFunc = defaultCheckFunc } - m := &uiim{ + m := &indexMap{ + mu: test.fields.mu, read: test.fields.read, dirty: test.fields.dirty, misses: test.fields.misses, @@ -902,13 +1042,14 @@ func Test_uiim_LoadAndDelete(t *testing.T) { } } -func Test_uiim_Delete(t *testing.T) { +func Test_indexMap_Delete(t *testing.T) { type args struct { key string } type fields struct { + mu sync.Mutex read atomic.Value - dirty map[string]*entryUiim + dirty map[string]*entryIndexMap misses int } type want struct{} @@ -918,8 +1059,8 @@ func Test_uiim_Delete(t *testing.T) { fields fields want want checkFunc func(want) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want) error { return nil @@ -933,12 +1074,19 @@ func Test_uiim_Delete(t *testing.T) { key: "", }, fields: fields { + mu: sync.Mutex{}, read: nil, dirty: nil, misses: 0, }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -951,12 +1099,19 @@ func Test_uiim_Delete(t *testing.T) { key: "", }, fields: fields { + mu: sync.Mutex{}, read: nil, dirty: nil, misses: 0, }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -968,16 +1123,17 @@ func Test_uiim_Delete(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { checkFunc = defaultCheckFunc } - m := &uiim{ + m := &indexMap{ + mu: test.fields.mu, read: test.fields.read, dirty: test.fields.dirty, misses: test.fields.misses, @@ -991,7 +1147,7 @@ func Test_uiim_Delete(t *testing.T) { } } -func Test_entryUiim_delete(t *testing.T) { +func Test_entryIndexMap_delete(t *testing.T) { type fields struct { p unsafe.Pointer } @@ -1004,8 +1160,8 @@ func Test_entryUiim_delete(t *testing.T) { fields fields want want checkFunc func(want, index, bool) error - beforeFunc func() - afterFunc func() + beforeFunc func(*testing.T) + afterFunc func(*testing.T) } defaultCheckFunc := func(w want, gotValue index, gotOk bool) error { if !reflect.DeepEqual(gotValue, w.wantValue) { @@ -1026,6 +1182,12 @@ func Test_entryUiim_delete(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, }, */ @@ -1039,6 +1201,12 @@ func Test_entryUiim_delete(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, } }(), */ @@ -1050,16 +1218,16 @@ func Test_entryUiim_delete(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc() + test.beforeFunc(tt) } if test.afterFunc != nil { - defer test.afterFunc() + defer test.afterFunc(tt) } checkFunc := test.checkFunc if test.checkFunc == nil { checkFunc = defaultCheckFunc } - e := &entryUiim{ + e := &entryIndexMap{ p: test.fields.p, } @@ -1071,13 +1239,14 @@ func Test_entryUiim_delete(t *testing.T) { } } -func Test_uiim_Range(t *testing.T) { +func Test_indexMap_Range(t *testing.T) { type args struct { f func(key string, value index) bool } type fields struct { + mu sync.Mutex read atomic.Value - dirty map[string]*entryUiim + dirty map[string]*entryIndexMap misses int } type want struct{} @@ -1087,8 +1256,8 @@ func Test_uiim_Range(t *testing.T) { fields fields want want checkFunc func(want) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want) error { return nil @@ -1102,12 +1271,19 @@ func Test_uiim_Range(t *testing.T) { f: nil, }, fields: fields { + mu: sync.Mutex{}, read: nil, dirty: nil, misses: 0, }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -1120,12 +1296,19 @@ func Test_uiim_Range(t *testing.T) { f: nil, }, fields: fields { + mu: sync.Mutex{}, read: nil, dirty: nil, misses: 0, }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -1137,16 +1320,17 @@ func Test_uiim_Range(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { checkFunc = defaultCheckFunc } - m := &uiim{ + m := &indexMap{ + mu: test.fields.mu, read: test.fields.read, dirty: test.fields.dirty, misses: test.fields.misses, @@ -1160,10 +1344,11 @@ func Test_uiim_Range(t *testing.T) { } } -func Test_uiim_missLocked(t *testing.T) { +func Test_indexMap_missLocked(t *testing.T) { type fields struct { + mu sync.Mutex read atomic.Value - dirty map[string]*entryUiim + dirty map[string]*entryIndexMap misses int } type want struct{} @@ -1172,8 +1357,8 @@ func Test_uiim_missLocked(t *testing.T) { fields fields want want checkFunc func(want) error - beforeFunc func() - afterFunc func() + beforeFunc func(*testing.T) + afterFunc func(*testing.T) } defaultCheckFunc := func(w want) error { return nil @@ -1184,12 +1369,19 @@ func Test_uiim_missLocked(t *testing.T) { { name: "test_case_1", fields: fields { + mu: sync.Mutex{}, read: nil, dirty: nil, misses: 0, }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, }, */ @@ -1199,12 +1391,19 @@ func Test_uiim_missLocked(t *testing.T) { return test { name: "test_case_2", fields: fields { + mu: sync.Mutex{}, read: nil, dirty: nil, misses: 0, }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, } }(), */ @@ -1216,16 +1415,17 @@ func Test_uiim_missLocked(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc() + test.beforeFunc(tt) } if test.afterFunc != nil { - defer test.afterFunc() + defer test.afterFunc(tt) } checkFunc := test.checkFunc if test.checkFunc == nil { checkFunc = defaultCheckFunc } - m := &uiim{ + m := &indexMap{ + mu: test.fields.mu, read: test.fields.read, dirty: test.fields.dirty, misses: test.fields.misses, @@ -1239,10 +1439,11 @@ func Test_uiim_missLocked(t *testing.T) { } } -func Test_uiim_dirtyLocked(t *testing.T) { +func Test_indexMap_dirtyLocked(t *testing.T) { type fields struct { + mu sync.Mutex read atomic.Value - dirty map[string]*entryUiim + dirty map[string]*entryIndexMap misses int } type want struct{} @@ -1251,8 +1452,8 @@ func Test_uiim_dirtyLocked(t *testing.T) { fields fields want want checkFunc func(want) error - beforeFunc func() - afterFunc func() + beforeFunc func(*testing.T) + afterFunc func(*testing.T) } defaultCheckFunc := func(w want) error { return nil @@ -1263,12 +1464,19 @@ func Test_uiim_dirtyLocked(t *testing.T) { { name: "test_case_1", fields: fields { + mu: sync.Mutex{}, read: nil, dirty: nil, misses: 0, }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, }, */ @@ -1278,12 +1486,19 @@ func Test_uiim_dirtyLocked(t *testing.T) { return test { name: "test_case_2", fields: fields { + mu: sync.Mutex{}, read: nil, dirty: nil, misses: 0, }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, } }(), */ @@ -1295,16 +1510,17 @@ func Test_uiim_dirtyLocked(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc() + test.beforeFunc(tt) } if test.afterFunc != nil { - defer test.afterFunc() + defer test.afterFunc(tt) } checkFunc := test.checkFunc if test.checkFunc == nil { checkFunc = defaultCheckFunc } - m := &uiim{ + m := &indexMap{ + mu: test.fields.mu, read: test.fields.read, dirty: test.fields.dirty, misses: test.fields.misses, @@ -1318,7 +1534,7 @@ func Test_uiim_dirtyLocked(t *testing.T) { } } -func Test_entryUiim_tryExpungeLocked(t *testing.T) { +func Test_entryIndexMap_tryExpungeLocked(t *testing.T) { type fields struct { p unsafe.Pointer } @@ -1330,8 +1546,8 @@ func Test_entryUiim_tryExpungeLocked(t *testing.T) { fields fields want want checkFunc func(want, bool) error - beforeFunc func() - afterFunc func() + beforeFunc func(*testing.T) + afterFunc func(*testing.T) } defaultCheckFunc := func(w want, gotIsExpunged bool) error { if !reflect.DeepEqual(gotIsExpunged, w.wantIsExpunged) { @@ -1349,6 +1565,12 @@ func Test_entryUiim_tryExpungeLocked(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, }, */ @@ -1362,6 +1584,12 @@ func Test_entryUiim_tryExpungeLocked(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, } }(), */ @@ -1373,16 +1601,16 @@ func Test_entryUiim_tryExpungeLocked(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc() + test.beforeFunc(tt) } if test.afterFunc != nil { - defer test.afterFunc() + defer test.afterFunc(tt) } checkFunc := test.checkFunc if test.checkFunc == nil { checkFunc = defaultCheckFunc } - e := &entryUiim{ + e := &entryIndexMap{ p: test.fields.p, } diff --git a/pkg/agent/core/ngt/service/vqueue/option.go b/pkg/agent/core/ngt/service/vqueue/option.go index ba8efff6b7..1c68dd84dc 100644 --- a/pkg/agent/core/ngt/service/vqueue/option.go +++ b/pkg/agent/core/ngt/service/vqueue/option.go @@ -17,52 +17,7 @@ // Package vqueue manages the vector cache layer for reducing FFI overhead for fast Agent processing. package vqueue -import ( - "github.com/vdaas/vald/internal/errgroup" - "github.com/vdaas/vald/internal/errors" -) - // Option represents the functional option for vqueue. type Option func(n *vqueue) error -var defaultOptions = []Option{ - WithErrGroup(errgroup.Get()), - WithDeleteBufferPoolSize(1000), - WithInsertBufferPoolSize(1000), -} - -// WithErrGroup returns the option to set the errgroup. -func WithErrGroup(eg errgroup.Group) Option { - return func(v *vqueue) error { - if eg == nil { - return errors.NewErrInvalidOption("errgroup", eg) - } - v.eg = eg - - return nil - } -} - -// WithInsertBufferPoolSize returns the option to set the pool size of the insert buffer. -func WithInsertBufferPoolSize(size int) Option { - return func(v *vqueue) error { - if size <= 0 { - return errors.NewErrInvalidOption("insertBufferPoolSize", size) - } - v.iBufSize = size - - return nil - } -} - -// WithDeleteBufferPoolSize returns the option to set the pool size of the delete buffer. -func WithDeleteBufferPoolSize(size int) Option { - return func(v *vqueue) error { - if size <= 0 { - return errors.NewErrInvalidOption("deleteBufferPoolSize", size) - } - v.dBufSize = size - - return nil - } -} +var defaultOptions = []Option{} diff --git a/pkg/agent/core/ngt/service/vqueue/option_test.go b/pkg/agent/core/ngt/service/vqueue/option_test.go deleted file mode 100644 index cee7646afb..0000000000 --- a/pkg/agent/core/ngt/service/vqueue/option_test.go +++ /dev/null @@ -1,412 +0,0 @@ -// -// Copyright (C) 2019-2022 vdaas.org vald team -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -// Package vqueue manages the vector cache layer for reducing FFI overhead for fast Agent processing. -package vqueue - -import ( - "context" - "math" - "reflect" - "testing" - - "github.com/vdaas/vald/internal/errgroup" - "github.com/vdaas/vald/internal/errors" - "github.com/vdaas/vald/internal/test/goleak" -) - -func TestWithErrGroup(t *testing.T) { - type T = vqueue - type args struct { - eg errgroup.Group - } - type want struct { - obj *T - err error - } - type test struct { - name string - args args - want want - checkFunc func(want, *T, error) error - beforeFunc func(args) - afterFunc func(args) - } - - defaultCheckFunc := func(w want, obj *T, err error) error { - if !errors.Is(err, w.err) { - return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) - } - if !reflect.DeepEqual(obj, w.obj) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) - } - return nil - } - - tests := []test{ - func() test { - eg, _ := errgroup.New(context.Background()) - return test{ - name: "set success when the eg is not nil", - args: args{ - eg: eg, - }, - want: want{ - obj: &T{ - eg: eg, - }, - }, - } - }(), - func() test { - return test{ - name: "set fails when the eg is nil", - args: args{}, - want: want{ - err: errors.NewErrInvalidOption("errgroup", nil), - obj: new(T), - }, - } - }(), - } - - for _, tc := range tests { - test := tc - t.Run(test.name, func(tt *testing.T) { - tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) - if test.beforeFunc != nil { - test.beforeFunc(test.args) - } - if test.afterFunc != nil { - defer test.afterFunc(test.args) - } - - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - - got := WithErrGroup(test.args.eg) - obj := new(T) - if err := checkFunc(test.want, obj, got(obj)); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} - -func TestWithInsertBufferPoolSize(t *testing.T) { - type T = vqueue - type args struct { - size int - } - type want struct { - obj *T - err error - } - type test struct { - name string - args args - want want - checkFunc func(want, *T, error) error - beforeFunc func(args) - afterFunc func(args) - } - - defaultCheckFunc := func(w want, obj *T, err error) error { - if !errors.Is(err, w.err) { - return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) - } - if !reflect.DeepEqual(obj, w.obj) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) - } - return nil - } - - tests := []test{ - func() test { - size := 100 - return test{ - name: "set success when size is 100", - args: args{ - size: size, - }, - want: want{ - obj: &T{ - iBufSize: size, - }, - }, - } - }(), - func() test { - size := 1 - return test{ - name: "set success when size is 1", - args: args{ - size: size, - }, - want: want{ - obj: &T{ - iBufSize: size, - }, - }, - } - }(), - func() test { - size := math.MaxInt64 - return test{ - name: "set success when size is maximum value of int", - args: args{ - size: size, - }, - want: want{ - obj: &T{ - iBufSize: size, - }, - }, - } - }(), - func() test { - size := 0 - return test{ - name: "set fails when size is 0", - args: args{ - size: size, - }, - want: want{ - err: errors.NewErrInvalidOption("insertBufferPoolSize", size), - obj: new(T), - }, - } - }(), - func() test { - size := -1 - return test{ - name: "set fails when size is -1", - args: args{ - size: size, - }, - want: want{ - err: errors.NewErrInvalidOption("insertBufferPoolSize", size), - obj: new(T), - }, - } - }(), - func() test { - size := -100 - return test{ - name: "set fails when size is -100", - args: args{ - size: size, - }, - want: want{ - err: errors.NewErrInvalidOption("insertBufferPoolSize", size), - obj: new(T), - }, - } - }(), - func() test { - size := math.MinInt64 - return test{ - name: "set success when size is minimum value of int", - args: args{ - size: size, - }, - want: want{ - err: errors.NewErrInvalidOption("insertBufferPoolSize", size), - obj: new(T), - }, - } - }(), - } - - for _, tc := range tests { - test := tc - t.Run(test.name, func(tt *testing.T) { - tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) - if test.beforeFunc != nil { - test.beforeFunc(test.args) - } - if test.afterFunc != nil { - defer test.afterFunc(test.args) - } - - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - - got := WithInsertBufferPoolSize(test.args.size) - obj := new(T) - if err := checkFunc(test.want, obj, got(obj)); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} - -func TestWithDeleteBufferPoolSize(t *testing.T) { - type T = vqueue - type args struct { - size int - } - type want struct { - obj *T - err error - } - type test struct { - name string - args args - want want - checkFunc func(want, *T, error) error - beforeFunc func(args) - afterFunc func(args) - } - - defaultCheckFunc := func(w want, obj *T, err error) error { - if !errors.Is(err, w.err) { - return errors.Errorf("got_error: \"%#v\",\n\t\t\t\twant: \"%#v\"", err, w.err) - } - if !reflect.DeepEqual(obj, w.obj) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", obj, w.obj) - } - return nil - } - - tests := []test{ - func() test { - size := 100 - return test{ - name: "set success when size is 100", - args: args{ - size: size, - }, - want: want{ - obj: &T{ - dBufSize: size, - }, - }, - } - }(), - func() test { - size := 1 - return test{ - name: "set success when size is 1", - args: args{ - size: size, - }, - want: want{ - obj: &T{ - dBufSize: size, - }, - }, - } - }(), - func() test { - size := math.MaxInt64 - return test{ - name: "set success when size is maximum value of int", - args: args{ - size: size, - }, - want: want{ - obj: &T{ - dBufSize: size, - }, - }, - } - }(), - func() test { - size := 0 - return test{ - name: "set fails when size is 0", - args: args{ - size: size, - }, - want: want{ - err: errors.NewErrInvalidOption("deleteBufferPoolSize", size), - obj: new(T), - }, - } - }(), - func() test { - size := -1 - return test{ - name: "set fails when size is -1", - args: args{ - size: size, - }, - want: want{ - err: errors.NewErrInvalidOption("deleteBufferPoolSize", size), - obj: new(T), - }, - } - }(), - func() test { - size := -100 - return test{ - name: "set fails when size is -100", - args: args{ - size: size, - }, - want: want{ - err: errors.NewErrInvalidOption("deleteBufferPoolSize", size), - obj: new(T), - }, - } - }(), - func() test { - size := math.MinInt64 - return test{ - name: "set success when size is minimum value of int", - args: args{ - size: size, - }, - want: want{ - err: errors.NewErrInvalidOption("deleteBufferPoolSize", size), - obj: new(T), - }, - } - }(), - } - - for _, tc := range tests { - test := tc - t.Run(test.name, func(tt *testing.T) { - tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) - if test.beforeFunc != nil { - test.beforeFunc(test.args) - } - if test.afterFunc != nil { - defer test.afterFunc(test.args) - } - - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - - got := WithDeleteBufferPoolSize(test.args.size) - obj := new(T) - if err := checkFunc(test.want, obj, got(obj)); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} diff --git a/pkg/agent/core/ngt/service/vqueue/queue.go b/pkg/agent/core/ngt/service/vqueue/queue.go index cd761e7051..9be07a3846 100644 --- a/pkg/agent/core/ngt/service/vqueue/queue.go +++ b/pkg/agent/core/ngt/service/vqueue/queue.go @@ -21,15 +21,14 @@ import ( "context" "reflect" "sort" - "sync" + "sync/atomic" "time" - "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/log" ) -// Queue +// Queue represents vector queue cache interface type Queue interface { PushInsert(uuid string, vector []float32, date int64) error PushDelete(uuid string, date int64) error @@ -43,17 +42,8 @@ type Queue interface { } type vqueue struct { - uii []index // uii is un inserted index - imu sync.RWMutex // insert mutex - uiim uiim // uiim is un inserted index map (this value is used for GetVector operation to return queued vector cache data) - udk []key // udk is un deleted key - dmu sync.RWMutex // delete mutex - udim udim // udim is un deleted index map (this value is used for Exists operation to return cache data existence) - eg errgroup.Group - - // buffer config - iBufSize int - dBufSize int + il, dl indexMap + ic, dc uint64 } type index struct { @@ -62,11 +52,6 @@ type index struct { uuid string } -type key struct { - date int64 - uuid string -} - func New(opts ...Option) (Queue, error) { vq := new(vqueue) for _, opt := range append(defaultOptions, opts...) { @@ -81,8 +66,6 @@ func New(opts ...Option) (Queue, error) { log.Warn(werr) } } - vq.uii = make([]index, 0, vq.iBufSize) - vq.udk = make([]key, 0, vq.dBufSize) return vq, nil } @@ -90,8 +73,8 @@ func (v *vqueue) PushInsert(uuid string, vector []float32, date int64) error { if date == 0 { date = time.Now().UnixNano() } - ddate, ok := v.udim.Load(uuid) - if ok && ddate > date { + didx, ok := v.dl.Load(uuid) + if ok && didx.date > date { return nil } idx := index{ @@ -99,14 +82,14 @@ func (v *vqueue) PushInsert(uuid string, vector []float32, date int64) error { vector: vector, date: date, } - oidx, loaded := v.uiim.LoadOrStore(uuid, idx) + oidx, loaded := v.il.LoadOrStore(uuid, idx) if loaded { - if oidx.date > idx.date { - return nil + if date > oidx.date { // if data already exists and existing index is older than new one + v.il.Store(uuid, idx) } - v.uiim.Store(uuid, idx) + } else { + _ = atomic.AddUint64(&v.ic, 1) } - v.addInsert(idx) return nil } @@ -114,17 +97,18 @@ func (v *vqueue) PushDelete(uuid string, date int64) error { if date == 0 { date = time.Now().UnixNano() } - odate, loaded := v.udim.LoadOrStore(uuid, date) + idx := index{ + uuid: uuid, + date: date, + } + oidx, loaded := v.dl.LoadOrStore(uuid, idx) if loaded { - if odate > date { - return nil + if date > oidx.date { // if data already exists and existing index is older than new one + v.dl.Store(uuid, idx) } - v.udim.Store(uuid, date) + } else { + _ = atomic.AddUint64(&v.dc, 1) } - v.addDelete(key{ - uuid: uuid, - date: date, - }) return nil } @@ -132,19 +116,19 @@ func (v *vqueue) PushDelete(uuid string, date int64) error { // If the same UUID exists in the insert queue and the delete queue, the timestamp is compared. // And the vector is returned if the timestamp in the insert queue is newer than the delete queue. func (v *vqueue) GetVector(uuid string) ([]float32, bool) { - vec, ok := v.uiim.Load(uuid) + idx, ok := v.il.Load(uuid) if !ok { // data not in the insert queue then return not exists(false) return nil, false } - di, ok := v.udim.Load(uuid) + didx, ok := v.dl.Load(uuid) if !ok { // data not in the delete queue but exists in insert queue then return exists(true) - return vec.vector, true + return idx.vector, true } // data exists both queue, compare data timestamp if insert queue timestamp is newer than delete one, this function returns exists(true) - if di <= vec.date { - return vec.vector, true + if didx.date <= idx.date { + return idx.vector, true } return nil, false } @@ -153,181 +137,123 @@ func (v *vqueue) GetVector(uuid string) ([]float32, bool) { // If the same UUID exists in the insert queue and the delete queue, the timestamp is compared. // And the true is returned if the timestamp in the insert queue is newer than the delete queue. func (v *vqueue) IVExists(uuid string) bool { - vec, ok := v.uiim.Load(uuid) + idx, ok := v.il.Load(uuid) if !ok { // data not in the insert queue then return not exists(false) return false } - di, ok := v.udim.Load(uuid) + didx, ok := v.dl.Load(uuid) if !ok { // data not in the delete queue but exists in insert queue then return exists(true) return true } // data exists both queue, compare data timestamp if insert queue timestamp is newer than delete one, this function returns exists(true) // However, if insert and delete are sent by the update instruction, the timestamp will be the same - return di <= vec.date + return didx.date <= idx.date } // DVExists returns true if there is the UUID in the delete queue. // If the same UUID exists in the insert queue and the delete queue, the timestamp is compared. // And the true is returned if the timestamp in the delete queue is newer than the insert queue. func (v *vqueue) DVExists(uuid string) bool { - di, ok := v.udim.Load(uuid) + didx, ok := v.dl.Load(uuid) if !ok { return false } - vec, ok := v.uiim.Load(uuid) + idx, ok := v.il.Load(uuid) if !ok { // data not in the insert queue then return not exists(false) return true } // data exists both queue, compare data timestamp if insert queue timestamp is newer than delete one, this function returns exists(true) - return di > vec.date + return didx.date > idx.date } -func (v *vqueue) addInsert(i index) { - date, ok := v.udim.Load(i.uuid) - if ok && i.date < date { - return - } - idx, ok := v.uiim.Load(i.uuid) - if ok && i.date < idx.date { - return - } - v.imu.Lock() - v.uii = append(v.uii, i) - v.imu.Unlock() -} - -func (v *vqueue) addDelete(d key) { - date, ok := v.udim.Load(d.uuid) - if ok && d.date < date { - return - } - v.dmu.Lock() - v.udk = append(v.udk, d) - v.dmu.Unlock() -} - -func (v *vqueue) RangePopInsert(_ context.Context, now int64, f func(uuid string, vector []float32) bool) { - v.imu.Lock() - uii := make([]index, len(v.uii)) - copy(uii, v.uii) - v.uii = v.uii[:0] - v.imu.Unlock() +func (v *vqueue) RangePopInsert(ctx context.Context, now int64, f func(uuid string, vector []float32) bool) { + uii := make([]index, 0, atomic.LoadUint64(&v.ic)) + v.il.Range(func(uuid string, idx index) bool { + if idx.date > now { + return true + } + didx, ok := v.dl.Load(uuid) + if ok { + if idx.date < didx.date { + v.il.Delete(idx.uuid) + atomic.AddUint64(&v.ic, ^uint64(0)) + } + return true + } + uii = append(uii, idx) + select { + case <-ctx.Done(): + return false + default: + } + return true + }) sort.Slice(uii, func(i, j int) bool { // sort by latest unix time order return uii[i].date > uii[j].date }) - dup := make(map[string]bool, len(uii)/2) - for i, idx := range uii { - if idx.date > now { - v.imu.Lock() - v.uii = append(v.uii, idx) - v.imu.Unlock() - continue + for _, idx := range uii { + if !f(idx.uuid, idx.vector) { + return } - - // if the same uuid is detected in the delete map during insert phase, which means the data is not processed in the delete phase. - // we need to add it back to insert map to process it in next create index process. - if _, ok := v.udim.Load(idx.uuid); ok { - v.imu.Lock() - v.uii = append(v.uii, idx) - v.imu.Unlock() - continue - } - - // if duplicated data exists current loop's data is old due to the uii's sort order - if !dup[idx.uuid] { - dup[idx.uuid] = true - if !f(idx.uuid, idx.vector) { - v.imu.Lock() - v.uii = append(uii[i:], v.uii...) - v.imu.Unlock() - return - } - v.uiim.Delete(idx.uuid) + v.il.Delete(idx.uuid) + atomic.AddUint64(&v.ic, ^uint64(0)) + select { + case <-ctx.Done(): + return + default: } } } -func (v *vqueue) RangePopDelete(_ context.Context, now int64, f func(uuid string) bool) { - v.dmu.Lock() - udk := make([]key, len(v.udk)) - copy(udk, v.udk) - v.udk = v.udk[:0] - v.dmu.Unlock() - sort.Slice(udk, func(i, j int) bool { - return udk[i].date > udk[j].date - }) - dup := make(map[string]bool, len(udk)/2) - udm := make(map[string]int64, len(udk)) - for i, idx := range udk { +func (v *vqueue) RangePopDelete(ctx context.Context, now int64, f func(uuid string) bool) { + udi := make([]index, 0, atomic.LoadUint64(&v.dc)) + v.dl.Range(func(uuid string, idx index) bool { if idx.date > now { - v.dmu.Lock() - v.udk = append(v.udk, idx) - v.dmu.Unlock() - continue + return true } - if !dup[idx.uuid] { - dup[idx.uuid] = true - if !f(idx.uuid) { - v.dmu.Lock() - v.udk = append(udk[i:], v.udk...) - v.dmu.Unlock() - return - } - v.udim.Delete(idx.uuid) - udm[idx.uuid] = idx.date + udi = append(udi, idx) + select { + case <-ctx.Done(): + return false + default: } - } - - dl := make([]int, 0, len(udk)/2) - - // In the CreateIndex operation of the NGT Service, the Delete Queue is processed first, and then the Insert Queue is processed, - // so the Insert Queue still contains the old Insert Operation older than the Delete Queue, - // and it is possible that data that was intended to be deleted is registered again. - // For this reason, the data is deleted from the Insert Queue only when retrieving data from the Delete Queue. - // we should check insert vqueue if insert vqueue exists and delete operation date is newer than insert operation date then we should remove insert vqueue's data. - v.imu.RLock() - for i, idx := range v.uii { - if idx.date > now { - continue + return true + }) + sort.Slice(udi, func(i, j int) bool { + // sort by latest unix time order + return udi[i].date > udi[j].date + }) + for _, idx := range udi { + if !f(idx.uuid) { + return } - // check same uuid & operation date - // if date is equal, it may update operation we shouldn't remove at that time - date, exists := udm[idx.uuid] - if exists && date <= now && date > idx.date { - dl = append(dl, i) + v.dl.Delete(idx.uuid) + atomic.AddUint64(&v.dc, ^uint64(0)) + iidx, ok := v.il.Load(idx.uuid) + if ok && idx.date > iidx.date { + v.il.Delete(idx.uuid) + atomic.AddUint64(&v.ic, ^uint64(0)) } - } - v.imu.RUnlock() - sort.Sort(sort.Reverse(sort.IntSlice(dl))) - for _, i := range dl { - v.imu.Lock() - // load removal target uuid - uuid := v.uii[i].uuid - // remove unnecessary insert vector queue data - v.uii = append(v.uii[:i], v.uii[i+1:]...) - v.imu.Unlock() - // remove from existing map - v.uiim.Delete(uuid) + select { + case <-ctx.Done(): + return + default: + } + } } // IVQLen returns the number of uninserted indexes stored in the insert queue. func (v *vqueue) IVQLen() (l int) { - v.imu.RLock() - l = len(v.uii) - v.imu.RUnlock() - return l + return int(atomic.LoadUint64(&v.ic)) } // DVQLen returns the number of undeleted keys stored in the delete queue. func (v *vqueue) DVQLen() (l int) { - v.dmu.RLock() - l = len(v.udk) - v.dmu.RUnlock() - return l + return int(atomic.LoadUint64(&v.dc)) } diff --git a/pkg/agent/core/ngt/service/vqueue/queue_test.go b/pkg/agent/core/ngt/service/vqueue/queue_test.go index 33a4865088..c9c650506e 100644 --- a/pkg/agent/core/ngt/service/vqueue/queue_test.go +++ b/pkg/agent/core/ngt/service/vqueue/queue_test.go @@ -20,10 +20,8 @@ package vqueue import ( "context" "reflect" - "sync/atomic" "testing" - "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/internal/errors" "github.com/vdaas/vald/internal/test/goleak" ) @@ -41,8 +39,8 @@ func TestNew(t *testing.T) { args args want want checkFunc func(want, Queue, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, got Queue, err error) error { if !errors.Is(err, w.err) { @@ -63,6 +61,12 @@ func TestNew(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -76,6 +80,12 @@ func TestNew(t *testing.T) { }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -87,10 +97,10 @@ func TestNew(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { @@ -105,18 +115,6 @@ func TestNew(t *testing.T) { } } -type uiimNoLock struct { - read atomic.Value - dirty map[string]*entryUiim - misses int -} - -type udimNoLock struct { - read atomic.Value - dirty map[string]*entryUdim - misses int -} - func Test_vqueue_PushInsert(t *testing.T) { type args struct { uuid string @@ -124,13 +122,10 @@ func Test_vqueue_PushInsert(t *testing.T) { date int64 } type fields struct { - uii []index - uiim uiimNoLock - udk []key - udim udimNoLock - eg errgroup.Group - iBufSize int - dBufSize int + il indexMap + dl indexMap + ic uint64 + dc uint64 } type want struct { err error @@ -141,8 +136,8 @@ func Test_vqueue_PushInsert(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -161,20 +156,19 @@ func Test_vqueue_PushInsert(t *testing.T) { date: 0, }, fields: fields { - ich: nil, - uii: nil, - uiim: uiimNoLock{}, - dch: nil, - udk: nil, - udim: udimNoLock{}, - eg: nil, - ichSize: 0, - dchSize: 0, - iBufSize: 0, - dBufSize: 0, + il: indexMap{}, + dl: indexMap{}, + ic: 0, + dc: 0, }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -189,20 +183,19 @@ func Test_vqueue_PushInsert(t *testing.T) { date: 0, }, fields: fields { - ich: nil, - uii: nil, - uiim: uiimNoLock{}, - dch: nil, - udk: nil, - udim: udimNoLock{}, - eg: nil, - ichSize: 0, - dchSize: 0, - iBufSize: 0, - dBufSize: 0, + il: indexMap{}, + dl: indexMap{}, + ic: 0, + dc: 0, }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -214,31 +207,20 @@ func Test_vqueue_PushInsert(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { checkFunc = defaultCheckFunc } v := &vqueue{ - uii: test.fields.uii, - uiim: uiim{ - read: test.fields.uiim.read, - dirty: test.fields.uiim.dirty, - misses: test.fields.uiim.misses, - }, - udk: test.fields.udk, - udim: udim{ - read: test.fields.udim.read, - dirty: test.fields.udim.dirty, - misses: test.fields.udim.misses, - }, - eg: test.fields.eg, - iBufSize: test.fields.iBufSize, - dBufSize: test.fields.dBufSize, + il: test.fields.il, + dl: test.fields.dl, + ic: test.fields.ic, + dc: test.fields.dc, } err := v.PushInsert(test.args.uuid, test.args.vector, test.args.date) @@ -255,13 +237,10 @@ func Test_vqueue_PushDelete(t *testing.T) { date int64 } type fields struct { - uii []index - uiim uiimNoLock - udk []key - udim udimNoLock - eg errgroup.Group - iBufSize int - dBufSize int + il indexMap + dl indexMap + ic uint64 + dc uint64 } type want struct { err error @@ -272,8 +251,8 @@ func Test_vqueue_PushDelete(t *testing.T) { fields fields want want checkFunc func(want, error) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -291,20 +270,19 @@ func Test_vqueue_PushDelete(t *testing.T) { date: 0, }, fields: fields { - ich: nil, - uii: nil, - uiim: uiimNoLock{}, - dch: nil, - udk: nil, - udim: udimNoLock{}, - eg: nil, - ichSize: 0, - dchSize: 0, - iBufSize: 0, - dBufSize: 0, + il: indexMap{}, + dl: indexMap{}, + ic: 0, + dc: 0, }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -318,20 +296,19 @@ func Test_vqueue_PushDelete(t *testing.T) { date: 0, }, fields: fields { - ich: nil, - uii: nil, - uiim: uiimNoLock{}, - dch: nil, - udk: nil, - udim: udimNoLock{}, - eg: nil, - ichSize: 0, - dchSize: 0, - iBufSize: 0, - dBufSize: 0, + il: indexMap{}, + dl: indexMap{}, + ic: 0, + dc: 0, }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -343,31 +320,20 @@ func Test_vqueue_PushDelete(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { checkFunc = defaultCheckFunc } v := &vqueue{ - uii: test.fields.uii, - uiim: uiim{ - read: test.fields.uiim.read, - dirty: test.fields.uiim.dirty, - misses: test.fields.uiim.misses, - }, - udk: test.fields.udk, - udim: udim{ - read: test.fields.udim.read, - dirty: test.fields.udim.dirty, - misses: test.fields.udim.misses, - }, - eg: test.fields.eg, - iBufSize: test.fields.iBufSize, - dBufSize: test.fields.dBufSize, + il: test.fields.il, + dl: test.fields.dl, + ic: test.fields.ic, + dc: test.fields.dc, } err := v.PushDelete(test.args.uuid, test.args.date) @@ -378,32 +344,36 @@ func Test_vqueue_PushDelete(t *testing.T) { } } -func Test_vqueue_RangePopInsert(t *testing.T) { +func Test_vqueue_GetVector(t *testing.T) { type args struct { - ctx context.Context - now int64 - f func(uuid string, vector []float32) bool + uuid string } type fields struct { - uii []index - uiim uiimNoLock - udk []key - udim udimNoLock - eg errgroup.Group - iBufSize int - dBufSize int + il indexMap + dl indexMap + ic uint64 + dc uint64 + } + type want struct { + want []float32 + want1 bool } - type want struct{} type test struct { name string args args fields fields want want - checkFunc func(want) error - beforeFunc func(args) - afterFunc func(args) + checkFunc func(want, []float32, bool) error + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } - defaultCheckFunc := func(w want) error { + defaultCheckFunc := func(w want, got []float32, got1 bool) error { + if !reflect.DeepEqual(got, w.want) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) + } + if !reflect.DeepEqual(got1, w.want1) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got1, w.want1) + } return nil } tests := []test{ @@ -412,24 +382,22 @@ func Test_vqueue_RangePopInsert(t *testing.T) { { name: "test_case_1", args: args { - ctx: nil, - f: nil, + uuid: "", }, fields: fields { - ich: nil, - uii: nil, - uiim: uiimNoLock{}, - dch: nil, - udk: nil, - udim: udimNoLock{}, - eg: nil, - ichSize: 0, - dchSize: 0, - iBufSize: 0, - dBufSize: 0, + il: indexMap{}, + dl: indexMap{}, + ic: 0, + dc: 0, }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -439,24 +407,22 @@ func Test_vqueue_RangePopInsert(t *testing.T) { return test { name: "test_case_2", args: args { - ctx: nil, - f: nil, + uuid: "", }, fields: fields { - ich: nil, - uii: nil, - uiim: uiimNoLock{}, - dch: nil, - udk: nil, - udim: udimNoLock{}, - eg: nil, - ichSize: 0, - dchSize: 0, - iBufSize: 0, - dBufSize: 0, + il: indexMap{}, + dl: indexMap{}, + ic: 0, + dc: 0, }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -468,67 +434,56 @@ func Test_vqueue_RangePopInsert(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { checkFunc = defaultCheckFunc } v := &vqueue{ - uii: test.fields.uii, - uiim: uiim{ - read: test.fields.uiim.read, - dirty: test.fields.uiim.dirty, - misses: test.fields.uiim.misses, - }, - udk: test.fields.udk, - udim: udim{ - read: test.fields.udim.read, - dirty: test.fields.udim.dirty, - misses: test.fields.udim.misses, - }, - eg: test.fields.eg, - iBufSize: test.fields.iBufSize, - dBufSize: test.fields.dBufSize, + il: test.fields.il, + dl: test.fields.dl, + ic: test.fields.ic, + dc: test.fields.dc, } - v.RangePopInsert(test.args.ctx, test.args.now, test.args.f) - if err := checkFunc(test.want); err != nil { + got, got1 := v.GetVector(test.args.uuid) + if err := checkFunc(test.want, got, got1); err != nil { tt.Errorf("error = %v", err) } }) } } -func Test_vqueue_RangePopDelete(t *testing.T) { +func Test_vqueue_IVExists(t *testing.T) { type args struct { - ctx context.Context - now int64 - f func(uuid string) bool + uuid string } type fields struct { - uii []index - uiim uiimNoLock - udk []key - udim udimNoLock - eg errgroup.Group - iBufSize int - dBufSize int + il indexMap + dl indexMap + ic uint64 + dc uint64 + } + type want struct { + want bool } - type want struct{} type test struct { name string args args fields fields want want - checkFunc func(want) error - beforeFunc func(args) - afterFunc func(args) + checkFunc func(want, bool) error + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } - defaultCheckFunc := func(w want) error { + defaultCheckFunc := func(w want, got bool) error { + if !reflect.DeepEqual(got, w.want) { + return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) + } return nil } tests := []test{ @@ -537,24 +492,22 @@ func Test_vqueue_RangePopDelete(t *testing.T) { { name: "test_case_1", args: args { - ctx: nil, - f: nil, + uuid: "", }, fields: fields { - ich: nil, - uii: nil, - uiim: uiimNoLock{}, - dch: nil, - udk: nil, - udim: udimNoLock{}, - eg: nil, - ichSize: 0, - dchSize: 0, - iBufSize: 0, - dBufSize: 0, + il: indexMap{}, + dl: indexMap{}, + ic: 0, + dc: 0, }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -564,24 +517,22 @@ func Test_vqueue_RangePopDelete(t *testing.T) { return test { name: "test_case_2", args: args { - ctx: nil, - f: nil, + uuid: "", }, fields: fields { - ich: nil, - uii: nil, - uiim: uiimNoLock{}, - dch: nil, - udk: nil, - udim: udimNoLock{}, - eg: nil, - ichSize: 0, - dchSize: 0, - iBufSize: 0, - dBufSize: 0, + il: indexMap{}, + dl: indexMap{}, + ic: 0, + dc: 0, }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -593,871 +544,20 @@ func Test_vqueue_RangePopDelete(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) - } - if test.afterFunc != nil { - defer test.afterFunc(test.args) - } - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - v := &vqueue{ - uii: test.fields.uii, - uiim: uiim{ - read: test.fields.uiim.read, - dirty: test.fields.uiim.dirty, - misses: test.fields.uiim.misses, - }, - udk: test.fields.udk, - udim: udim{ - read: test.fields.udim.read, - dirty: test.fields.udim.dirty, - misses: test.fields.udim.misses, - }, - eg: test.fields.eg, - iBufSize: test.fields.iBufSize, - dBufSize: test.fields.dBufSize, - } - - v.RangePopDelete(test.args.ctx, test.args.now, test.args.f) - if err := checkFunc(test.want); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} - -func Test_vqueue_GetVector(t *testing.T) { - type args struct { - uuid string - } - type fields struct { - uii []index - uiim uiimNoLock - udk []key - udim udimNoLock - eg errgroup.Group - iBufSize int - dBufSize int - } - type want struct { - want []float32 - want1 bool - } - type test struct { - name string - args args - fields fields - want want - checkFunc func(want, []float32, bool) error - beforeFunc func(args) - afterFunc func(args) - } - defaultCheckFunc := func(w want, got []float32, got1 bool) error { - if !reflect.DeepEqual(got, w.want) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) - } - if !reflect.DeepEqual(got1, w.want1) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got1, w.want1) - } - return nil - } - tests := []test{ - func() test { - uuid := "146bbe1a-bc48-11eb-8529-0242ac130003" - uii := []index{ - { - uuid: "246bbe1a-bc48-11eb-8529-0242ac130003", - date: 2000000000, - }, - { - uuid: "346bbe1a-bc48-11eb-8529-0242ac130003", - date: 3000000000, - }, - } - var uiim uiim - for _, idx := range uii { - uiim.Store(idx.uuid, idx) - } - - return test{ - name: "return (nil, false) when the uiid dose not exist in uiim", - args: args{ - uuid: uuid, - }, - fields: fields{ - uiim: uiimNoLock{ - read: uiim.read, - dirty: uiim.dirty, - misses: uiim.misses, - }, - }, - want: want{ - want: nil, - want1: false, - }, - } - }(), - func() test { - uii := []index{ - { - uuid: "146bbe1a-bc48-11eb-8529-0242ac130003", - date: 2000000000, - }, - { - uuid: "246bbe1a-bc48-11eb-8529-0242ac130003", - date: 3000000000, - }, - } - var uiim uiim - for _, idx := range uii { - uiim.Store(idx.uuid, idx) - } - - return test{ - name: "return (nil, false) when the uuid is empty", - args: args{ - uuid: "", - }, - fields: fields{ - uiim: uiimNoLock{ - read: uiim.read, - dirty: uiim.dirty, - misses: uiim.misses, - }, - }, - want: want{ - want: nil, - want1: false, - }, - } - }(), - func() test { - return test{ - name: "return (nil, false) when the uiim is empty", - args: args{ - uuid: "146bbe1a-bc48-11eb-8529-0242ac130003", - }, - fields: fields{}, - want: want{ - want: nil, - want1: false, - }, - } - }(), - func() test { - uuid := "146bbe1a-bc48-11eb-8529-0242ac130003" - uii := []index{ - { - uuid: uuid, - vector: []float32{1}, - date: 1000000000, - }, - { - uuid: "246bbe1a-bc48-11eb-8529-0242ac130003", - vector: []float32{2}, - date: 2000000000, - }, - } - var uiim uiim - for _, idx := range uii { - uiim.Store(idx.uuid, idx) - } - - udk := []key{ - { - uuid: "346bbe1a-bc48-11eb-8529-0242ac130003", - date: 1000000000, - }, - { - uuid: "446bbe1a-bc48-11eb-8529-0242ac130003", - date: 4000000000, - }, - } - var udim udim - for _, key := range udk { - udim.Store(key.uuid, key.date) - } - - return test{ - name: "return (1, true) when the uiid dose not exist in udim", - args: args{ - uuid: uuid, - }, - fields: fields{ - uiim: uiimNoLock{ - read: uiim.read, - dirty: uiim.dirty, - misses: uiim.misses, - }, - udim: udimNoLock{ - read: udim.read, - dirty: udim.dirty, - misses: udim.misses, - }, - }, - want: want{ - want: []float32{1}, - want1: true, - }, - } - }(), - func() test { - uuid := "146bbe1a-bc48-11eb-8529-0242ac130003" - uii := []index{ - { - uuid: uuid, - vector: []float32{1}, - date: 1000000000, - }, - { - uuid: "246bbe1a-bc48-11eb-8529-0242ac130003", - vector: []float32{2}, - date: 2000000000, - }, - } - var uiim uiim - for _, idx := range uii { - uiim.Store(idx.uuid, idx) - } - - return test{ - name: "return (1, true) when the udim is empty", - args: args{ - uuid: uuid, - }, - fields: fields{ - uiim: uiimNoLock{ - read: uiim.read, - dirty: uiim.dirty, - misses: uiim.misses, - }, - }, - want: want{ - want: []float32{1}, - want1: true, - }, - } - }(), - func() test { - uuid := "146bbe1a-bc48-11eb-8529-0242ac130003" - uii := []index{ - { - uuid: uuid, - vector: []float32{1}, - date: 1000000000, - }, - { - uuid: "246bbe1a-bc48-11eb-8529-0242ac130003", - vector: []float32{2}, - date: 2000000000, - }, - } - var uiim uiim - for _, idx := range uii { - uiim.Store(idx.uuid, idx) - } - - udk := []key{ - { - uuid: uuid, - date: 1000000000, - }, - { - uuid: "346bbe1a-bc48-11eb-8529-0242ac130003", - date: 4000000000, - }, - } - var udim udim - for _, key := range udk { - udim.Store(key.uuid, key.date) - } - - return test{ - name: "return (1, true) when the date of uiim is equal the date of udim", - args: args{ - uuid: uuid, - }, - fields: fields{ - uiim: uiimNoLock{ - read: uiim.read, - dirty: uiim.dirty, - misses: uiim.misses, - }, - udim: udimNoLock{ - read: udim.read, - dirty: udim.dirty, - misses: udim.misses, - }, - }, - want: want{ - want: []float32{1}, - want1: true, - }, - } - }(), - func() test { - uuid := "146bbe1a-bc48-11eb-8529-0242ac130003" - uii := []index{ - { - uuid: uuid, - vector: []float32{1}, - date: 1000000001, - }, - { - uuid: "246bbe1a-bc48-11eb-8529-0242ac130003", - vector: []float32{2}, - date: 2000000000, - }, - } - var uiim uiim - for _, idx := range uii { - uiim.Store(idx.uuid, idx) - } - - udk := []key{ - { - uuid: uuid, - date: 1000000000, - }, - { - uuid: "346bbe1a-bc48-11eb-8529-0242ac130003", - date: 4000000000, - }, - } - var udim udim - for _, key := range udk { - udim.Store(key.uuid, key.date) - } - - return test{ - name: "return (1, true) when the date of uiim is newer than the date of udim", - args: args{ - uuid: uuid, - }, - fields: fields{ - uiim: uiimNoLock{ - read: uiim.read, - dirty: uiim.dirty, - misses: uiim.misses, - }, - udim: udimNoLock{ - read: udim.read, - dirty: udim.dirty, - misses: udim.misses, - }, - }, - want: want{ - want: []float32{1}, - want1: true, - }, - } - }(), - func() test { - uuid := "146bbe1a-bc48-11eb-8529-0242ac130003" - uii := []index{ - { - uuid: uuid, - vector: []float32{1}, - date: 999999999, - }, - { - uuid: "246bbe1a-bc48-11eb-8529-0242ac130003", - vector: []float32{2}, - date: 2000000000, - }, - } - var uiim uiim - for _, idx := range uii { - uiim.Store(idx.uuid, idx) - } - - udk := []key{ - { - uuid: uuid, - date: 1000000000, - }, - { - uuid: "346bbe1a-bc48-11eb-8529-0242ac130003", - date: 4000000000, - }, - } - var udim udim - for _, key := range udk { - udim.Store(key.uuid, key.date) - } - - return test{ - name: "return (nil, false) when the date of uiim is older than the date of udim", - args: args{ - uuid: uuid, - }, - fields: fields{ - uiim: uiimNoLock{ - read: uiim.read, - dirty: uiim.dirty, - misses: uiim.misses, - }, - udim: udimNoLock{ - read: udim.read, - dirty: udim.dirty, - misses: udim.misses, - }, - }, - want: want{ - want: nil, - want1: false, - }, - } - }(), - } - - for _, tc := range tests { - test := tc - t.Run(test.name, func(tt *testing.T) { - tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) - if test.beforeFunc != nil { - test.beforeFunc(test.args) - } - if test.afterFunc != nil { - defer test.afterFunc(test.args) - } - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - v := &vqueue{ - uii: test.fields.uii, - uiim: uiim{ - read: test.fields.uiim.read, - dirty: test.fields.uiim.dirty, - misses: test.fields.uiim.misses, - }, - udk: test.fields.udk, - udim: udim{ - read: test.fields.udim.read, - dirty: test.fields.udim.dirty, - misses: test.fields.udim.misses, - }, - eg: test.fields.eg, - iBufSize: test.fields.iBufSize, - dBufSize: test.fields.dBufSize, - } - - got, got1 := v.GetVector(test.args.uuid) - if err := checkFunc(test.want, got, got1); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} - -func Test_vqueue_IVExists(t *testing.T) { - type args struct { - uuid string - } - type fields struct { - uii []index - uiim uiimNoLock - udk []key - udim udimNoLock - eg errgroup.Group - iBufSize int - dBufSize int - } - type want struct { - want bool - } - type test struct { - name string - args args - fields fields - want want - checkFunc func(want, bool) error - beforeFunc func(args) - afterFunc func(args) - } - defaultCheckFunc := func(w want, got bool) error { - if !reflect.DeepEqual(got, w.want) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) - } - return nil - } - tests := []test{ - func() test { - uuid := "146bbe1a-bc48-11eb-8529-0242ac130003" - uii := []index{ - { - uuid: "246bbe1a-bc48-11eb-8529-0242ac130003", - date: 2000000000, - }, - { - uuid: "346bbe1a-bc48-11eb-8529-0242ac130003", - date: 3000000000, - }, - } - var uiim uiim - for _, idx := range uii { - uiim.Store(idx.uuid, idx) - } - - return test{ - name: "return false when the uiid dose not exist in uiim", - args: args{ - uuid: uuid, - }, - fields: fields{ - uiim: uiimNoLock{ - read: uiim.read, - dirty: uiim.dirty, - misses: uiim.misses, - }, - }, - want: want{ - want: false, - }, - } - }(), - func() test { - uii := []index{ - { - uuid: "146bbe1a-bc48-11eb-8529-0242ac130003", - date: 2000000000, - }, - { - uuid: "246bbe1a-bc48-11eb-8529-0242ac130003", - date: 3000000000, - }, - } - var uiim uiim - for _, idx := range uii { - uiim.Store(idx.uuid, idx) - } - - return test{ - name: "return false when the uuid is empty", - args: args{ - uuid: "", - }, - fields: fields{ - uiim: uiimNoLock{ - read: uiim.read, - dirty: uiim.dirty, - misses: uiim.misses, - }, - }, - want: want{ - want: false, - }, - } - }(), - func() test { - return test{ - name: "return false when the uiim is empty", - args: args{ - uuid: "146bbe1a-bc48-11eb-8529-0242ac130003", - }, - fields: fields{}, - want: want{ - want: false, - }, - } - }(), - func() test { - uuid := "146bbe1a-bc48-11eb-8529-0242ac130003" - uii := []index{ - { - uuid: uuid, - vector: []float32{1}, - date: 1000000000, - }, - { - uuid: "246bbe1a-bc48-11eb-8529-0242ac130003", - vector: []float32{2}, - date: 2000000000, - }, - } - var uiim uiim - for _, idx := range uii { - uiim.Store(idx.uuid, idx) - } - - udk := []key{ - { - uuid: "346bbe1a-bc48-11eb-8529-0242ac130003", - date: 1000000000, - }, - { - uuid: "446bbe1a-bc48-11eb-8529-0242ac130003", - date: 4000000000, - }, - } - var udim udim - for _, key := range udk { - udim.Store(key.uuid, key.date) - } - - return test{ - name: "return true when the uiid dose not exist in udim", - args: args{ - uuid: uuid, - }, - fields: fields{ - uiim: uiimNoLock{ - read: uiim.read, - dirty: uiim.dirty, - misses: uiim.misses, - }, - udim: udimNoLock{ - read: udim.read, - dirty: udim.dirty, - misses: udim.misses, - }, - }, - want: want{ - want: true, - }, - } - }(), - func() test { - uuid := "146bbe1a-bc48-11eb-8529-0242ac130003" - uii := []index{ - { - uuid: uuid, - vector: []float32{1}, - date: 1000000000, - }, - { - uuid: "246bbe1a-bc48-11eb-8529-0242ac130003", - vector: []float32{2}, - date: 2000000000, - }, - } - var uiim uiim - for _, idx := range uii { - uiim.Store(idx.uuid, idx) - } - - return test{ - name: "return true when the udim is empty", - args: args{ - uuid: uuid, - }, - fields: fields{ - uiim: uiimNoLock{ - read: uiim.read, - dirty: uiim.dirty, - misses: uiim.misses, - }, - }, - want: want{ - want: true, - }, - } - }(), - func() test { - uuid := "146bbe1a-bc48-11eb-8529-0242ac130003" - uii := []index{ - { - uuid: uuid, - vector: []float32{1}, - date: 1000000000, - }, - { - uuid: "246bbe1a-bc48-11eb-8529-0242ac130003", - vector: []float32{2}, - date: 2000000000, - }, - } - var uiim uiim - for _, idx := range uii { - uiim.Store(idx.uuid, idx) - } - - udk := []key{ - { - uuid: uuid, - date: 1000000000, - }, - { - uuid: "346bbe1a-bc48-11eb-8529-0242ac130003", - date: 4000000000, - }, - } - var udim udim - for _, key := range udk { - udim.Store(key.uuid, key.date) - } - - return test{ - name: "return true when the date of uiim is equal the date of udim", - args: args{ - uuid: uuid, - }, - fields: fields{ - uiim: uiimNoLock{ - read: uiim.read, - dirty: uiim.dirty, - misses: uiim.misses, - }, - udim: udimNoLock{ - read: udim.read, - dirty: udim.dirty, - misses: udim.misses, - }, - }, - want: want{ - want: true, - }, - } - }(), - func() test { - uuid := "146bbe1a-bc48-11eb-8529-0242ac130003" - uii := []index{ - { - uuid: uuid, - vector: []float32{1}, - date: 1000000001, - }, - { - uuid: "246bbe1a-bc48-11eb-8529-0242ac130003", - vector: []float32{2}, - date: 2000000000, - }, - } - var uiim uiim - for _, idx := range uii { - uiim.Store(idx.uuid, idx) - } - - udk := []key{ - { - uuid: uuid, - date: 1000000000, - }, - { - uuid: "346bbe1a-bc48-11eb-8529-0242ac130003", - date: 4000000000, - }, - } - var udim udim - for _, key := range udk { - udim.Store(key.uuid, key.date) - } - - return test{ - name: "return true when the date of uiim is newer than the date of udim", - args: args{ - uuid: uuid, - }, - fields: fields{ - uiim: uiimNoLock{ - read: uiim.read, - dirty: uiim.dirty, - misses: uiim.misses, - }, - udim: udimNoLock{ - read: udim.read, - dirty: udim.dirty, - misses: udim.misses, - }, - }, - want: want{ - want: true, - }, - } - }(), - func() test { - uuid := "146bbe1a-bc48-11eb-8529-0242ac130003" - uii := []index{ - { - uuid: uuid, - vector: []float32{1}, - date: 999999999, - }, - { - uuid: "246bbe1a-bc48-11eb-8529-0242ac130003", - vector: []float32{2}, - date: 2000000000, - }, - } - var uiim uiim - for _, idx := range uii { - uiim.Store(idx.uuid, idx) - } - - udk := []key{ - { - uuid: uuid, - date: 1000000000, - }, - { - uuid: "346bbe1a-bc48-11eb-8529-0242ac130003", - date: 4000000000, - }, - } - var udim udim - for _, key := range udk { - udim.Store(key.uuid, key.date) - } - - return test{ - name: "return false when the date of uiim is older than the date of udim", - args: args{ - uuid: uuid, - }, - fields: fields{ - uiim: uiimNoLock{ - read: uiim.read, - dirty: uiim.dirty, - misses: uiim.misses, - }, - udim: udimNoLock{ - read: udim.read, - dirty: udim.dirty, - misses: udim.misses, - }, - }, - want: want{ - want: false, - }, - } - }(), - } - - for _, tc := range tests { - test := tc - t.Run(test.name, func(tt *testing.T) { - tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) - if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { checkFunc = defaultCheckFunc } v := &vqueue{ - uii: test.fields.uii, - uiim: uiim{ - read: test.fields.uiim.read, - dirty: test.fields.uiim.dirty, - misses: test.fields.uiim.misses, - }, - udk: test.fields.udk, - udim: udim{ - read: test.fields.udim.read, - dirty: test.fields.udim.dirty, - misses: test.fields.udim.misses, - }, - eg: test.fields.eg, - iBufSize: test.fields.iBufSize, - dBufSize: test.fields.dBufSize, + il: test.fields.il, + dl: test.fields.dl, + ic: test.fields.ic, + dc: test.fields.dc, } got := v.IVExists(test.args.uuid) @@ -1473,13 +573,10 @@ func Test_vqueue_DVExists(t *testing.T) { uuid string } type fields struct { - uii []index - uiim uiimNoLock - udk []key - udim udimNoLock - eg errgroup.Group - iBufSize int - dBufSize int + il indexMap + dl indexMap + ic uint64 + dc uint64 } type want struct { want bool @@ -1490,8 +587,8 @@ func Test_vqueue_DVExists(t *testing.T) { fields fields want want checkFunc func(want, bool) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want, got bool) error { if !reflect.DeepEqual(got, w.want) { @@ -1500,343 +597,55 @@ func Test_vqueue_DVExists(t *testing.T) { return nil } tests := []test{ - func() test { - uuid := "146bbe1a-bc48-11eb-8529-0242ac130003" - udk := []key{ - { - uuid: "246bbe1a-bc48-11eb-8529-0242ac130003", - date: 2000000000, - }, - { - uuid: "346bbe1a-bc48-11eb-8529-0242ac130003", - date: 3000000000, - }, - } - var udim udim - for _, key := range udk { - udim.Store(key.uuid, key.date) - } - - return test{ - name: "return false when the uiid dose not exist in udim", - args: args{ - uuid: uuid, - }, - fields: fields{ - udim: udimNoLock{ - read: udim.read, - dirty: udim.dirty, - misses: udim.misses, - }, - }, - want: want{ - want: false, - }, - } - }(), - func() test { - udk := []key{ - { - uuid: "146bbe1a-bc48-11eb-8529-0242ac130003", - date: 2000000000, - }, - { - uuid: "246bbe1a-bc48-11eb-8529-0242ac130003", - date: 3000000000, - }, - } - var udim udim - for _, key := range udk { - udim.Store(key.uuid, key.date) - } - - return test{ - name: "return false when the uuid is empty", - args: args{ - uuid: "", - }, - fields: fields{ - udim: udimNoLock{ - read: udim.read, - dirty: udim.dirty, - misses: udim.misses, - }, - }, - want: want{ - want: false, - }, - } - }(), - func() test { - return test{ - name: "return false when the udim is empty", - args: args{ - uuid: "146bbe1a-bc48-11eb-8529-0242ac130003", - }, - fields: fields{}, - want: want{ - want: false, - }, - } - }(), - func() test { - uuid := "146bbe1a-bc48-11eb-8529-0242ac130003" - udk := []key{ - { - uuid: uuid, - date: 1000000000, - }, - { - uuid: "246bbe1a-bc48-11eb-8529-0242ac130003", - date: 2000000000, - }, - } - var udim udim - for _, key := range udk { - udim.Store(key.uuid, key.date) - } - - uii := []index{ - { - uuid: "346bbe1a-bc48-11eb-8529-0242ac130003", - vector: []float32{1}, - date: 1000000000, - }, - { - uuid: "446bbe1a-bc48-11eb-8529-0242ac130003", - vector: []float32{2}, - date: 4000000000, - }, - } - var uiim uiim - for _, idx := range uii { - uiim.Store(idx.uuid, idx) - } - - return test{ - name: "return true when the uiid dose not exist in uiim", - args: args{ - uuid: uuid, - }, - fields: fields{ - uiim: uiimNoLock{ - read: uiim.read, - dirty: uiim.dirty, - misses: uiim.misses, - }, - udim: udimNoLock{ - read: udim.read, - dirty: udim.dirty, - misses: udim.misses, - }, - }, - want: want{ - want: true, - }, - } - }(), - func() test { - uuid := "146bbe1a-bc48-11eb-8529-0242ac130003" - udk := []key{ - { - uuid: uuid, - date: 1000000000, - }, - { - uuid: "246bbe1a-bc48-11eb-8529-0242ac130003", - date: 2000000000, - }, - } - var udim udim - for _, key := range udk { - udim.Store(key.uuid, key.date) - } - - return test{ - name: "return true when the uiim is empty", - args: args{ - uuid: uuid, - }, - fields: fields{ - udim: udimNoLock{ - read: udim.read, - dirty: udim.dirty, - misses: udim.misses, - }, - }, - want: want{ - want: true, - }, - } - }(), - func() test { - uuid := "146bbe1a-bc48-11eb-8529-0242ac130003" - udk := []key{ - { - uuid: uuid, - date: 1000000000, - }, - { - uuid: "246bbe1a-bc48-11eb-8529-0242ac130003", - date: 2000000000, - }, - } - var udim udim - for _, key := range udk { - udim.Store(key.uuid, key.date) - } - - uii := []index{ - { - uuid: uuid, - vector: []float32{1}, - date: 1000000000, - }, - { - uuid: "346bbe1a-bc48-11eb-8529-0242ac130003", - vector: []float32{2}, - date: 4000000000, - }, - } - var uiim uiim - for _, idx := range uii { - uiim.Store(idx.uuid, idx) - } - - return test{ - name: "return true when the date of udim is equal the date of uiim", - args: args{ - uuid: uuid, - }, - fields: fields{ - uiim: uiimNoLock{ - read: uiim.read, - dirty: uiim.dirty, - misses: uiim.misses, - }, - udim: udimNoLock{ - read: udim.read, - dirty: udim.dirty, - misses: udim.misses, - }, - }, - want: want{ - want: false, - }, - } - }(), - func() test { - uuid := "146bbe1a-bc48-11eb-8529-0242ac130003" - udk := []key{ - { - uuid: uuid, - date: 1000000001, - }, - { - uuid: "246bbe1a-bc48-11eb-8529-0242ac130003", - date: 2000000000, - }, - } - var udim udim - for _, key := range udk { - udim.Store(key.uuid, key.date) - } - - uii := []index{ - { - uuid: uuid, - vector: []float32{1}, - date: 1000000000, - }, - { - uuid: "346bbe1a-bc48-11eb-8529-0242ac130003", - vector: []float32{2}, - date: 4000000000, - }, - } - var uiim uiim - for _, idx := range uii { - uiim.Store(idx.uuid, idx) - } - - return test{ - name: "return true when the date of udim is newer than the date of uiim", - args: args{ - uuid: uuid, - }, - fields: fields{ - uiim: uiimNoLock{ - read: uiim.read, - dirty: uiim.dirty, - misses: uiim.misses, - }, - udim: udimNoLock{ - read: udim.read, - dirty: udim.dirty, - misses: udim.misses, - }, - }, - want: want{ - want: true, - }, - } - }(), - func() test { - uuid := "146bbe1a-bc48-11eb-8529-0242ac130003" - udk := []key{ - { - uuid: uuid, - date: 999999999, - }, - { - uuid: "246bbe1a-bc48-11eb-8529-0242ac130003", - date: 2000000000, - }, - } - var udim udim - for _, key := range udk { - udim.Store(key.uuid, key.date) - } - - uii := []index{ - { - uuid: uuid, - vector: []float32{1}, - date: 1000000000, - }, - { - uuid: "346bbe1a-bc48-11eb-8529-0242ac130003", - vector: []float32{2}, - date: 4000000000, - }, - } - var uiim uiim - for _, idx := range uii { - uiim.Store(idx.uuid, idx) - } + // TODO test cases + /* + { + name: "test_case_1", + args: args { + uuid: "", + }, + fields: fields { + il: indexMap{}, + dl: indexMap{}, + ic: 0, + dc: 0, + }, + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + }, + */ - return test{ - name: "return false when the date of udim is older than the date of uiim", - args: args{ - uuid: uuid, - }, - fields: fields{ - uiim: uiimNoLock{ - read: uiim.read, - dirty: uiim.dirty, - misses: uiim.misses, - }, - udim: udimNoLock{ - read: udim.read, - dirty: udim.dirty, - misses: udim.misses, - }, - }, - want: want{ - want: false, - }, - } - }(), + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + args: args { + uuid: "", + }, + fields: fields { + il: indexMap{}, + dl: indexMap{}, + ic: 0, + dc: 0, + }, + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, + } + }(), + */ } for _, tc := range tests { @@ -1845,31 +654,20 @@ func Test_vqueue_DVExists(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { checkFunc = defaultCheckFunc } v := &vqueue{ - uii: test.fields.uii, - uiim: uiim{ - read: test.fields.uiim.read, - dirty: test.fields.uiim.dirty, - misses: test.fields.uiim.misses, - }, - udk: test.fields.udk, - udim: udim{ - read: test.fields.udim.read, - dirty: test.fields.udim.dirty, - misses: test.fields.udim.misses, - }, - eg: test.fields.eg, - iBufSize: test.fields.iBufSize, - dBufSize: test.fields.dBufSize, + il: test.fields.il, + dl: test.fields.dl, + ic: test.fields.ic, + dc: test.fields.dc, } got := v.DVExists(test.args.uuid) @@ -1880,18 +678,17 @@ func Test_vqueue_DVExists(t *testing.T) { } } -func Test_vqueue_addInsert(t *testing.T) { +func Test_vqueue_RangePopInsert(t *testing.T) { type args struct { - i index + in0 context.Context + now int64 + f func(uuid string, vector []float32) bool } type fields struct { - uii []index - uiim uiimNoLock - udk []key - udim udimNoLock - eg errgroup.Group - iBufSize int - dBufSize int + il indexMap + dl indexMap + ic uint64 + dc uint64 } type want struct{} type test struct { @@ -1900,8 +697,8 @@ func Test_vqueue_addInsert(t *testing.T) { fields fields want want checkFunc func(want) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want) error { return nil @@ -1912,23 +709,24 @@ func Test_vqueue_addInsert(t *testing.T) { { name: "test_case_1", args: args { - i: index{}, + in0: nil, + now: 0, + f: nil, }, fields: fields { - ich: nil, - uii: nil, - uiim: uiimNoLock{}, - dch: nil, - udk: nil, - udim: udimNoLock{}, - eg: nil, - ichSize: 0, - dchSize: 0, - iBufSize: 0, - dBufSize: 0, + il: indexMap{}, + dl: indexMap{}, + ic: 0, + dc: 0, }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -1938,23 +736,24 @@ func Test_vqueue_addInsert(t *testing.T) { return test { name: "test_case_2", args: args { - i: index{}, + in0: nil, + now: 0, + f: nil, }, fields: fields { - ich: nil, - uii: nil, - uiim: uiimNoLock{}, - dch: nil, - udk: nil, - udim: udimNoLock{}, - eg: nil, - ichSize: 0, - dchSize: 0, - iBufSize: 0, - dBufSize: 0, + il: indexMap{}, + dl: indexMap{}, + ic: 0, + dc: 0, }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -1966,34 +765,23 @@ func Test_vqueue_addInsert(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { checkFunc = defaultCheckFunc } v := &vqueue{ - uii: test.fields.uii, - uiim: uiim{ - read: test.fields.uiim.read, - dirty: test.fields.uiim.dirty, - misses: test.fields.uiim.misses, - }, - udk: test.fields.udk, - udim: udim{ - read: test.fields.udim.read, - dirty: test.fields.udim.dirty, - misses: test.fields.udim.misses, - }, - eg: test.fields.eg, - iBufSize: test.fields.iBufSize, - dBufSize: test.fields.dBufSize, + il: test.fields.il, + dl: test.fields.dl, + ic: test.fields.ic, + dc: test.fields.dc, } - v.addInsert(test.args.i) + v.RangePopInsert(test.args.in0, test.args.now, test.args.f) if err := checkFunc(test.want); err != nil { tt.Errorf("error = %v", err) } @@ -2001,18 +789,17 @@ func Test_vqueue_addInsert(t *testing.T) { } } -func Test_vqueue_addDelete(t *testing.T) { +func Test_vqueue_RangePopDelete(t *testing.T) { type args struct { - d key + in0 context.Context + now int64 + f func(uuid string) bool } type fields struct { - uii []index - uiim uiimNoLock - udk []key - udim udimNoLock - eg errgroup.Group - iBufSize int - dBufSize int + il indexMap + dl indexMap + ic uint64 + dc uint64 } type want struct{} type test struct { @@ -2021,8 +808,8 @@ func Test_vqueue_addDelete(t *testing.T) { fields fields want want checkFunc func(want) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func(*testing.T, args) + afterFunc func(*testing.T, args) } defaultCheckFunc := func(w want) error { return nil @@ -2033,23 +820,24 @@ func Test_vqueue_addDelete(t *testing.T) { { name: "test_case_1", args: args { - d: key{}, + in0: nil, + now: 0, + f: nil, }, fields: fields { - ich: nil, - uii: nil, - uiim: uiimNoLock{}, - dch: nil, - udk: nil, - udim: udimNoLock{}, - eg: nil, - ichSize: 0, - dchSize: 0, - iBufSize: 0, - dBufSize: 0, + il: indexMap{}, + dl: indexMap{}, + ic: 0, + dc: 0, }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, }, */ @@ -2059,23 +847,24 @@ func Test_vqueue_addDelete(t *testing.T) { return test { name: "test_case_2", args: args { - d: key{}, + in0: nil, + now: 0, + f: nil, }, fields: fields { - ich: nil, - uii: nil, - uiim: uiimNoLock{}, - dch: nil, - udk: nil, - udim: udimNoLock{}, - eg: nil, - ichSize: 0, - dchSize: 0, - iBufSize: 0, - dBufSize: 0, + il: indexMap{}, + dl: indexMap{}, + ic: 0, + dc: 0, }, want: want{}, checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T, args args) { + t.Helper() + }, + afterFunc: func(t *testing.T, args args) { + t.Helper() + }, } }(), */ @@ -2087,34 +876,23 @@ func Test_vqueue_addDelete(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc(tt, test.args) } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc(tt, test.args) } checkFunc := test.checkFunc if test.checkFunc == nil { checkFunc = defaultCheckFunc } v := &vqueue{ - uii: test.fields.uii, - uiim: uiim{ - read: test.fields.uiim.read, - dirty: test.fields.uiim.dirty, - misses: test.fields.uiim.misses, - }, - udk: test.fields.udk, - udim: udim{ - read: test.fields.udim.read, - dirty: test.fields.udim.dirty, - misses: test.fields.udim.misses, - }, - eg: test.fields.eg, - iBufSize: test.fields.iBufSize, - dBufSize: test.fields.dBufSize, + il: test.fields.il, + dl: test.fields.dl, + ic: test.fields.ic, + dc: test.fields.dc, } - v.addDelete(test.args.d) + v.RangePopDelete(test.args.in0, test.args.now, test.args.f) if err := checkFunc(test.want); err != nil { tt.Errorf("error = %v", err) } @@ -2124,13 +902,10 @@ func Test_vqueue_addDelete(t *testing.T) { func Test_vqueue_IVQLen(t *testing.T) { type fields struct { - uii []index - uiim uiimNoLock - udk []key - udim udimNoLock - eg errgroup.Group - iBufSize int - dBufSize int + il indexMap + dl indexMap + ic uint64 + dc uint64 } type want struct { wantL int @@ -2140,8 +915,8 @@ func Test_vqueue_IVQLen(t *testing.T) { fields fields want want checkFunc func(want, int) error - beforeFunc func() - afterFunc func() + beforeFunc func(*testing.T) + afterFunc func(*testing.T) } defaultCheckFunc := func(w want, gotL int) error { if !reflect.DeepEqual(gotL, w.wantL) { @@ -2150,102 +925,49 @@ func Test_vqueue_IVQLen(t *testing.T) { return nil } tests := []test{ - func() test { - size := 0 - uii := make([]index, size) - - return test{ - name: "return 0 when the capacity and length is 0", - fields: fields{ - uii: uii, - }, - want: want{ - wantL: size, - }, - } - }(), - func() test { - size := 10 - uii := make([]index, size) - - return test{ - name: "return 10 when the capacity and length is 10", - fields: fields{ - uii: uii, - }, - want: want{ - wantL: size, - }, - } - }(), - func() test { - c := 10 - l := 5 - uii := make([]index, l, c) - - return test{ - name: "return 5 when the capacity is 10 and the length is 5", - fields: fields{ - uii: uii, - }, - want: want{ - wantL: l, - }, - } - }(), - func() test { - iniLen := 5 - isrtSize := 2 - uii := make([]index, iniLen, 10) - for i := 0; i < isrtSize; i++ { - uii = append(uii, index{}) - } - - return test{ - name: "return 7 when the capacity is 10 and the initial length is 5 but the inserted size is 2", - fields: fields{ - uii: uii, - }, - want: want{ - wantL: iniLen + isrtSize, - }, - } - }(), - func() test { - size := 10 - uii := make([]index, 0, size) - for i := 0; i < size; i++ { - uii = append(uii, index{}) - } - - return test{ - name: "return 10 when the inserted size is 10", - fields: fields{ - uii: uii, - }, - want: want{ - wantL: size, - }, - } - }(), - func() test { - insertSize := 5 - size := 10 - uii := make([]index, 0, size) - for i := 0; i < insertSize; i++ { - uii = append(uii, index{}) - } + // TODO test cases + /* + { + name: "test_case_1", + fields: fields { + il: indexMap{}, + dl: indexMap{}, + ic: 0, + dc: 0, + }, + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, + }, + */ - return test{ - name: "return 5 when the capacity is 10 and the inserted size is 5", - fields: fields{ - uii: uii, - }, - want: want{ - wantL: insertSize, - }, - } - }(), + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + fields: fields { + il: indexMap{}, + dl: indexMap{}, + ic: 0, + dc: 0, + }, + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, + } + }(), + */ } for _, tc := range tests { @@ -2254,31 +976,20 @@ func Test_vqueue_IVQLen(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc() + test.beforeFunc(tt) } if test.afterFunc != nil { - defer test.afterFunc() + defer test.afterFunc(tt) } checkFunc := test.checkFunc if test.checkFunc == nil { checkFunc = defaultCheckFunc } v := &vqueue{ - uii: test.fields.uii, - uiim: uiim{ - read: test.fields.uiim.read, - dirty: test.fields.uiim.dirty, - misses: test.fields.uiim.misses, - }, - udk: test.fields.udk, - udim: udim{ - read: test.fields.udim.read, - dirty: test.fields.udim.dirty, - misses: test.fields.udim.misses, - }, - eg: test.fields.eg, - iBufSize: test.fields.iBufSize, - dBufSize: test.fields.dBufSize, + il: test.fields.il, + dl: test.fields.dl, + ic: test.fields.ic, + dc: test.fields.dc, } gotL := v.IVQLen() @@ -2291,13 +1002,10 @@ func Test_vqueue_IVQLen(t *testing.T) { func Test_vqueue_DVQLen(t *testing.T) { type fields struct { - uii []index - uiim uiimNoLock - udk []key - udim udimNoLock - eg errgroup.Group - iBufSize int - dBufSize int + il indexMap + dl indexMap + ic uint64 + dc uint64 } type want struct { wantL int @@ -2307,8 +1015,8 @@ func Test_vqueue_DVQLen(t *testing.T) { fields fields want want checkFunc func(want, int) error - beforeFunc func() - afterFunc func() + beforeFunc func(*testing.T) + afterFunc func(*testing.T) } defaultCheckFunc := func(w want, gotL int) error { if !reflect.DeepEqual(gotL, w.wantL) { @@ -2317,102 +1025,49 @@ func Test_vqueue_DVQLen(t *testing.T) { return nil } tests := []test{ - func() test { - size := 0 - udk := make([]key, size) - - return test{ - name: "return 0 when the capacity and length is 0", - fields: fields{ - udk: udk, - }, - want: want{ - wantL: size, - }, - } - }(), - func() test { - size := 10 - udk := make([]key, size) - - return test{ - name: "return 10 when the capacity and length is 10", - fields: fields{ - udk: udk, - }, - want: want{ - wantL: size, - }, - } - }(), - func() test { - c := 10 - l := 5 - udk := make([]key, l, c) - - return test{ - name: "return 5 when the capacity is 10 and the length is 5", - fields: fields{ - udk: udk, - }, - want: want{ - wantL: l, - }, - } - }(), - func() test { - iniLen := 5 - isrtSize := 2 - udk := make([]key, iniLen, 10) - for i := 0; i < isrtSize; i++ { - udk = append(udk, key{}) - } - - return test{ - name: "return 7 when the capacity is 10 and the initial length is 5 but the inserted size is 2", - fields: fields{ - udk: udk, - }, - want: want{ - wantL: iniLen + isrtSize, - }, - } - }(), - func() test { - size := 10 - udk := make([]key, 0, size) - for i := 0; i < size; i++ { - udk = append(udk, key{}) - } - - return test{ - name: "return 10 when the inserted size is 10", - fields: fields{ - udk: udk, - }, - want: want{ - wantL: size, - }, - } - }(), - func() test { - insertSize := 5 - size := 10 - udk := make([]key, 0, size) - for i := 0; i < insertSize; i++ { - udk = append(udk, key{}) - } + // TODO test cases + /* + { + name: "test_case_1", + fields: fields { + il: indexMap{}, + dl: indexMap{}, + ic: 0, + dc: 0, + }, + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, + }, + */ - return test{ - name: "return 5 when the capacity is 10 and the inserted size is 5", - fields: fields{ - udk: udk, - }, - want: want{ - wantL: insertSize, - }, - } - }(), + // TODO test cases + /* + func() test { + return test { + name: "test_case_2", + fields: fields { + il: indexMap{}, + dl: indexMap{}, + ic: 0, + dc: 0, + }, + want: want{}, + checkFunc: defaultCheckFunc, + beforeFunc: func(t *testing.T,) { + t.Helper() + }, + afterFunc: func(t *testing.T,) { + t.Helper() + }, + } + }(), + */ } for _, tc := range tests { @@ -2421,31 +1076,20 @@ func Test_vqueue_DVQLen(t *testing.T) { tt.Parallel() defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) if test.beforeFunc != nil { - test.beforeFunc() + test.beforeFunc(tt) } if test.afterFunc != nil { - defer test.afterFunc() + defer test.afterFunc(tt) } checkFunc := test.checkFunc if test.checkFunc == nil { checkFunc = defaultCheckFunc } v := &vqueue{ - uii: test.fields.uii, - uiim: uiim{ - read: test.fields.uiim.read, - dirty: test.fields.uiim.dirty, - misses: test.fields.uiim.misses, - }, - udk: test.fields.udk, - udim: udim{ - read: test.fields.udim.read, - dirty: test.fields.udim.dirty, - misses: test.fields.udim.misses, - }, - eg: test.fields.eg, - iBufSize: test.fields.iBufSize, - dBufSize: test.fields.dBufSize, + il: test.fields.il, + dl: test.fields.dl, + ic: test.fields.ic, + dc: test.fields.dc, } gotL := v.DVQLen() diff --git a/pkg/agent/core/ngt/service/vqueue/undeleted_index_map.go b/pkg/agent/core/ngt/service/vqueue/undeleted_index_map.go deleted file mode 100644 index 0b83a13da9..0000000000 --- a/pkg/agent/core/ngt/service/vqueue/undeleted_index_map.go +++ /dev/null @@ -1,274 +0,0 @@ -// Copyright (C) 2019-2022 vdaas.org vald team -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -package vqueue - -import ( - "sync" - "sync/atomic" - "unsafe" -) - -type udim struct { - mu sync.Mutex - read atomic.Value - dirty map[string]*entryUdim - misses int -} - -type readOnlyUdim struct { - m map[string]*entryUdim - amended bool -} - -// skipcq: GSC-G103 -var expungedUdim = unsafe.Pointer(new(int64)) - -type entryUdim struct { - p unsafe.Pointer -} - -func newEntryUdim(i int64) *entryUdim { - // skipcq: GSC-G103 - return &entryUdim{p: unsafe.Pointer(&i)} -} - -func (m *udim) Load(key string) (value int64, ok bool) { - read, _ := m.read.Load().(readOnlyUdim) - e, ok := read.m[key] - if !ok && read.amended { - m.mu.Lock() - read, _ = m.read.Load().(readOnlyUdim) - e, ok = read.m[key] - if !ok && read.amended { - e, ok = m.dirty[key] - m.missLocked() - } - m.mu.Unlock() - } - if !ok { - return value, false - } - return e.load() -} - -func (e *entryUdim) load() (value int64, ok bool) { - p := atomic.LoadPointer(&e.p) - if p == nil || p == expungedUdim { - return value, false - } - return *(*int64)(p), true -} - -func (m *udim) Store(key string, value int64) { - read, _ := m.read.Load().(readOnlyUdim) - if e, ok := read.m[key]; ok && e.tryStore(&value) { - return - } - - m.mu.Lock() - read, _ = m.read.Load().(readOnlyUdim) - if e, ok := read.m[key]; ok { - if e.unexpungeLocked() { - m.dirty[key] = e - } - e.storeLocked(&value) - } else if e, ok := m.dirty[key]; ok { - e.storeLocked(&value) - } else { - if !read.amended { - m.dirtyLocked() - m.read.Store(readOnlyUdim{m: read.m, amended: true}) - } - m.dirty[key] = newEntryUdim(value) - } - m.mu.Unlock() -} - -func (e *entryUdim) tryStore(i *int64) bool { - for { - p := atomic.LoadPointer(&e.p) - if p == expungedUdim { - return false - } - // skipcq: GSC-G103 - if atomic.CompareAndSwapPointer(&e.p, p, unsafe.Pointer(i)) { - return true - } - } -} - -func (e *entryUdim) unexpungeLocked() (wasExpunged bool) { - return atomic.CompareAndSwapPointer(&e.p, expungedUdim, nil) -} - -func (e *entryUdim) storeLocked(i *int64) { - // skipcq: GSC-G103 - atomic.StorePointer(&e.p, unsafe.Pointer(i)) -} - -func (m *udim) LoadOrStore(key string, value int64) (actual int64, loaded bool) { - read, _ := m.read.Load().(readOnlyUdim) - if e, ok := read.m[key]; ok { - actual, loaded, ok := e.tryLoadOrStore(value) - if ok { - return actual, loaded - } - } - - m.mu.Lock() - read, _ = m.read.Load().(readOnlyUdim) - if e, ok := read.m[key]; ok { - if e.unexpungeLocked() { - m.dirty[key] = e - } - actual, loaded, _ = e.tryLoadOrStore(value) - } else if e, ok := m.dirty[key]; ok { - actual, loaded, _ = e.tryLoadOrStore(value) - m.missLocked() - } else { - if !read.amended { - - m.dirtyLocked() - m.read.Store(readOnlyUdim{m: read.m, amended: true}) - } - m.dirty[key] = newEntryUdim(value) - actual, loaded = value, false - } - m.mu.Unlock() - - return actual, loaded -} - -func (e *entryUdim) tryLoadOrStore(i int64) (actual int64, loaded, ok bool) { - p := atomic.LoadPointer(&e.p) - if p == expungedUdim { - return actual, false, false - } - if p != nil { - return *(*int64)(p), true, true - } - - ic := i - for { - // skipcq: GSC-G103 - if atomic.CompareAndSwapPointer(&e.p, nil, unsafe.Pointer(&ic)) { - return i, false, true - } - p = atomic.LoadPointer(&e.p) - if p == expungedUdim { - return actual, false, false - } - if p != nil { - return *(*int64)(p), true, true - } - } -} - -func (m *udim) LoadAndDelete(key string) (value int64, loaded bool) { - read, _ := m.read.Load().(readOnlyUdim) - e, ok := read.m[key] - if !ok && read.amended { - m.mu.Lock() - read, _ = m.read.Load().(readOnlyUdim) - e, ok = read.m[key] - if !ok && read.amended { - e, ok = m.dirty[key] - delete(m.dirty, key) - - m.missLocked() - } - m.mu.Unlock() - } - if ok { - return e.delete() - } - return value, false -} - -func (m *udim) Delete(key string) { - m.LoadAndDelete(key) -} - -func (e *entryUdim) delete() (value int64, ok bool) { - for { - p := atomic.LoadPointer(&e.p) - if p == nil || p == expungedUdim { - return value, false - } - if atomic.CompareAndSwapPointer(&e.p, p, nil) { - return *(*int64)(p), true - } - } -} - -func (m *udim) Range(f func(key string, value int64) bool) { - read, _ := m.read.Load().(readOnlyUdim) - if read.amended { - - m.mu.Lock() - read, _ = m.read.Load().(readOnlyUdim) - if read.amended { - read = readOnlyUdim{m: m.dirty} - m.read.Store(read) - m.dirty = nil - m.misses = 0 - } - m.mu.Unlock() - } - - for k, e := range read.m { - v, ok := e.load() - if !ok { - continue - } - if !f(k, v) { - break - } - } -} - -func (m *udim) missLocked() { - m.misses++ - if m.misses < len(m.dirty) { - return - } - m.read.Store(readOnlyUdim{m: m.dirty}) - m.dirty = nil - m.misses = 0 -} - -func (m *udim) dirtyLocked() { - if m.dirty != nil { - return - } - - read, _ := m.read.Load().(readOnlyUdim) - m.dirty = make(map[string]*entryUdim, len(read.m)) - for k, e := range read.m { - if !e.tryExpungeLocked() { - m.dirty[k] = e - } - } -} - -func (e *entryUdim) tryExpungeLocked() (isExpunged bool) { - p := atomic.LoadPointer(&e.p) - for p == nil { - if atomic.CompareAndSwapPointer(&e.p, nil, expungedUdim) { - return true - } - p = atomic.LoadPointer(&e.p) - } - return p == expungedUdim -} diff --git a/pkg/agent/core/ngt/service/vqueue/undeleted_index_map_test.go b/pkg/agent/core/ngt/service/vqueue/undeleted_index_map_test.go deleted file mode 100644 index f583164bf0..0000000000 --- a/pkg/agent/core/ngt/service/vqueue/undeleted_index_map_test.go +++ /dev/null @@ -1,1395 +0,0 @@ -// Copyright (C) 2019-2022 vdaas.org vald team -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -package vqueue - -import ( - "reflect" - "sync/atomic" - "testing" - "unsafe" - - "github.com/vdaas/vald/internal/errors" - "github.com/vdaas/vald/internal/test/goleak" -) - -func Test_newEntryUdim(t *testing.T) { - type args struct { - i int64 - } - type want struct { - want *entryUdim - } - type test struct { - name string - args args - want want - checkFunc func(want, *entryUdim) error - beforeFunc func(args) - afterFunc func(args) - } - defaultCheckFunc := func(w want, got *entryUdim) error { - if !reflect.DeepEqual(got, w.want) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) - } - return nil - } - tests := []test{ - // TODO test cases - /* - { - name: "test_case_1", - args: args { - i: 0, - }, - want: want{}, - checkFunc: defaultCheckFunc, - }, - */ - - // TODO test cases - /* - func() test { - return test { - name: "test_case_2", - args: args { - i: 0, - }, - want: want{}, - checkFunc: defaultCheckFunc, - } - }(), - */ - } - - for _, tc := range tests { - test := tc - t.Run(test.name, func(tt *testing.T) { - tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) - if test.beforeFunc != nil { - test.beforeFunc(test.args) - } - if test.afterFunc != nil { - defer test.afterFunc(test.args) - } - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - - got := newEntryUdim(test.args.i) - if err := checkFunc(test.want, got); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} - -func Test_udim_Load(t *testing.T) { - type args struct { - key string - } - type fields struct { - read atomic.Value - dirty map[string]*entryUdim - misses int - } - type want struct { - wantValue int64 - wantOk bool - } - type test struct { - name string - args args - fields fields - want want - checkFunc func(want, int64, bool) error - beforeFunc func(args) - afterFunc func(args) - } - defaultCheckFunc := func(w want, gotValue int64, gotOk bool) error { - if !reflect.DeepEqual(gotValue, w.wantValue) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotValue, w.wantValue) - } - if !reflect.DeepEqual(gotOk, w.wantOk) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotOk, w.wantOk) - } - return nil - } - tests := []test{ - // TODO test cases - /* - { - name: "test_case_1", - args: args { - key: "", - }, - fields: fields { - read: nil, - dirty: nil, - misses: 0, - }, - want: want{}, - checkFunc: defaultCheckFunc, - }, - */ - - // TODO test cases - /* - func() test { - return test { - name: "test_case_2", - args: args { - key: "", - }, - fields: fields { - read: nil, - dirty: nil, - misses: 0, - }, - want: want{}, - checkFunc: defaultCheckFunc, - } - }(), - */ - } - - for _, tc := range tests { - test := tc - t.Run(test.name, func(tt *testing.T) { - tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) - if test.beforeFunc != nil { - test.beforeFunc(test.args) - } - if test.afterFunc != nil { - defer test.afterFunc(test.args) - } - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - m := &udim{ - read: test.fields.read, - dirty: test.fields.dirty, - misses: test.fields.misses, - } - - gotValue, gotOk := m.Load(test.args.key) - if err := checkFunc(test.want, gotValue, gotOk); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} - -func Test_entryUdim_load(t *testing.T) { - type fields struct { - p unsafe.Pointer - } - type want struct { - wantValue int64 - wantOk bool - } - type test struct { - name string - fields fields - want want - checkFunc func(want, int64, bool) error - beforeFunc func() - afterFunc func() - } - defaultCheckFunc := func(w want, gotValue int64, gotOk bool) error { - if !reflect.DeepEqual(gotValue, w.wantValue) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotValue, w.wantValue) - } - if !reflect.DeepEqual(gotOk, w.wantOk) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotOk, w.wantOk) - } - return nil - } - tests := []test{ - // TODO test cases - /* - { - name: "test_case_1", - fields: fields { - p: nil, - }, - want: want{}, - checkFunc: defaultCheckFunc, - }, - */ - - // TODO test cases - /* - func() test { - return test { - name: "test_case_2", - fields: fields { - p: nil, - }, - want: want{}, - checkFunc: defaultCheckFunc, - } - }(), - */ - } - - for _, tc := range tests { - test := tc - t.Run(test.name, func(tt *testing.T) { - tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) - if test.beforeFunc != nil { - test.beforeFunc() - } - if test.afterFunc != nil { - defer test.afterFunc() - } - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - e := &entryUdim{ - p: test.fields.p, - } - - gotValue, gotOk := e.load() - if err := checkFunc(test.want, gotValue, gotOk); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} - -func Test_udim_Store(t *testing.T) { - type args struct { - key string - value int64 - } - type fields struct { - read atomic.Value - dirty map[string]*entryUdim - misses int - } - type want struct{} - type test struct { - name string - args args - fields fields - want want - checkFunc func(want) error - beforeFunc func(args) - afterFunc func(args) - } - defaultCheckFunc := func(w want) error { - return nil - } - tests := []test{ - // TODO test cases - /* - { - name: "test_case_1", - args: args { - key: "", - value: 0, - }, - fields: fields { - read: nil, - dirty: nil, - misses: 0, - }, - want: want{}, - checkFunc: defaultCheckFunc, - }, - */ - - // TODO test cases - /* - func() test { - return test { - name: "test_case_2", - args: args { - key: "", - value: 0, - }, - fields: fields { - read: nil, - dirty: nil, - misses: 0, - }, - want: want{}, - checkFunc: defaultCheckFunc, - } - }(), - */ - } - - for _, tc := range tests { - test := tc - t.Run(test.name, func(tt *testing.T) { - tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) - if test.beforeFunc != nil { - test.beforeFunc(test.args) - } - if test.afterFunc != nil { - defer test.afterFunc(test.args) - } - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - m := &udim{ - read: test.fields.read, - dirty: test.fields.dirty, - misses: test.fields.misses, - } - - m.Store(test.args.key, test.args.value) - if err := checkFunc(test.want); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} - -func Test_entryUdim_tryStore(t *testing.T) { - type args struct { - i *int64 - } - type fields struct { - p unsafe.Pointer - } - type want struct { - want bool - } - type test struct { - name string - args args - fields fields - want want - checkFunc func(want, bool) error - beforeFunc func(args) - afterFunc func(args) - } - defaultCheckFunc := func(w want, got bool) error { - if !reflect.DeepEqual(got, w.want) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", got, w.want) - } - return nil - } - tests := []test{ - // TODO test cases - /* - { - name: "test_case_1", - args: args { - i: nil, - }, - fields: fields { - p: nil, - }, - want: want{}, - checkFunc: defaultCheckFunc, - }, - */ - - // TODO test cases - /* - func() test { - return test { - name: "test_case_2", - args: args { - i: nil, - }, - fields: fields { - p: nil, - }, - want: want{}, - checkFunc: defaultCheckFunc, - } - }(), - */ - } - - for _, tc := range tests { - test := tc - t.Run(test.name, func(tt *testing.T) { - tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) - if test.beforeFunc != nil { - test.beforeFunc(test.args) - } - if test.afterFunc != nil { - defer test.afterFunc(test.args) - } - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - e := &entryUdim{ - p: test.fields.p, - } - - got := e.tryStore(test.args.i) - if err := checkFunc(test.want, got); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} - -func Test_entryUdim_unexpungeLocked(t *testing.T) { - type fields struct { - p unsafe.Pointer - } - type want struct { - wantWasExpunged bool - } - type test struct { - name string - fields fields - want want - checkFunc func(want, bool) error - beforeFunc func() - afterFunc func() - } - defaultCheckFunc := func(w want, gotWasExpunged bool) error { - if !reflect.DeepEqual(gotWasExpunged, w.wantWasExpunged) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotWasExpunged, w.wantWasExpunged) - } - return nil - } - tests := []test{ - // TODO test cases - /* - { - name: "test_case_1", - fields: fields { - p: nil, - }, - want: want{}, - checkFunc: defaultCheckFunc, - }, - */ - - // TODO test cases - /* - func() test { - return test { - name: "test_case_2", - fields: fields { - p: nil, - }, - want: want{}, - checkFunc: defaultCheckFunc, - } - }(), - */ - } - - for _, tc := range tests { - test := tc - t.Run(test.name, func(tt *testing.T) { - tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) - if test.beforeFunc != nil { - test.beforeFunc() - } - if test.afterFunc != nil { - defer test.afterFunc() - } - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - e := &entryUdim{ - p: test.fields.p, - } - - gotWasExpunged := e.unexpungeLocked() - if err := checkFunc(test.want, gotWasExpunged); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} - -func Test_entryUdim_storeLocked(t *testing.T) { - type args struct { - i *int64 - } - type fields struct { - p unsafe.Pointer - } - type want struct{} - type test struct { - name string - args args - fields fields - want want - checkFunc func(want) error - beforeFunc func(args) - afterFunc func(args) - } - defaultCheckFunc := func(w want) error { - return nil - } - tests := []test{ - // TODO test cases - /* - { - name: "test_case_1", - args: args { - i: nil, - }, - fields: fields { - p: nil, - }, - want: want{}, - checkFunc: defaultCheckFunc, - }, - */ - - // TODO test cases - /* - func() test { - return test { - name: "test_case_2", - args: args { - i: nil, - }, - fields: fields { - p: nil, - }, - want: want{}, - checkFunc: defaultCheckFunc, - } - }(), - */ - } - - for _, tc := range tests { - test := tc - t.Run(test.name, func(tt *testing.T) { - tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) - if test.beforeFunc != nil { - test.beforeFunc(test.args) - } - if test.afterFunc != nil { - defer test.afterFunc(test.args) - } - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - e := &entryUdim{ - p: test.fields.p, - } - - e.storeLocked(test.args.i) - if err := checkFunc(test.want); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} - -func Test_udim_LoadOrStore(t *testing.T) { - type args struct { - key string - value int64 - } - type fields struct { - read atomic.Value - dirty map[string]*entryUdim - misses int - } - type want struct { - wantActual int64 - wantLoaded bool - } - type test struct { - name string - args args - fields fields - want want - checkFunc func(want, int64, bool) error - beforeFunc func(args) - afterFunc func(args) - } - defaultCheckFunc := func(w want, gotActual int64, gotLoaded bool) error { - if !reflect.DeepEqual(gotActual, w.wantActual) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotActual, w.wantActual) - } - if !reflect.DeepEqual(gotLoaded, w.wantLoaded) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotLoaded, w.wantLoaded) - } - return nil - } - tests := []test{ - // TODO test cases - /* - { - name: "test_case_1", - args: args { - key: "", - value: 0, - }, - fields: fields { - read: nil, - dirty: nil, - misses: 0, - }, - want: want{}, - checkFunc: defaultCheckFunc, - }, - */ - - // TODO test cases - /* - func() test { - return test { - name: "test_case_2", - args: args { - key: "", - value: 0, - }, - fields: fields { - read: nil, - dirty: nil, - misses: 0, - }, - want: want{}, - checkFunc: defaultCheckFunc, - } - }(), - */ - } - - for _, tc := range tests { - test := tc - t.Run(test.name, func(tt *testing.T) { - tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) - if test.beforeFunc != nil { - test.beforeFunc(test.args) - } - if test.afterFunc != nil { - defer test.afterFunc(test.args) - } - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - m := &udim{ - read: test.fields.read, - dirty: test.fields.dirty, - misses: test.fields.misses, - } - - gotActual, gotLoaded := m.LoadOrStore(test.args.key, test.args.value) - if err := checkFunc(test.want, gotActual, gotLoaded); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} - -func Test_entryUdim_tryLoadOrStore(t *testing.T) { - type args struct { - i int64 - } - type fields struct { - p unsafe.Pointer - } - type want struct { - wantActual int64 - wantLoaded bool - wantOk bool - } - type test struct { - name string - args args - fields fields - want want - checkFunc func(want, int64, bool, bool) error - beforeFunc func(args) - afterFunc func(args) - } - defaultCheckFunc := func(w want, gotActual int64, gotLoaded bool, gotOk bool) error { - if !reflect.DeepEqual(gotActual, w.wantActual) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotActual, w.wantActual) - } - if !reflect.DeepEqual(gotLoaded, w.wantLoaded) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotLoaded, w.wantLoaded) - } - if !reflect.DeepEqual(gotOk, w.wantOk) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotOk, w.wantOk) - } - return nil - } - tests := []test{ - // TODO test cases - /* - { - name: "test_case_1", - args: args { - i: 0, - }, - fields: fields { - p: nil, - }, - want: want{}, - checkFunc: defaultCheckFunc, - }, - */ - - // TODO test cases - /* - func() test { - return test { - name: "test_case_2", - args: args { - i: 0, - }, - fields: fields { - p: nil, - }, - want: want{}, - checkFunc: defaultCheckFunc, - } - }(), - */ - } - - for _, tc := range tests { - test := tc - t.Run(test.name, func(tt *testing.T) { - tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) - if test.beforeFunc != nil { - test.beforeFunc(test.args) - } - if test.afterFunc != nil { - defer test.afterFunc(test.args) - } - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - e := &entryUdim{ - p: test.fields.p, - } - - gotActual, gotLoaded, gotOk := e.tryLoadOrStore(test.args.i) - if err := checkFunc(test.want, gotActual, gotLoaded, gotOk); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} - -func Test_udim_LoadAndDelete(t *testing.T) { - type args struct { - key string - } - type fields struct { - read atomic.Value - dirty map[string]*entryUdim - misses int - } - type want struct { - wantValue int64 - wantLoaded bool - } - type test struct { - name string - args args - fields fields - want want - checkFunc func(want, int64, bool) error - beforeFunc func(args) - afterFunc func(args) - } - defaultCheckFunc := func(w want, gotValue int64, gotLoaded bool) error { - if !reflect.DeepEqual(gotValue, w.wantValue) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotValue, w.wantValue) - } - if !reflect.DeepEqual(gotLoaded, w.wantLoaded) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotLoaded, w.wantLoaded) - } - return nil - } - tests := []test{ - // TODO test cases - /* - { - name: "test_case_1", - args: args { - key: "", - }, - fields: fields { - read: nil, - dirty: nil, - misses: 0, - }, - want: want{}, - checkFunc: defaultCheckFunc, - }, - */ - - // TODO test cases - /* - func() test { - return test { - name: "test_case_2", - args: args { - key: "", - }, - fields: fields { - read: nil, - dirty: nil, - misses: 0, - }, - want: want{}, - checkFunc: defaultCheckFunc, - } - }(), - */ - } - - for _, tc := range tests { - test := tc - t.Run(test.name, func(tt *testing.T) { - tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) - if test.beforeFunc != nil { - test.beforeFunc(test.args) - } - if test.afterFunc != nil { - defer test.afterFunc(test.args) - } - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - m := &udim{ - read: test.fields.read, - dirty: test.fields.dirty, - misses: test.fields.misses, - } - - gotValue, gotLoaded := m.LoadAndDelete(test.args.key) - if err := checkFunc(test.want, gotValue, gotLoaded); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} - -func Test_udim_Delete(t *testing.T) { - type args struct { - key string - } - type fields struct { - read atomic.Value - dirty map[string]*entryUdim - misses int - } - type want struct{} - type test struct { - name string - args args - fields fields - want want - checkFunc func(want) error - beforeFunc func(args) - afterFunc func(args) - } - defaultCheckFunc := func(w want) error { - return nil - } - tests := []test{ - // TODO test cases - /* - { - name: "test_case_1", - args: args { - key: "", - }, - fields: fields { - read: nil, - dirty: nil, - misses: 0, - }, - want: want{}, - checkFunc: defaultCheckFunc, - }, - */ - - // TODO test cases - /* - func() test { - return test { - name: "test_case_2", - args: args { - key: "", - }, - fields: fields { - read: nil, - dirty: nil, - misses: 0, - }, - want: want{}, - checkFunc: defaultCheckFunc, - } - }(), - */ - } - - for _, tc := range tests { - test := tc - t.Run(test.name, func(tt *testing.T) { - tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) - if test.beforeFunc != nil { - test.beforeFunc(test.args) - } - if test.afterFunc != nil { - defer test.afterFunc(test.args) - } - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - m := &udim{ - read: test.fields.read, - dirty: test.fields.dirty, - misses: test.fields.misses, - } - - m.Delete(test.args.key) - if err := checkFunc(test.want); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} - -func Test_entryUdim_delete(t *testing.T) { - type fields struct { - p unsafe.Pointer - } - type want struct { - wantValue int64 - wantOk bool - } - type test struct { - name string - fields fields - want want - checkFunc func(want, int64, bool) error - beforeFunc func() - afterFunc func() - } - defaultCheckFunc := func(w want, gotValue int64, gotOk bool) error { - if !reflect.DeepEqual(gotValue, w.wantValue) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotValue, w.wantValue) - } - if !reflect.DeepEqual(gotOk, w.wantOk) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotOk, w.wantOk) - } - return nil - } - tests := []test{ - // TODO test cases - /* - { - name: "test_case_1", - fields: fields { - p: nil, - }, - want: want{}, - checkFunc: defaultCheckFunc, - }, - */ - - // TODO test cases - /* - func() test { - return test { - name: "test_case_2", - fields: fields { - p: nil, - }, - want: want{}, - checkFunc: defaultCheckFunc, - } - }(), - */ - } - - for _, tc := range tests { - test := tc - t.Run(test.name, func(tt *testing.T) { - tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) - if test.beforeFunc != nil { - test.beforeFunc() - } - if test.afterFunc != nil { - defer test.afterFunc() - } - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - e := &entryUdim{ - p: test.fields.p, - } - - gotValue, gotOk := e.delete() - if err := checkFunc(test.want, gotValue, gotOk); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} - -func Test_udim_Range(t *testing.T) { - type args struct { - f func(key string, value int64) bool - } - type fields struct { - read atomic.Value - dirty map[string]*entryUdim - misses int - } - type want struct{} - type test struct { - name string - args args - fields fields - want want - checkFunc func(want) error - beforeFunc func(args) - afterFunc func(args) - } - defaultCheckFunc := func(w want) error { - return nil - } - tests := []test{ - // TODO test cases - /* - { - name: "test_case_1", - args: args { - f: nil, - }, - fields: fields { - read: nil, - dirty: nil, - misses: 0, - }, - want: want{}, - checkFunc: defaultCheckFunc, - }, - */ - - // TODO test cases - /* - func() test { - return test { - name: "test_case_2", - args: args { - f: nil, - }, - fields: fields { - read: nil, - dirty: nil, - misses: 0, - }, - want: want{}, - checkFunc: defaultCheckFunc, - } - }(), - */ - } - - for _, tc := range tests { - test := tc - t.Run(test.name, func(tt *testing.T) { - tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) - if test.beforeFunc != nil { - test.beforeFunc(test.args) - } - if test.afterFunc != nil { - defer test.afterFunc(test.args) - } - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - m := &udim{ - read: test.fields.read, - dirty: test.fields.dirty, - misses: test.fields.misses, - } - - m.Range(test.args.f) - if err := checkFunc(test.want); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} - -func Test_udim_missLocked(t *testing.T) { - type fields struct { - read atomic.Value - dirty map[string]*entryUdim - misses int - } - type want struct{} - type test struct { - name string - fields fields - want want - checkFunc func(want) error - beforeFunc func() - afterFunc func() - } - defaultCheckFunc := func(w want) error { - return nil - } - tests := []test{ - // TODO test cases - /* - { - name: "test_case_1", - fields: fields { - read: nil, - dirty: nil, - misses: 0, - }, - want: want{}, - checkFunc: defaultCheckFunc, - }, - */ - - // TODO test cases - /* - func() test { - return test { - name: "test_case_2", - fields: fields { - read: nil, - dirty: nil, - misses: 0, - }, - want: want{}, - checkFunc: defaultCheckFunc, - } - }(), - */ - } - - for _, tc := range tests { - test := tc - t.Run(test.name, func(tt *testing.T) { - tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) - if test.beforeFunc != nil { - test.beforeFunc() - } - if test.afterFunc != nil { - defer test.afterFunc() - } - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - m := &udim{ - read: test.fields.read, - dirty: test.fields.dirty, - misses: test.fields.misses, - } - - m.missLocked() - if err := checkFunc(test.want); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} - -func Test_udim_dirtyLocked(t *testing.T) { - type fields struct { - read atomic.Value - dirty map[string]*entryUdim - misses int - } - type want struct{} - type test struct { - name string - fields fields - want want - checkFunc func(want) error - beforeFunc func() - afterFunc func() - } - defaultCheckFunc := func(w want) error { - return nil - } - tests := []test{ - // TODO test cases - /* - { - name: "test_case_1", - fields: fields { - read: nil, - dirty: nil, - misses: 0, - }, - want: want{}, - checkFunc: defaultCheckFunc, - }, - */ - - // TODO test cases - /* - func() test { - return test { - name: "test_case_2", - fields: fields { - read: nil, - dirty: nil, - misses: 0, - }, - want: want{}, - checkFunc: defaultCheckFunc, - } - }(), - */ - } - - for _, tc := range tests { - test := tc - t.Run(test.name, func(tt *testing.T) { - tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) - if test.beforeFunc != nil { - test.beforeFunc() - } - if test.afterFunc != nil { - defer test.afterFunc() - } - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - m := &udim{ - read: test.fields.read, - dirty: test.fields.dirty, - misses: test.fields.misses, - } - - m.dirtyLocked() - if err := checkFunc(test.want); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} - -func Test_entryUdim_tryExpungeLocked(t *testing.T) { - type fields struct { - p unsafe.Pointer - } - type want struct { - wantIsExpunged bool - } - type test struct { - name string - fields fields - want want - checkFunc func(want, bool) error - beforeFunc func() - afterFunc func() - } - defaultCheckFunc := func(w want, gotIsExpunged bool) error { - if !reflect.DeepEqual(gotIsExpunged, w.wantIsExpunged) { - return errors.Errorf("got: \"%#v\",\n\t\t\t\twant: \"%#v\"", gotIsExpunged, w.wantIsExpunged) - } - return nil - } - tests := []test{ - // TODO test cases - /* - { - name: "test_case_1", - fields: fields { - p: nil, - }, - want: want{}, - checkFunc: defaultCheckFunc, - }, - */ - - // TODO test cases - /* - func() test { - return test { - name: "test_case_2", - fields: fields { - p: nil, - }, - want: want{}, - checkFunc: defaultCheckFunc, - } - }(), - */ - } - - for _, tc := range tests { - test := tc - t.Run(test.name, func(tt *testing.T) { - tt.Parallel() - defer goleak.VerifyNone(tt, goleak.IgnoreCurrent()) - if test.beforeFunc != nil { - test.beforeFunc() - } - if test.afterFunc != nil { - defer test.afterFunc() - } - checkFunc := test.checkFunc - if test.checkFunc == nil { - checkFunc = defaultCheckFunc - } - e := &entryUdim{ - p: test.fields.p, - } - - gotIsExpunged := e.tryExpungeLocked() - if err := checkFunc(test.want, gotIsExpunged); err != nil { - tt.Errorf("error = %v", err) - } - }) - } -} diff --git a/versions/NGT_VERSION b/versions/NGT_VERSION index 9be7846722..815e68dd20 100644 --- a/versions/NGT_VERSION +++ b/versions/NGT_VERSION @@ -1 +1 @@ -1.14.8 +2.0.8