Repository: milvus-io/milvus-sdk-go
Pull request #569 (2023-08-30 03:37:27)

Remove a outdated comment
/kind improvement

sre-ci-robot: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by: *<a href="https://github.com/milvus-io/milvus-sdk-go/pull/569#" title="Author self-approved">wayblink</a>*
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please assign **yah01** after the PR has been reviewed.
You can assign the PR to them by writing `/assign @yah01` in a comment when ready.

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=milvus-io%2Fmilvus-sdk-go).

<details open>
Needs approval from an approver in each of these files:

- **[OWNERS](https://github.com/milvus-io/milvus-sdk-go/blob/master/OWNERS)**

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":["yah01"]} -->

Patch:
diff --git a/client/client.go b/client/client.go
index eb1403b..5f3cd73 100644
--- a/client/client.go
+++ b/client/client.go
@@ -125,6 +125,9 @@ type Client interface {
 	Insert(ctx context.Context, collName string, partitionName string, columns ...entity.Column) (entity.Column, error)
 	// Flush flush collection, specified
 	Flush(ctx context.Context, collName string, async bool) error
+	// FlushV2 flush collection, specified, return newly sealed segmentIds, all flushed segmentIds of the collection, seal time and error
+	// currently it is only used in milvus-backup(https://github.com/zilliztech/milvus-backup)
+	FlushV2(ctx context.Context, collName string, async bool) ([]int64, []int64, int64, error)
 	// DeleteByPks deletes entries related to provided primary keys
 	DeleteByPks(ctx context.Context, collName string, partitionName string, ids entity.Column) error
 	// Upsert column-based data of collection, returns id column values
diff --git a/client/index.go b/client/index.go
index a38c86e..6f725aa 100644
--- a/client/index.go
+++ b/client/index.go
@@ -136,7 +136,6 @@ func (c *GrpcClient) CreateIndex(ctx context.Context, collName string, fieldName
 }
 
 // DescribeIndex describe index
-// Deprecate please use DescribeIndexV2 instead.
 func (c *GrpcClient) DescribeIndex(ctx context.Context, collName string, fieldName string, opts ...IndexOption) ([]entity.Index, error) {
 	if c.Service == nil {
 		return []entity.Index{}, ErrClientNotReady
@@ -190,7 +189,6 @@ func (c *GrpcClient) DropIndex(ctx context.Context, collName string, fieldName s
 }
 
 // GetIndexState get index state
-// Deprecate please use DescribeIndexV2 instead.
 func (c *GrpcClient) GetIndexState(ctx context.Context, collName string, fieldName string, opts ...IndexOption) (entity.IndexState, error) {
 	if c.Service == nil {
 		return entity.IndexState(commonpb.IndexState_Failed), ErrClientNotReady
@@ -218,7 +216,6 @@ func (c *GrpcClient) GetIndexState(ctx context.Context, collName string, fieldNa
 }
 
 // GetIndexBuildProgress get index building progress
-// Deprecate please use DescribeIndexV2 instead.
 func (c *GrpcClient) GetIndexBuildProgress(ctx context.Context, collName string, fieldName string, opts ...IndexOption) (total, indexed int64, err error) {
 	if c.Service == nil {
 		return 0, 0, ErrClientNotReady
diff --git a/client/insert.go b/client/insert.go
index 2a1f20e..24fb682 100644
--- a/client/insert.go
+++ b/client/insert.go
@@ -191,11 +191,18 @@ func (c *GrpcClient) mergeDynamicColumns(dynamicName string, rowSize int, column
 // Flush force collection to flush memory records into storage
 // in sync mode, flush will wait all segments to be flushed
 func (c *GrpcClient) Flush(ctx context.Context, collName string, async bool) error {
+	_, _, _, err := c.FlushV2(ctx, collName, async)
+	return err
+}
+
+// Flush force collection to flush memory records into storage
+// in sync mode, flush will wait all segments to be flushed
+func (c *GrpcClient) FlushV2(ctx context.Context, collName string, async bool) ([]int64, []int64, int64, error) {
 	if c.Service == nil {
-		return ErrClientNotReady
+		return nil, nil, 0, ErrClientNotReady
 	}
 	if err := c.checkCollectionExists(ctx, collName); err != nil {
-		return err
+		return nil, nil, 0, err
 	}
 	req := &milvuspb.FlushRequest{
 		DbName:          "", // reserved,
@@ -203,10 +210,10 @@ func (c *GrpcClient) Flush(ctx context.Context, collName string, async bool) err
 	}
 	resp, err := c.Service.Flush(ctx, req)
 	if err != nil {
-		return err
+		return nil, nil, 0, err
 	}
 	if err := handleRespStatus(resp.GetStatus()); err != nil {
-		return err
+		return nil, nil, 0, err
 	}
 	if !async {
 		segmentIDs, has := resp.GetCollSegIDs()[collName]
@@ -226,14 +233,14 @@ func (c *GrpcClient) Flush(ctx context.Context, collName string, async bool) err
 				// respect context deadline/cancel
 				select {
 				case <-ctx.Done():
-					return errors.New("deadline exceeded")
+					return nil, nil, 0, errors.New("deadline exceeded")
 				default:
 				}
 				time.Sleep(200 * time.Millisecond)
 			}
 		}
 	}
-	return nil
+	return resp.GetCollSegIDs()[collName].GetData(), resp.GetFlushCollSegIDs()[collName].GetData(), resp.GetCollSealTimes()[collName], nil
 }
 
 // DeleteByPks deletes entries related to provided primary keys
diff --git a/client/options.go b/client/options.go
index f4e5b9b..14875c3 100644
--- a/client/options.go
+++ b/client/options.go
@@ -235,6 +235,15 @@ func WithEndTs(endTs int64) BulkInsertOption {
 	}
 }
 
+// IsBackup specifies it is triggered by backup tool
+func IsBackup() BulkInsertOption {
+	return func(req *milvuspb.ImportRequest) {
+		optionMap := entity.KvPairsMap(req.GetOptions())
+		optionMap["backup"] = "true"
+		req.Options = entity.MapKvPairs(optionMap)
+	}
+}
+
 type getOption struct {
 	partitionNames []string
 	outputFields   []string


Test patch:
diff --git a/test/testcases/index_test.go b/test/testcases/index_test.go
index 91079ca..f13e71d 100644
--- a/test/testcases/index_test.go
+++ b/test/testcases/index_test.go
@@ -176,8 +176,6 @@ func TestCreateBinaryIndexNotSupportedMetricsType(t *testing.T) {
 
 	// create BinIvfFlat, BinFlat index with not supported metric type
 	invalidMetricTypes := []entity.MetricType{
-		entity.SUBSTRUCTURE,
-		entity.SUPERSTRUCTURE,
 		entity.L2,
 		entity.TANIMOTO,
 	}
@@ -185,12 +183,12 @@ func TestCreateBinaryIndexNotSupportedMetricsType(t *testing.T) {
 		// create BinFlat
 		idxBinFlat, _ := entity.NewIndexBinFlat(metricType, 128)
 		err := mc.CreateIndex(ctx, collName, common.DefaultBinaryVecFieldName, idxBinFlat, false, client.WithIndexName("my_index"))
-		common.CheckErr(t, err, false, "supported: [HAMMING JACCARD]")
+		common.CheckErr(t, err, false, "supported: [HAMMING JACCARD SUBSTRUCTURE SUPERSTRUCTURE]")
 
 		// create BinIvfFlat index
 		idxBinIvfFlat, _ := entity.NewIndexBinIvfFlat(metricType, 128)
 		errIvf := mc.CreateIndex(ctx, collName, common.DefaultBinaryVecFieldName, idxBinIvfFlat, false, client.WithIndexName("my_index2"))
-		common.CheckErr(t, errIvf, false, "supported: [HAMMING JACCARD]")
+		common.CheckErr(t, errIvf, false, "supported: [HAMMING JACCARD SUBSTRUCTURE SUPERSTRUCTURE]")
 	}
 
 }
diff --git a/test/testcases/search_test.go b/test/testcases/search_test.go
index e007e91..452e880 100644
--- a/test/testcases/search_test.go
+++ b/test/testcases/search_test.go
@@ -66,7 +66,7 @@ func TestSearchCollectionNotExist(t *testing.T) {
 		common.DefaultTopK,
 		sp,
 	)
-	common.CheckErr(t, errSearch, false, "can't find collection: collName")
+	common.CheckErr(t, errSearch, false, "collection not found")
 }
 
 // test search empty collection -> return empty
@@ -561,11 +561,11 @@ func TestSearchInvalidVectors(t *testing.T) {
 		{vectors: common.GenSearchVectors(common.DefaultNq, 64, entity.FieldTypeFloatVector), errMsg: "vector dimension mismatch"},
 
 		// vector type not match
-		{vectors: common.GenSearchVectors(common.DefaultNq, common.DefaultDim, entity.FieldTypeBinaryVector), errMsg: "fail to search on all shard leaders"},
+		{vectors: common.GenSearchVectors(common.DefaultNq, common.DefaultDim, entity.FieldTypeBinaryVector), errMsg: "failed to search"},
 
 		// empty vectors
 		{vectors: []entity.Vector{}, errMsg: "nq [0] is invalid"},
-		{vectors: []entity.Vector{entity.FloatVector{}}, errMsg: "fail to search on all shard leaders"},
+		{vectors: []entity.Vector{entity.FloatVector{}}, errMsg: "failed to search"},
 	}
 
 	sp, _ := entity.NewIndexHNSWSearchParam(74)