Skip to content

Commit

Permalink
Refine code
Browse files Browse the repository at this point in the history
Signed-off-by: Cai Zhang <[email protected]>
  • Loading branch information
xiaocai2333 committed Feb 5, 2024
1 parent 5f0e9f6 commit c9ab2cc
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions states/etcd/repair/add_index_param_retrive_friendly.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/spf13/cobra"

"github.com/golang/protobuf/proto"
commonpbv2 "github.com/milvus-io/birdwatcher/proto/v2.2/commonpb"
indexpbv2 "github.com/milvus-io/birdwatcher/proto/v2.2/indexpb"
clientv3 "go.etcd.io/etcd/client/v3"
Expand All @@ -15,7 +16,7 @@ func AddIndexParamsCommand(cli clientv3.KV, basePath string) *cobra.Command {
cmd := &cobra.Command{
Use: "add_index_params_retrieve_friendly",
Aliases: []string{"add_index_params_retrieve_friendly"},
Short: "check index parma and try to add retrieve_friendly",
Short: "check index param and try to add retrieve_friendly",
Run: func(cmd *cobra.Command, args []string) {
collID, err := cmd.Flags().GetInt64("collection")
if err != nil {
Expand Down Expand Up @@ -47,24 +48,7 @@ func AddIndexParamsCommand(cli clientv3.KV, basePath string) *cobra.Command {
if collID != 0 && index.IndexInfo.CollectionID != collID {
continue
}
newIndex := &indexpbv2.FieldIndex{
IndexInfo: &indexpbv2.IndexInfo{
CollectionID: index.GetIndexInfo().GetCollectionID(),
FieldID: index.GetIndexInfo().GetFieldID(),
IndexName: index.GetIndexInfo().GetIndexName(),
IndexID: index.GetIndexInfo().GetIndexID(),
TypeParams: index.GetIndexInfo().GetTypeParams(),
IndexParams: index.GetIndexInfo().GetIndexParams(),
IndexedRows: index.GetIndexInfo().GetIndexedRows(),
TotalRows: index.GetIndexInfo().GetTotalRows(),
State: index.GetIndexInfo().GetState(),
IndexStateFailReason: index.GetIndexInfo().GetIndexStateFailReason(),
IsAutoIndex: index.GetIndexInfo().GetIsAutoIndex(),
UserIndexParams: index.GetIndexInfo().GetUserIndexParams(),
},
Deleted: index.GetDeleted(),
CreateTime: index.GetCreateTime(),
}
newIndex := proto.Clone(&index).(*indexpbv2.FieldIndex)

Check failure on line 51 in states/etcd/repair/add_index_param_retrive_friendly.go

View workflow job for this annotation

GitHub Actions / lint

G601: Implicit memory aliasing in for loop. (gosec)
indexType := ""
for _, pair := range index.IndexInfo.IndexParams {
if pair.Key == "index_type" {
Expand Down

0 comments on commit c9ab2cc

Please sign in to comment.