funcutil

package
v0.0.0-...-572c485 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Licensed to the LF AI & Data foundation under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	// PulsarMaxMessageSizeKey is the key of config item
	PulsarMaxMessageSizeKey = "maxMessageSize"
)

Variables

This section is empty.

Functions

func CheckCtxValid

func CheckCtxValid(ctx context.Context) bool

CheckCtxValid check if the context is valid

func CheckGrpcReady

func CheckGrpcReady(ctx context.Context, targetCh chan error)

CheckGrpcReady wait for context timeout, or wait 100ms then send nil to targetCh

func CheckPortAvailable

func CheckPortAvailable(port int) bool

CheckPortAvailable check if a port is available to be listened on

func CombineObjectName

func CombineObjectName(dbName string, objectName string) string

func ConvertChannelName

func ConvertChannelName(chanName string, tokenFrom string, tokenTo string) (string, error)

ConvertChannelName assembles channel name according to parameters.

func ConvertToKeyValuePairPointer

func ConvertToKeyValuePairPointer(datas []commonpb.KeyValuePair) []*commonpb.KeyValuePair

func DecodeUserRoleCache

func DecodeUserRoleCache(cache string) (string, string, error)

func EncodeUserRoleCache

func EncodeUserRoleCache(user string, role string) string

func FieldDataToPlaceholderGroupBytes

func FieldDataToPlaceholderGroupBytes(fieldData *schemapb.FieldData) ([]byte, error)

func GenChannelSubName

func GenChannelSubName(prefix string, collectionID int64, nodeID int64) string

GenChannelSubName generate subName to watch channel

func GenRandomBytes

func GenRandomBytes() []byte

GenRandomBytes generates a random bytes.

func GenRandomBytesWithLength

func GenRandomBytesWithLength(length int64) []byte

func GenRandomStr

func GenRandomStr() string

GenRandomStr generates a random string.

func GetAttrByKeyFromRepeatedKV

func GetAttrByKeyFromRepeatedKV(key string, kvs []*commonpb.KeyValuePair) (string, error)

GetAttrByKeyFromRepeatedKV return the value corresponding to key in kv pair

func GetAvailablePort

func GetAvailablePort() int

GetAvailablePort return an available port that can be listened on

func GetCollectionIDFromVChannel

func GetCollectionIDFromVChannel(vChannelName string) int64

func GetFunctionName

func GetFunctionName(i interface{}) string

GetFunctionName returns the name of input

func GetIP

func GetIP(ip string) string

GetIP return the ip address

func GetLocalIP

func GetLocalIP() string

GetLocalIP return the local ip address

func GetNumRowOfFieldData

func GetNumRowOfFieldData(fieldData *schemapb.FieldData) (uint64, error)

GetNumRowOfFieldData returns num of rows from the field data type

func GetNumRowOfFieldDataWithSchema

func GetNumRowOfFieldDataWithSchema(fieldData *schemapb.FieldData, helper *typeutil.SchemaHelper) (uint64, error)

GetNumRowOfFieldDataWithSchema returns num of rows with schema specification.

func GetNumRowsOfBFloat16VectorField

func GetNumRowsOfBFloat16VectorField(bf16Datas []byte, dim int64) (uint64, error)

func GetNumRowsOfBinaryVectorField

func GetNumRowsOfBinaryVectorField(bDatas []byte, dim int64) (uint64, error)

func GetNumRowsOfFloat16VectorField

func GetNumRowsOfFloat16VectorField(f16Datas []byte, dim int64) (uint64, error)

func GetNumRowsOfFloatVectorField

func GetNumRowsOfFloatVectorField(fDatas []float32, dim int64) (uint64, error)

func GetObjectName

func GetObjectName(m interface{}, index int32) string

GetObjectName get object name from the grpc message according to the field index. The field is a string.

func GetObjectNames

func GetObjectNames(m interface{}, index int32) []string

GetObjectNames get object names from the grpc message according to the field index. The field is an array.

func GetPrivilegeExtObj

func GetPrivilegeExtObj(m interface{}) (commonpb.PrivilegeExt, error)

func GetValidLocalIP

func GetValidLocalIP(addrs []net.Addr) string

