Skip to content

Commit

Permalink
Merge pull request #34 from fishpenguin/master-add-test
Browse files Browse the repository at this point in the history
Remove SearchByID
  • Loading branch information
fishpenguin authored May 14, 2020
2 parents bf2ebbd + 81eebe9 commit 464bb76
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 60 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

### Task
---
- \#33 - Remove SearchByID

## milvus-sdk-go 0.3.0 (2020-04-15)

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Go SDK for [Milvus](https://github.com/milvus-io/milvus). To contribute code to
| 0.7.0 | 0.1.0|
| 0.7.1 | 0.2.0|
| 0.8.0 | 0.3.0|
| 0.9.0 | 0.4.0|

### Getting started

Expand Down
31 changes: 0 additions & 31 deletions milvus/ClientProxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,37 +230,6 @@ func (client *Milvusclient) Search(searchParam SearchParam) (TopkQueryResult, St

////////////////////////////////////////////////////////////////////////////

func (client *Milvusclient) SearchByID(searchByIDParam SearchByIDParam) (TopkQueryResult, Status, error) {
keyValuePair := make([]*pb.KeyValuePair, 1)
pair := pb.KeyValuePair{"params", searchByIDParam.ExtraParams, struct{}{}, nil, 0}
keyValuePair[0] = &pair
grpcSearchByIDParam := pb.SearchByIDParam{searchByIDParam.CollectionName, searchByIDParam.PartitionTag, searchByIDParam.IdArray, searchByIDParam.Topk,
keyValuePair, struct{}{}, nil, 0,}

topkQueryResult, err := client.Instance.SearchByID(grpcSearchByIDParam)
if err != nil {
return TopkQueryResult{nil}, nil, err
}
nq := topkQueryResult.GetRowNum()
if nq == 0 {
return TopkQueryResult{nil}, status{int64(topkQueryResult.Status.ErrorCode), topkQueryResult.Status.Reason,}, err
}
var result = make([]QueryResult, nq)
topk := int64(len(topkQueryResult.GetIds())) / nq
var i, j int64
for i = 0; i < nq; i++ {
result[i].Ids = make([]int64, topk)
result[i].Distances = make([]float32, topk)
for j = 0; j < topk; j++ {
result[i].Ids[j] = topkQueryResult.GetIds()[i*topk+j]
result[i].Distances[j] = topkQueryResult.GetDistances()[i*topk+j]
}
}
return TopkQueryResult{result}, status{int64(topkQueryResult.Status.ErrorCode), topkQueryResult.Status.Reason}, nil
}

////////////////////////////////////////////////////////////////////////////

func (client *Milvusclient) DeleteEntityByID(collectionName string, id_array []int64) (Status, error) {
grpcParam := pb.DeleteByIDParam{collectionName, id_array, struct{}{}, nil, 0}
grpcStatus, err := client.Instance.DeleteByID(grpcParam)
Expand Down
18 changes: 0 additions & 18 deletions milvus/MilvusClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,19 +187,6 @@ type SearchParam struct {
ExtraParams string
}

type SearchByIDParam struct {
// CollectionName collection name for search
CollectionName string
// QueryEntities query entities raw array
IdArray []int64
// Topk topk
Topk int64
// PartitionTag partition tag array
PartitionTag []string
// ExtraParams extra parameters
ExtraParams string
}

//QueryResult Query result
type QueryResult struct {
// Ids id array
Expand Down Expand Up @@ -291,11 +278,6 @@ type MilvusClient interface {
// return indicate if query is successful.
Search(searchParam SearchParam) (TopkQueryResult, Status, error)

// SearchByID method
// This method is used to query entity in collection.
// return indicate if query is successful.
SearchByID(searchByIDParam SearchByIDParam) (TopkQueryResult, Status, error)

// DeleteEntityByID method
// This method is used to delete entities by ids
// return indicate if delete is successful
Expand Down
11 changes: 0 additions & 11 deletions milvus/MilvusGrpcClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ type MilvusGrpcClient interface {

Search(searchParam pb.SearchParam) (*pb.TopKQueryResult, error)

SearchByID(searchByIDParam pb.SearchByIDParam) (*pb.TopKQueryResult, error)

SearchInFiles(searchInFilesParam pb.SearchInFilesParam) (*pb.TopKQueryResult, error)

Cmd(command pb.Command) (pb.StringReply, error)
Expand Down Expand Up @@ -255,15 +253,6 @@ func (grpcClient *milvusGrpcClient) Search(searchParam pb.SearchParam) (*pb.TopK
return topkQueryResult, err
}

func (grpcClient *milvusGrpcClient) SearchByID(searchByIDParam pb.SearchByIDParam) (*pb.TopKQueryResult, error) {
ctx := context.Background()
topkQueryResult, err := grpcClient.serviceInstance.SearchByID(ctx, &searchByIDParam)
if err != nil {
return &pb.TopKQueryResult{nil, 0, nil, nil, struct{}{}, nil, 0}, err
}
return topkQueryResult, err
}

func (grpcClient *milvusGrpcClient) SearchInFiles(searchInFilesParam pb.SearchInFilesParam) (*pb.TopKQueryResult, error) {
ctx := context.Background()
topkQueryResult, err := grpcClient.serviceInstance.SearchInFiles(ctx, &searchInFilesParam)
Expand Down

0 comments on commit 464bb76

Please sign in to comment.