mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-05 05:18:52 +08:00
5de89422ed
Signed-off-by: neza2017 <yefu.chen@zilliz.com>
40 lines
993 B
Go
40 lines
993 B
Go
package masterservice
|
|
|
|
import (
|
|
"github.com/zilliztech/milvus-distributed/internal/errors"
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/commonpb"
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/etcdpb"
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/schemapb"
|
|
"github.com/zilliztech/milvus-distributed/internal/util/typeutil"
|
|
)
|
|
|
|
//return
|
|
func EqualKeyPairArray(p1 []*commonpb.KeyValuePair, p2 []*commonpb.KeyValuePair) bool {
|
|
if len(p1) != len(p2) {
|
|
return false
|
|
}
|
|
m1 := make(map[string]string)
|
|
for _, p := range p1 {
|
|
m1[p.Key] = p.Value
|
|
}
|
|
for _, p := range p2 {
|
|
val, ok := m1[p.Key]
|
|
if !ok {
|
|
return false
|
|
}
|
|
if val != p.Value {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
|
|
func GetFieldSchemaByID(coll *etcdpb.CollectionInfo, fieldID typeutil.UniqueID) (*schemapb.FieldSchema, error) {
|
|
for _, f := range coll.Schema.Fields {
|
|
if f.FieldID == fieldID {
|
|
return f, nil
|
|
}
|
|
}
|
|
return nil, errors.Errorf("field id = %d not found", fieldID)
|
|
}
|