GetValidLocalIP return the first valid local ip address

func GetVecFieldIDs

func GetVecFieldIDs(schema *schemapb.CollectionSchema) []int64

func GetVersion

func GetVersion(m interface{}) (string, error)

func GetVirtualChannel

func GetVirtualChannel(pchannel string, collectionID int64, idx int) string

func HandleTenantForEtcdKey

func HandleTenantForEtcdKey(prefix string, tenant string, key string) string

func IsEmptyString

func IsEmptyString(str string) bool

func IsGrant

func IsGrant(operateType milvuspb.OperatePrivilegeType) bool

func IsGrpcErr

func IsGrpcErr(err error, targets ...codes.Code) bool

IsGrpcErr checks whether err is instance of grpc status error.

func IsPhysicalChannel

func IsPhysicalChannel(channel string) bool

IsPhysicalChannel checks if the channel is a physical channel

func IsRevoke

func IsRevoke(operateType milvuspb.OperatePrivilegeType) bool

func JSONToMap

func JSONToMap(mStr string) (map[string]string, error)

JSONToMap parse the jsonic index parameters to map

func JSONToRoleDetails

func JSONToRoleDetails(mStr string) (map[string](map[string]([](map[string]string))), error)

func KeyValuePair2Map

func KeyValuePair2Map(datas []*commonpb.KeyValuePair) map[string]string

func Map2KeyValuePair

func Map2KeyValuePair(datas map[string]string) []*commonpb.KeyValuePair

func MapReduce

func MapReduce(results []map[string]string, method map[string]func(string) error) error

func MapToJSON

func MapToJSON(m map[string]string) []byte

func Max

func Max[T constraints.Ordered](first T, values ...T) T

func Min

func Min[T constraints.Ordered](first T, values ...T) T

func PolicyForPrivilege

func PolicyForPrivilege(roleName string, objectType string, objectName string, privilege string, dbName string) string

func PolicyForResource

func PolicyForResource(dbName string, objectType string, objectName string) string

func ProcessFuncParallel

func ProcessFuncParallel(total, maxParallel int, f ProcessFunc, fname string) error

ProcessFuncParallel processes function in parallel.

ProcessFuncParallel waits for all goroutines done if no errors occur. If some goroutines return error, ProcessFuncParallel cancels other goroutines as soon as possible and wait for all other goroutines done, and returns the first error occurs. Reference: https://stackoverflow.com/questions/40809504/idiomatic-goroutine-termination-and-error-handling

func ProcessTaskParallel

func ProcessTaskParallel(maxParallel int, fname string, tasks ...TaskFunc) error

ProcessTaskParallel processes tasks in parallel. Similar to ProcessFuncParallel

func RandomBytes

func RandomBytes(n int) []byte

RandomBytes returns a batch of random string

func RandomString

func RandomString(n int) string

RandomString returns a batch of random string

func ReadBinary

func ReadBinary(endian binary.ByteOrder, bs []byte, receiver interface{}) error

ReadBinary read byte slice as receiver.

func RoleDetailsToJSON

func RoleDetailsToJSON(m map[string](map[string]([](map[string]string)))) []byte

func SetContain

func SetContain(m1, m2 map[interface{}]struct{}) bool

SetContain returns true if set m1 contains set m2

func SetToSlice

func SetToSlice(m map[interface{}]struct{}) []interface{}

SetToSlice transform the set to a slice.

func SliceContain

func SliceContain[T comparable](s []T, item T) bool

SliceContain returns true if slice s contains item.

func SliceSetEqual

func SliceSetEqual[T comparable](s1, s2 []T) bool

SliceSetEqual is used to compare two Slice

func SortedSliceEqual

func SortedSliceEqual(s1, s2 interface{}) bool

SortedSliceEqual is used to compare two Sorted Slice

func SplitObjectName

func SplitObjectName(objectName string) (string, string)

func ToPhysicalChannel

func ToPhysicalChannel(vchannel string) string

ToPhysicalChannel get physical channel name from virtual channel name

Types

type DataProcessFunc

type DataProcessFunc func(data interface{}) error

type ProcessFunc

type ProcessFunc func(idx int) error

type TaskFunc

type TaskFunc func() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL