milvus-io--milvus
498b235461
Build and test / Build and test AMD64 Ubuntu 22.04 (push) Failing after 0s
Publish Builder / amazonlinux2023 (push) Failing after 1s
Build and test / UT for Go (push) Has been skipped
Publish KRTE Images / KRTE (push) Failing after 1s
Build and test / Integration Test (push) Has been skipped
Build and test / Upload Code Coverage (push) Has been skipped
Publish Builder / rockylinux9 (push) Failing after 1s
Publish Builder / ubuntu22.04 (push) Failing after 0s
Publish Builder / ubuntu24.04 (push) Failing after 0s
Publish Gpu Builder / publish-gpu-builder (push) Failing after 1s
Publish Test Images / PyTest (push) Failing after 0s
Build and test / UT for Cpp (push) Has been cancelled
52 行
1.1 KiB
Go
52 行
1.1 KiB
Go
package common
|
|
|
|
import (
|
|
"reflect"
|
|
|
|
"github.com/milvus-io/milvus-proto/go-api/v3/commonpb"
|
|
)
|
|
|
|
type KeyValuePairs []*commonpb.KeyValuePair
|
|
|
|
func (pairs KeyValuePairs) Clone() KeyValuePairs {
|
|
if pairs == nil {
|
|
return nil
|
|
}
|
|
clone := make(KeyValuePairs, 0, len(pairs))
|
|
for _, pair := range pairs {
|
|
clone = append(clone, &commonpb.KeyValuePair{
|
|
Key: pair.GetKey(),
|
|
Value: pair.GetValue(),
|
|
})
|
|
}
|
|
return clone
|
|
}
|
|
|
|
func (pairs KeyValuePairs) ToMap() map[string]string {
|
|
ret := make(map[string]string)
|
|
for _, pair := range pairs {
|
|
ret[pair.GetKey()] = pair.GetValue()
|
|
}
|
|
return ret
|
|
}
|
|
|
|
func (pairs KeyValuePairs) Equal(other KeyValuePairs) bool {
|
|
return reflect.DeepEqual(pairs.ToMap(), other.ToMap())
|
|
}
|
|
|
|
func CloneKeyValuePairs(pairs KeyValuePairs) KeyValuePairs {
|
|
return pairs.Clone()
|
|
}
|
|
|
|
// NewKeyValuePairs creates a new KeyValuePairs from a map[string]string.
|
|
func NewKeyValuePairs(kvs map[string]string) KeyValuePairs {
|
|
pairs := make(KeyValuePairs, 0, len(kvs))
|
|
for key, value := range kvs {
|
|
pairs = append(pairs, &commonpb.KeyValuePair{
|
|
Key: key,
|
|
Value: value,
|
|
})
|
|
}
|
|
return pairs
|
|
}
|