mirror of https://github.com/milvus-io/milvus.git
parent
c019e80dbb
commit
1f2f76789e
|
@ -50,7 +50,7 @@ func (kv *MemoryKV) Load(key string) (string, error) {
|
|||
return item.(memoryKVItem).value, nil
|
||||
}
|
||||
|
||||
func (kv *MemoryKV) LoadWithDefault(key string, defaultValue string) (string, error) {
|
||||
func (kv *MemoryKV) LoadWithDefault(key, defaultValue string) (string, error) {
|
||||
kv.RLock()
|
||||
defer kv.RUnlock()
|
||||
item := kv.tree.Get(memoryKVItem{key, ""})
|
||||
|
|
|
@ -92,7 +92,7 @@ func CalcFFBatch(dim int64, left []float32, lIndex int64, right []float32, metri
|
|||
}
|
||||
}
|
||||
|
||||
func CalcFloatDistance(dim int64, left []float32, right []float32, metric string) ([]float32, error) {
|
||||
func CalcFloatDistance(dim int64, left, right []float32, metric string) ([]float32, error) {
|
||||
if dim <= 0 {
|
||||
err := errors.New("Invalid dimension")
|
||||
return nil, err
|
||||
|
|
|
@ -47,7 +47,7 @@ func TestValidateFloatArrayLength(t *testing.T) {
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
func CreateFloatArray(n int64, dim int64) []float32 {
|
||||
func CreateFloatArray(n, dim int64) []float32 {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
num := n * dim
|
||||
array := make([]float32, num)
|
||||
|
@ -58,7 +58,7 @@ func CreateFloatArray(n int64, dim int64) []float32 {
|
|||
return array
|
||||
}
|
||||
|
||||
func DistanceL2(left []float32, right []float32) float32 {
|
||||
func DistanceL2(left, right []float32) float32 {
|
||||
if len(left) != len(right) {
|
||||
panic("array dimension not equal")
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ func DistanceL2(left []float32, right []float32) float32 {
|
|||
return sum
|
||||
}
|
||||
|
||||
func DistanceIP(left []float32, right []float32) float32 {
|
||||
func DistanceIP(left, right []float32) float32 {
|
||||
if len(left) != len(right) {
|
||||
panic("array dimension not equal")
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ func Test_CalcFloatDistance(t *testing.T) {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
func CreateBinaryArray(n int64, dim int64) []byte {
|
||||
func CreateBinaryArray(n, dim int64) []byte {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
num := n * dim / 8
|
||||
if num*8 < n*dim {
|
||||
|
|
|
@ -14,7 +14,7 @@ package funcutil
|
|||
import "reflect"
|
||||
|
||||
// SliceContain returns true if slice s contains item.
|
||||
func SliceContain(s interface{}, item interface{}) bool {
|
||||
func SliceContain(s, item interface{}) bool {
|
||||
ss := reflect.ValueOf(s)
|
||||
if ss.Kind() != reflect.Slice {
|
||||
panic("SliceContain expect a slice")
|
||||
|
@ -30,7 +30,7 @@ func SliceContain(s interface{}, item interface{}) bool {
|
|||
}
|
||||
|
||||
// SliceSetEqual is used to compare two Slice
|
||||
func SliceSetEqual(s1 interface{}, s2 interface{}) bool {
|
||||
func SliceSetEqual(s1, s2 interface{}) bool {
|
||||
ss1 := reflect.ValueOf(s1)
|
||||
ss2 := reflect.ValueOf(s2)
|
||||
if ss1.Kind() != reflect.Slice {
|
||||
|
@ -51,7 +51,7 @@ func SliceSetEqual(s1 interface{}, s2 interface{}) bool {
|
|||
}
|
||||
|
||||
// SortedSliceEqual is used to compare two Sorted Slice
|
||||
func SortedSliceEqual(s1 interface{}, s2 interface{}) bool {
|
||||
func SortedSliceEqual(s1, s2 interface{}) bool {
|
||||
ss1 := reflect.ValueOf(s1)
|
||||
ss2 := reflect.ValueOf(s2)
|
||||
if ss1.Kind() != reflect.Slice {
|
||||
|
|
|
@ -177,7 +177,7 @@ func InfoFromSpan(span opentracing.Span) (traceID string, sampled bool, found bo
|
|||
}
|
||||
|
||||
// InfoFromContext is a method return details of span associated with context.
|
||||
func InfoFromContext(ctx context.Context) (traceID string, sampled bool, found bool) {
|
||||
func InfoFromContext(ctx context.Context) (traceID string, sampled, found bool) {
|
||||
if ctx != nil {
|
||||
if span := opentracing.SpanFromContext(ctx); span != nil {
|
||||
return InfoFromSpan(span)
|
||||
|
|
Loading…
Reference in New Issue