From da1745fb1d9a9478ce5cf71f0a595dfafdf8b60a Mon Sep 17 00:00:00 2001 From: yukun Date: Thu, 29 Apr 2021 16:44:28 +0800 Subject: [PATCH] Fix grpc version (#101) Signed-off-by: fishpenguin --- examples/MilvusClientExample.go | 5 +++-- go.mod | 3 ++- go.sum | 2 ++ milvus/ClientProxy.go | 3 ++- milvus/MilvusClient.go | 2 +- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/examples/MilvusClientExample.go b/examples/MilvusClientExample.go index 7c3c9086..2c834834 100644 --- a/examples/MilvusClientExample.go +++ b/examples/MilvusClientExample.go @@ -22,6 +22,7 @@ package main import ( "context" "log" + "math/rand" "strconv" "time" @@ -31,7 +32,7 @@ import ( var collectionName string = "test_go2" var dimension int64 = 128 var indexFileSize int64 = 1024 -var metricType int64 = int64(milvus.L2) +var metricType int32 = int32(milvus.L2) var nq int64 = 100 var nprobe int64 = 64 var nb int64 = 100000 @@ -164,7 +165,7 @@ func example(address string, port string) { for i = 0; i < nq; i++ { queryVectors[i] = make([]float32, dimension) for j = 0; j < dimension; j++ { - queryVectors[i][j] = float32(i % (j + 1)) + queryVectors[i][j] = float32(rand.Float64()) } queryRecords[i].FloatData = queryVectors[i] } diff --git a/go.mod b/go.mod index b54e582a..9e5117ab 100644 --- a/go.mod +++ b/go.mod @@ -4,5 +4,6 @@ go 1.12 require ( github.com/golang/protobuf v1.5.2 - google.golang.org/grpc v1.26.0 + google.golang.org/grpc v1.27.0 + google.golang.org/protobuf v1.26.0 ) diff --git a/go.sum b/go.sum index a0743bfa..8b643cfc 100644 --- a/go.sum +++ b/go.sum @@ -50,6 +50,8 @@ google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZi google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.26.0 h1:2dTRdpdFEEhJYQD8EMLB61nnrzSCTbG38PhqdhvOltg= google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.0 h1:rRYRFMVgRv6E0D70Skyfsr28tDXIuuPZyWGMPdMcnXg= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= diff --git a/milvus/ClientProxy.go b/milvus/ClientProxy.go index 0020758d..6bc213c8 100644 --- a/milvus/ClientProxy.go +++ b/milvus/ClientProxy.go @@ -98,6 +98,7 @@ func (client *Milvusclient) CreateCollection(ctx context.Context, collectionPara CollectionName: collectionParam.CollectionName, Dimension: collectionParam.Dimension, IndexFileSize: collectionParam.IndexFileSize, + MetricType: collectionParam.MetricType, } grpcStatus, err := client.Instance.CreateCollection(ctx, grpcCollectionSchema) if err != nil { @@ -293,7 +294,7 @@ func (client *Milvusclient) GetCollectionInfo(ctx context.Context, collectionNam if err != nil { return CollectionParam{"", 0, 0, 0}, nil, err } - return CollectionParam{collectionSchema.GetCollectionName(), collectionSchema.GetDimension(), collectionSchema.GetIndexFileSize(), int64(collectionSchema.GetMetricType())}, + return CollectionParam{collectionSchema.GetCollectionName(), collectionSchema.GetDimension(), collectionSchema.GetIndexFileSize(), collectionSchema.GetMetricType()}, status{int64(collectionSchema.GetStatus().GetErrorCode()), collectionSchema.Status.Reason}, err } diff --git a/milvus/MilvusClient.go b/milvus/MilvusClient.go index eed1a6c9..344a90fb 100644 --- a/milvus/MilvusClient.go +++ b/milvus/MilvusClient.go @@ -113,7 +113,7 @@ type CollectionParam struct { // IndexFileSize Index file size, must be a positive value IndexFileSize int64 // MetricType Index metric type - MetricType int64 + MetricType int32 } // IndexParam index parameters