typeutil

package
v0.0.2-0...-993051b Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: Apache-2.0 Imports: 28 Imported by: 40

Documentation

Index

Constants

View Source
const (
	// EmbeddedRole is for embedded Milvus.
	EmbeddedRole = "embedded"
	// StandaloneRole is a constant represent Standalone
	StandaloneRole = "standalone"
	// RootCoordRole is a constant represent RootCoord
	RootCoordRole = "rootcoord"
	// ProxyRole is a constant represent Proxy
	ProxyRole = "proxy"
	// QueryCoordRole is a constant represent QueryCoord
	QueryCoordRole = "querycoord"
	// QueryNodeRole is a constant represent QueryNode
	QueryNodeRole = "querynode"
	// IndexCoordRole is a constant represent IndexCoord
	IndexCoordRole = "indexcoord"
	// IndexNodeRole is a constant represent IndexNode
	DataCoordRole = "datacoord"
	// DataNodeRole is a constant represent DataNode
	DataNodeRole = "datanode"
	// IndexNodeRole is a constant represent IndexNode
	IndexNodeRole = "indexnode"
	// MixtureRole is a constant represents Mixture running modtoe
	MixtureRole = "mixture"
	// StreamingCoord is a constant represent StreamingCoord
	StreamingCoordRole = "streamingcoord"
	// StreamingNode is a constant represent StreamingNode
	StreamingNodeRole = "streamingnode"
)
View Source
const DynamicFieldMaxLength = 512
View Source
const MaxTimestamp = Timestamp(math.MaxUint64)

MaxTimestamp is the max timestamp.

View Source
const Unlimited int64 = -1

Variables

View Source
var ZeroTime = time.Time{}

ZeroTime is a zero time.

View Source
var ZeroTimestamp = Timestamp(0)

ZeroTimestamp is a zero timestamp

Functions

func AddOne

func AddOne(data string) string

AddOne add one to last byte in string, on empty string return empty it helps with key iteration upper bound

func After

func After(str string, sub string) string

After get substring after sub string.

func AfterN

func AfterN(str string, sub string, sep string) []string

AfterN Split slices After(str) into all substrings separated by sep

func AppendFieldData

func AppendFieldData(dst, src []*schemapb.FieldData, idx int64) (appendSize int64)

AppendFieldData appends fields data of specified index from src to dst

func AppendGroupByValue

func AppendGroupByValue(dstResData *schemapb.SearchResultData,
	groupByVal interface{}, srcDataType schemapb.DataType,
) error

func AppendID

func AppendID(dst *schemapb.IDs, src any)

func AppendIDs

func AppendIDs(dst *schemapb.IDs, src *schemapb.IDs, idx int)

func AppendPKs

func AppendPKs(pks *schemapb.IDs, pk interface{})

func AppendSystemFields

func AppendSystemFields(schema *schemapb.CollectionSchema) *schemapb.CollectionSchema

func BFloat16BytesToFloat32

func BFloat16BytesToFloat32(b []byte) float32

func BFloat16BytesToFloat32Vector

func BFloat16BytesToFloat32Vector(b []byte) []float32

func BigEndianBytesToUint64

func BigEndianBytesToUint64(b []byte) (uint64, error)

BigEndianBytesToUint64 converts a byte slice (big endian) to uint64.

func BytesToFloat32

func BytesToFloat32(bytes []byte) float32

BytesToFloat32 converts a byte slice to float32.

func BytesToInt64

func BytesToInt64(b []byte) (int64, error)

BytesToInt64 converts a byte slice to uint64.

func BytesToUint64

func BytesToUint64(b []byte) (uint64, error)

BytesToUint64 converts a byte slice to uint64.

func CalcColumnSize

func CalcColumnSize(column *schemapb.FieldData) int

func Clone

func Clone[T proto.Message](msg T) T

Generic Clone for proto message

func CompareIndexParams

func CompareIndexParams(indexParam1, indexParam2 []*commonpb.KeyValuePair) bool

CompareIndexParams compares indexParam1 with indexParam2. When all keys of indexParam1 exist in indexParam2, and the corresponding value are the same as in indexParam2, return true Otherwise return false

func ComparePK

func ComparePK(pkA, pkB interface{}) bool

ComparePK returns if i-th PK of dataA > j-th PK of dataB

func ComparePKInSlice

func ComparePKInSlice(data *schemapb.IDs, i, j int) bool

ComparePKInSlice returns if i-th PK < j-th PK

func CopyPk

func CopyPk(dst *schemapb.IDs, src *schemapb.IDs, offset int)

func CreateAndSortSparseFloatRow

func CreateAndSortSparseFloatRow(sparse map[uint32]float32) []byte

func CreateSparseFloatRow

func CreateSparseFloatRow(indices []uint32, values []float32) []byte

func CreateSparseFloatRowFromJSON

func CreateSparseFloatRowFromJSON(input []byte) ([]byte, error)

func CreateSparseFloatRowFromMap

func CreateSparseFloatRowFromMap(input map[string]interface{}) ([]byte, error)

accepted format:

  • {"indices": [1, 2, 3], "values": [0.1, 0.2, 0.3]} # format1
  • {"1": 0.1, "2": 0.2, "3": 0.3} # format2

we don't require the indices to be sorted from user input, but the returned byte representation must have indices sorted

func DeleteFieldData

func DeleteFieldData(dst []*schemapb.FieldData)

DeleteFieldData delete fields data appended last time

func EstimateAvgSizePerRecord

func EstimateAvgSizePerRecord(schema *schemapb.CollectionSchema) (int, error)

func EstimateEntitySize

func EstimateEntitySize(fieldsData []*schemapb.FieldData, rowOffset int) (int, error)

func EstimateMaxSizePerRecord

func EstimateMaxSizePerRecord(schema *schemapb.CollectionSchema) (int, error)

func EstimateSizePerRecord

func EstimateSizePerRecord(schema *schemapb.CollectionSchema) (int, error)

EstimateSizePerRecord returns the estimate size of a record in a collection

func Float16BytesToFloat32

func Float16BytesToFloat32(b []byte) float32

func Float16BytesToFloat32Vector

func Float16BytesToFloat32Vector(b []byte) []float32

func Float32ToBFloat16Bytes

func Float32ToBFloat16Bytes(f float32) []byte

func Float32ToBytes

func Float32ToBytes(float float32) []byte

Float32ToBytes converts a float to byte slice.

func Float32ToFloat16Bytes

func Float32ToFloat16Bytes(f float32) []byte

func GenEmptyFieldData

func GenEmptyFieldData(field *schemapb.FieldSchema) (*schemapb.FieldData, error)

func GetData

func GetData(field *schemapb.FieldData, idx int) interface{}

func GetDim

func GetDim(field *schemapb.FieldSchema) (int64, error)

GetDim get dimension of field. Maybe also helpful outside.

func GetDynamicField

func GetDynamicField(schema *schemapb.CollectionSchema) *schemapb.FieldSchema

GetDynamicField returns the dynamic field if it exists.

func GetField

func GetField(schema *schemapb.CollectionSchema, fieldID int64) *schemapb.FieldSchema

func GetFieldByName

func GetFieldByName(schema *schemapb.CollectionSchema, fieldName string) *schemapb.FieldSchema

func GetId

func GetId(src *schemapb.IDs, idx int) (int, any)

func GetMapKeys

func GetMapKeys(src map[string]string) []string

GetMapKeys return keys of a map

func GetPK

func GetPK(data *schemapb.IDs, idx int64) interface{}

func GetPKSize

func GetPKSize(fieldData *schemapb.FieldData) int

func GetPartitionKeyFieldSchema

func GetPartitionKeyFieldSchema(schema *schemapb.CollectionSchema) (*schemapb.FieldSchema, error)

GetPartitionKeyFieldSchema get partition field schema from collection schema

func GetPrimaryFieldData

func GetPrimaryFieldData(datas []*schemapb.FieldData, primaryFieldSchema *schemapb.FieldSchema) (*schemapb.FieldData, error)

GetPrimaryFieldData get primary field data from all field data inserted from sdk

func GetPrimaryFieldSchema

func GetPrimaryFieldSchema(schema *schemapb.CollectionSchema) (*schemapb.FieldSchema, error)

GetPrimaryFieldSchema get primary field schema from collection schema

func GetSizeOfIDs

func GetSizeOfIDs(data *schemapb.IDs) int

func GetVectorFieldSchema

func GetVectorFieldSchema(schema *schemapb.CollectionSchema) (*schemapb.FieldSchema, error)

GetVectorFieldSchema get vector field schema from collection schema.

func GetVectorFieldSchemas

func GetVectorFieldSchemas(schema *schemapb.CollectionSchema) []*schemapb.FieldSchema

GetVectorFieldSchemas get vector fields schema from collection schema.

func HasClusterKey

func HasClusterKey(schema *schemapb.CollectionSchema) bool

HasClusterKey check if a collection schema has ClusterKey field

func HasPartitionKey

func HasPartitionKey(schema *schemapb.CollectionSchema) bool

HasPartitionKey check if a collection schema has PartitionKey field

func Hash32Bytes

func Hash32Bytes(b []byte) (uint32, error)

Hash32Bytes hashing a byte array to uint32

func Hash32Int64

func Hash32Int64(v int64) (uint32, error)

Hash32Int64 hashing an int64 number to uint32

func Hash32String

func Hash32String(s string) (int64, error)

Hash32String hashing a string to int64

func Hash32Uint64

func Hash32Uint64(v uint64) (uint32, error)

Hash32Uint64 hashing an uint64 nubmer to uint32

func HashKey2Partitions

func HashKey2Partitions(keys *schemapb.FieldData, partitionNames []string) ([]uint32, error)

HashKey2Partitions hash partition keys to partitions

func HashPK2Channels

func HashPK2Channels(primaryKeys *schemapb.IDs, shardNames []string) []uint32

HashPK2Channels hash primary keys to channels

func HashString2Uint32

func HashString2Uint32(v string) uint32

HashString2Uint32 hashing a string to uint32

func Int64ToBytes

func Int64ToBytes(v int64) []byte

Int64ToBytes converts uint64 to a byte slice.

func IsArithmetic

func IsArithmetic(dataType schemapb.DataType) bool

IsArithmetic returns true if input is of arithmetic type, otherwise false.

func IsArrayType

func IsArrayType(dataType schemapb.DataType) bool

func IsAutoPKField

func IsAutoPKField(field *schemapb.FieldSchema) bool

func IsBinaryVectorType

func IsBinaryVectorType(dataType schemapb.DataType) bool

func IsBoolType

func IsBoolType(dataType schemapb.DataType) bool

IsBoolType returns true if input is a bool type, otherwise false

func IsChanClosed

func IsChanClosed(ch <-chan struct{}) bool

IsChanClosed returns whether input signal channel is closed or not. this method accept `chan struct{}` type only in case of passing msg channels by mistake.

func IsDenseFloatVectorType

func IsDenseFloatVectorType(dataType schemapb.DataType) bool

func IsFieldDataTypeSupportMaterializedView

func IsFieldDataTypeSupportMaterializedView(fieldSchema *schemapb.FieldSchema) bool

func IsFixDimVectorType

func IsFixDimVectorType(dataType schemapb.DataType) bool

func IsFloatVectorType

func IsFloatVectorType(dataType schemapb.DataType) bool

func IsFloatingType

func IsFloatingType(dataType schemapb.DataType) bool

IsFloatingType returns true if input is a floating type, otherwise false

func IsIntegerType

func IsIntegerType(dataType schemapb.DataType) bool

IsIntegerType returns true if input is an integer type, otherwise false

func IsJSONType

func IsJSONType(dataType schemapb.DataType) bool

func IsPrimaryFieldDataExist

func IsPrimaryFieldDataExist(datas []*schemapb.FieldData, primaryFieldSchema *schemapb.FieldSchema) bool

func IsPrimaryFieldType

func IsPrimaryFieldType(dataType schemapb.DataType) bool

func IsPrimitiveType

func IsPrimitiveType(dataType schemapb.DataType) bool

func IsSparseFloatVectorType

func IsSparseFloatVectorType(dataType schemapb.DataType) bool

func IsStringType

func IsStringType(dataType schemapb.DataType) bool

IsStringType returns true if input is a varChar type, otherwise false

func IsVariableDataType

func IsVariableDataType(dataType schemapb.DataType) bool

func IsVectorType

func IsVectorType(dataType schemapb.DataType) bool

IsVectorType returns true if input is a vector type, otherwise false

func MapEqual

func MapEqual(left, right map[int64]int64) bool

MapEqual returns true if the two map contain the same keys and values

func MergeFieldData

func MergeFieldData(dst []*schemapb.FieldData, src []*schemapb.FieldData) error

MergeFieldData appends fields data to dst

func MergeMap

func MergeMap(src map[string]string, dst map[string]string) map[string]string

MergeMap merge one map to another

func NewKvPairs

func NewKvPairs(pairs []*commonpb.KeyValuePair) *kvPairsHelper[string, string]

func ParseTimestamp

func ParseTimestamp(data []byte) (time.Time, error)

ParseTimestamp returns a timestamp for a given byte slice.

func PrepareResultFieldData

func PrepareResultFieldData(sample []*schemapb.FieldData, topK int64) []*schemapb.FieldData

PrepareResultFieldData construct this slice fo FieldData for final result reduce this shall preallocate the space for field data internal slice prevent slice growing cost.

func RearrangePartitionsForPartitionKey

func RearrangePartitionsForPartitionKey(partitions map[string]int64) ([]string, []int64, error)

this method returns a static sequence for partitions for partiton key mode

func SelectMinPK

func SelectMinPK[T ResultWithID](results []T, cursors []int64) (int, bool)

SelectMinPK select the index of the minPK in results T of the cursors.

func SelectMinPKWithTimestamp

func SelectMinPKWithTimestamp[T interface {
	ResultWithID
	ResultWithTimestamp
}](results []T, cursors []int64) (int, bool)

func ServerTypeList

func ServerTypeList() []string

func SliceRemoveDuplicate

func SliceRemoveDuplicate(a interface{}) (ret []interface{})

SliceRemoveDuplicate is used to dedup a Slice

func SortSparseFloatRow

func SortSparseFloatRow(indices []uint32, values []float32) ([]uint32, []float32)

func SparseFloatBytesToMap

func SparseFloatBytesToMap(b []byte) map[uint32]float32

func SparseFloatRowDim

func SparseFloatRowDim(row []byte) int64

dim of a sparse float vector is the maximum/last index + 1. for an empty row, dim is 0.

func SparseFloatRowElementCount

func SparseFloatRowElementCount(row []byte) int

SparseFloatRowUtils

func SparseFloatRowIndexAt

func SparseFloatRowIndexAt(row []byte, idx int) uint32

does not check for out-of-range access

func SparseFloatRowSetAt

func SparseFloatRowSetAt(row []byte, pos int, idx uint32, value float32)

func SparseFloatRowValueAt

func SparseFloatRowValueAt(row []byte, idx int) float32

does not check for out-of-range access

func SubTimeByWallClock

func SubTimeByWallClock(after, before time.Time) time.Duration

SubTimeByWallClock returns the duration between two different timestamps.

func SwapPK

func SwapPK(data *schemapb.IDs, i, j int)

SwapPK swaps i-th PK with j-th PK

func TimestampToString

func TimestampToString(ts uint64) string

func Uint64ToBytes

func Uint64ToBytes(v uint64) []byte

Uint64ToBytes converts uint64 to a byte slice.

func Uint64ToBytesBigEndian

func Uint64ToBytesBigEndian(v uint64) []byte

Uint64ToBytesBigEndian converts uint64 to a byte slice(big endian).

func UnsafeBytes2str

func UnsafeBytes2str(b []byte) string

#nosec G103

func UnsafeStr2bytes

func UnsafeStr2bytes(s string) []byte

#nosec G103

func ValidateSparseFloatRows

func ValidateSparseFloatRows(rows ...[]byte) error

func VectorTypeSize

func VectorTypeSize(dataType schemapb.DataType) float64

return VectorTypeSize for each dim (byte)

func VerifyBFloats16

func VerifyBFloats16(value []byte) error

func VerifyFloat

func VerifyFloat(value float64) error

func VerifyFloats16

func VerifyFloats16(value []byte) error

func VerifyFloats32

func VerifyFloats32(values []float32) error

func VerifyFloats64

func VerifyFloats64(values []float64) error

Types

type BackoffConfig

type BackoffConfig struct {
	InitialInterval time.Duration
	Multiplier      float64
	MaxInterval     time.Duration
}

BackoffConfig is the configuration for backoff

type BackoffTimer

type BackoffTimer struct {
	// contains filtered or unexported fields
}

BackoffTimer is a timer for balance operation

func NewBackoffTimer

func NewBackoffTimer(configFetcher BackoffTimerConfigFetcher) *BackoffTimer

NewBackoffTimer creates a new balanceTimer

func (*BackoffTimer) DisableBackoff

func (t *BackoffTimer) DisableBackoff()

DisableBackoff disables the backoff

func (*BackoffTimer) EnableBackoff

func (t *BackoffTimer) EnableBackoff()

EnableBackoff enables the backoff

func (*BackoffTimer) IsBackoffStopped

func (t *BackoffTimer) IsBackoffStopped() bool

IsBackoffStopped returns the elapsed time of backoff

func (*BackoffTimer) NextInterval

func (t *BackoffTimer) NextInterval() time.Duration

NextInterval returns the next interval

func (*BackoffTimer) NextTimer

func (t *BackoffTimer) NextTimer() (<-chan time.Time, time.Duration)

NextTimer returns the next timer and the duration of the timer

type BackoffTimerConfig

type BackoffTimerConfig struct {
	Default time.Duration
	Backoff BackoffConfig
}

BackoffTimerConfig is the configuration for backoff timer It's also used to be const config fetcher. Every DefaultInterval is a fetch loop.

func (BackoffTimerConfig) BackoffConfig

func (c BackoffTimerConfig) BackoffConfig() BackoffConfig

func (BackoffTimerConfig) DefaultInterval

func (c BackoffTimerConfig) DefaultInterval() time.Duration

type BackoffTimerConfigFetcher

type BackoffTimerConfigFetcher interface {
	DefaultInterval() time.Duration
	BackoffConfig() BackoffConfig
}

BackoffTimerConfigFetcher is the interface to fetch backoff timer configuration

type CacheOp

type CacheOp struct {
	OpType CacheOpType
	OpKey  string
}

type CacheOpType

type CacheOpType int32
const (
	CacheAddUserToRole CacheOpType = iota + 1
	CacheRemoveUserFromRole
	CacheGrantPrivilege
	CacheRevokePrivilege
	CacheDeleteUser
	CacheDropRole
	CacheRefresh
)

type Closable

type Closable interface {
	Close()
}

Closable is an interface that can be closed or release the resource.

type ConcurrentMap

type ConcurrentMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewConcurrentMap

func NewConcurrentMap[K comparable, V any]() *ConcurrentMap[K, V]

func (*ConcurrentMap[K, V]) Contain

func (m *ConcurrentMap[K, V]) Contain(key K) bool

func (*ConcurrentMap[K, V]) Get

func (m *ConcurrentMap[K, V]) Get(key K) (V, bool)

func (*ConcurrentMap[K, V]) GetAndRemove

func (m *ConcurrentMap[K, V]) GetAndRemove(key K) (V, bool)

func (*ConcurrentMap[K, V]) GetOrInsert

func (m *ConcurrentMap[K, V]) GetOrInsert(key K, value V) (V, bool)

GetOrInsert returns the `value` and `loaded` on the given `key`, `value` set. If the key already exists, return the value and set `loaded` to true. If the key does not exist, insert the given `key` and `value` to map, return the value and set `loaded` to false.

func (*ConcurrentMap[K, V]) Insert

func (m *ConcurrentMap[K, V]) Insert(key K, value V)

Insert inserts the key-value pair to the concurrent map

func (*ConcurrentMap[K, V]) Keys

func (m *ConcurrentMap[K, V]) Keys() []K

func (*ConcurrentMap[K, V]) Len

func (m *ConcurrentMap[K, V]) Len() int

func (*ConcurrentMap[K, V]) Range

func (m *ConcurrentMap[K, V]) Range(f func(key K, value V) bool)

func (*ConcurrentMap[K, V]) Remove

func (m *ConcurrentMap[K, V]) Remove(key K)

Remove removes the `key`, `value` set if `key` is in the map, does nothing if `key` not in the map.

func (*ConcurrentMap[K, V]) Values

func (m *ConcurrentMap[K, V]) Values() []V

type ConcurrentSet

type ConcurrentSet[T comparable] struct {
	// contains filtered or unexported fields
}

func NewConcurrentSet

func NewConcurrentSet[T comparable]() *ConcurrentSet[T]

func (*ConcurrentSet[T]) Collect

func (set *ConcurrentSet[T]) Collect() []T

Get all elements in the set

func (*ConcurrentSet[T]) Contain

func (set *ConcurrentSet[T]) Contain(elements ...T) bool

Check whether the elements exist

func (*ConcurrentSet[T]) Insert

func (set *ConcurrentSet[T]) Insert(element T) bool

func (*ConcurrentSet[T]) Range

func (set *ConcurrentSet[T]) Range(f func(element T) bool)

func (*ConcurrentSet[T]) Remove

func (set *ConcurrentSet[T]) Remove(elements ...T)

Remove elements from the set, do nothing if set is nil or id not exists

func (*ConcurrentSet[T]) TryRemove

func (set *ConcurrentSet[T]) TryRemove(element T) bool

Try remove element from set, return false if not exist

func (*ConcurrentSet[T]) Upsert

func (set *ConcurrentSet[T]) Upsert(elements ...T)

Insert elements into the set, do nothing if the id existed

type FieldSchemaHelper

type FieldSchemaHelper struct {
	// contains filtered or unexported fields
}

func CreateFieldSchemaHelper

func CreateFieldSchemaHelper(schema *schemapb.FieldSchema) *FieldSchemaHelper

func (*FieldSchemaHelper) EnableAnalyzer

func (h *FieldSchemaHelper) EnableAnalyzer() bool

func (*FieldSchemaHelper) EnableMatch

func (h *FieldSchemaHelper) EnableMatch() bool

func (*FieldSchemaHelper) GetDim

func (h *FieldSchemaHelper) GetDim() (int64, error)

type GenericSchemaSlice

type GenericSchemaSlice[T any] interface {
	Append(T)
	Get(int) T
}

func NewInt64PkSchemaSlice

func NewInt64PkSchemaSlice(data *schemapb.IDs) GenericSchemaSlice[int64]

func NewStringPkSchemaSlice

func NewStringPkSchemaSlice(data *schemapb.IDs) GenericSchemaSlice[string]

type Heap

type Heap[E any] interface {
	// Len returns the size of the heap.
	Len() int

	// Push pushes an element onto the heap.
	Push(x E)

	// Pop returns the element at the top of the heap.
	// Panics if the heap is empty.
	Pop() E

	// Peek returns the element at the top of the heap.
	// Panics if the heap is empty.
	Peek() E
}

Heap is a heap of E. Use `golang.org/x/exp/constraints` directly if you want to change any element.

func NewArrayBasedMaximumHeap

func NewArrayBasedMaximumHeap[E constraints.Ordered](initial []E) Heap[E]

NewArrayBasedMaximumHeap returns a new maximum heap.

func NewArrayBasedMinimumHeap

func NewArrayBasedMinimumHeap[E constraints.Ordered](initial []E) Heap[E]

NewArrayBasedMinimumHeap returns a new minimum heap.

func NewHeap

func NewHeap[E any](inner HeapInterface) Heap[E]

NewHeap returns a new heap from a underlying representation.

type HeapInterface

type HeapInterface interface {
	heap.Interface
	Peek() interface{}
}

HeapInterface is the interface that a heap must implement.

type IDAllocator

type IDAllocator struct {
	// contains filtered or unexported fields
}

IDAllocator is a thread-safe ID allocator.

func NewIDAllocator

func NewIDAllocator() *IDAllocator

NewIDAllocator creates a new IDAllocator.

func (*IDAllocator) Allocate

func (ida *IDAllocator) Allocate() int64

Allocate allocates a new ID.

type IntPrimaryKey

type IntPrimaryKey = int64

IntPrimaryKey is an alias of int64

type MultipartQueue

type MultipartQueue[T any] struct {
	// contains filtered or unexported fields
}

MultipartQueue is a multi-part queue.

func NewMultipartQueue

func NewMultipartQueue[T any]() *MultipartQueue[T]

NewMultipartQueue create a new multi-part queue.

func (*MultipartQueue[T]) Add

func (pq *MultipartQueue[T]) Add(msgs []T)

Add add a slice of message as pending one

func (*MultipartQueue[T]) AddOne

func (pq *MultipartQueue[T]) AddOne(msg T)

AddOne add a message as pending one

func (*MultipartQueue[T]) Len

func (pq *MultipartQueue[T]) Len() int

Len return the queue size.

func (*MultipartQueue[T]) Next

func (pq *MultipartQueue[T]) Next() T

Next return the next message in pending queue.

func (*MultipartQueue[T]) UnsafeAdvance

func (pq *MultipartQueue[T]) UnsafeAdvance()

UnsafeAdvance do a advance without check. !!! Should only be called `Next` do not return nil.

type OrderedMap

type OrderedMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewOrderedMap

func NewOrderedMap[K comparable, V any]() *OrderedMap[K, V]

func (*OrderedMap[K, V]) Delete

func (o *OrderedMap[K, V]) Delete(key K)

func (*OrderedMap[K, V]) Get

func (o *OrderedMap[K, V]) Get(key K) (V, bool)

func (*OrderedMap[K, V]) Keys

func (o *OrderedMap[K, V]) Keys() []K

func (*OrderedMap[K, V]) Set

func (o *OrderedMap[K, V]) Set(key K, value V)

func (*OrderedMap[K, V]) SortKeys

func (o *OrderedMap[K, V]) SortKeys(sortFunc func(keys []K))

SortKeys Sort the map keys using your sort func

type Pair

type Pair[T, U any] struct {
	A T
	B U
}

func NewPair

func NewPair[T, U any](a T, b U) Pair[T, U]

type ResultWithID

type ResultWithID interface {
	GetIds() *schemapb.IDs
	GetHasMoreResult() bool
}

type ResultWithTimestamp

type ResultWithTimestamp interface {
	GetTimestamps() []int64
}

type SchemaHelper

type SchemaHelper struct {
	// contains filtered or unexported fields
}

SchemaHelper provides methods to get the schema of fields

func CreateSchemaHelper

func CreateSchemaHelper(schema *schemapb.CollectionSchema) (*SchemaHelper, error)

CreateSchemaHelper returns a new SchemaHelper object

func CreateSchemaHelperWithLoadFields

func CreateSchemaHelperWithLoadFields(schema *schemapb.CollectionSchema, loadFields []int64) (*SchemaHelper, error)

func (*SchemaHelper) GetClusteringKeyField

func (helper *SchemaHelper) GetClusteringKeyField() (*schemapb.FieldSchema, error)

GetClusteringKeyField returns the schema of the clustering key. If not found, an error shall be returned.

func (*SchemaHelper) GetCollectionName

func (helper *SchemaHelper) GetCollectionName() string

func (*SchemaHelper) GetDynamicField

func (helper *SchemaHelper) GetDynamicField() (*schemapb.FieldSchema, error)

GetDynamicField returns the field schema of dynamic field if exists. if there is no dynamic field defined in schema, error will be returned.

func (*SchemaHelper) GetFieldFromID

func (helper *SchemaHelper) GetFieldFromID(fieldID int64) (*schemapb.FieldSchema, error)

GetFieldFromID returns the schema of specified field

func (*SchemaHelper) GetFieldFromName

func (helper *SchemaHelper) GetFieldFromName(fieldName string) (*schemapb.FieldSchema, error)

GetFieldFromName is used to find the schema by field name

func (*SchemaHelper) GetFieldFromNameDefaultJSON

func (helper *SchemaHelper) GetFieldFromNameDefaultJSON(fieldName string) (*schemapb.FieldSchema, error)

GetFieldFromNameDefaultJSON is used to find the schema by field name, if not exist, use json field

func (*SchemaHelper) GetFunctionByOutputField

func (helper *SchemaHelper) GetFunctionByOutputField(field *schemapb.FieldSchema) (*schemapb.FunctionSchema, error)

func (*SchemaHelper) GetPartitionKeyField

func (helper *SchemaHelper) GetPartitionKeyField() (*schemapb.FieldSchema, error)

GetPartitionKeyField returns the schema of the partition key

func (*SchemaHelper) GetPrimaryKeyField

func (helper *SchemaHelper) GetPrimaryKeyField() (*schemapb.FieldSchema, error)

GetPrimaryKeyField returns the schema of the primary key

func (*SchemaHelper) GetVectorDimFromID

func (helper *SchemaHelper) GetVectorDimFromID(fieldID int64) (int, error)

GetVectorDimFromID returns the dimension of specified field

func (*SchemaHelper) IsFieldLoaded

func (helper *SchemaHelper) IsFieldLoaded(fieldID int64) bool

GetFieldFromNameDefaultJSON returns whether is field loaded. If load fields is not provided, treated as loaded

type Set

type Set[T comparable] map[T]struct{}

func NewSet

func NewSet[T comparable](elements ...T) Set[T]

func ServerTypeSet

func ServerTypeSet() Set[string]

func (Set[T]) Clear

func (set Set[T]) Clear()

func (Set[T]) Clone

func (set Set[T]) Clone() Set[T]

Clone returns a new set with the same elements

func (Set[T]) Collect

func (set Set[T]) Collect() []T

Get all elements in the set

func (Set[T]) Complement

func (set Set[T]) Complement(other Set[T]) Set[T]

Complement returns the complement with the given set

func (Set[T]) Contain

func (set Set[T]) Contain(elements ...T) bool

Check whether the elements exist

func (Set[T]) Insert

func (set Set[T]) Insert(elements ...T)

Insert elements into the set, do nothing if the id existed

func (Set[T]) Intersection

func (set Set[T]) Intersection(other Set[T]) Set[T]

Intersection returns the intersection with the given set

func (Set[T]) Len

func (set Set[T]) Len() int

Len returns the number of elements in the set

func (Set[T]) Range

func (set Set[T]) Range(f func(element T) bool)

Range iterates over elements in the set

func (Set[T]) Remove

func (set Set[T]) Remove(elements ...T)

Remove elements from the set, do nothing if set is nil or id not exists

func (Set[T]) Union

func (set Set[T]) Union(other Set[T]) Set[T]

Union returns the union with the given set

type SharedReference

type SharedReference[T Closable] struct {
	// contains filtered or unexported fields
}

SharedReference is a reference type that can be shared with only one close operation. Without supported of determined destructor, A safe SharedReference is rely on user's behavior.

func NewSharedReference

func NewSharedReference[T Closable](inner T) *SharedReference[T]

NewSharedReference creates a new SharedReference with the inner object.

func (*SharedReference[T]) Clone

func (sr *SharedReference[T]) Clone() *SharedReference[T]

Clone returns a new SharedReference with the same inner object. Clone should only be called if the reference is not closed. Otherwise UB happens.

func (*SharedReference[T]) Close

func (sr *SharedReference[T]) Close()

Close closes the reference, should only be called once at a sharedReference. After called this method, all other method of the SharedReference should not be called any more. if the reference count is 0, the inner object will be closed.

func (*SharedReference[T]) Deref

func (sr *SharedReference[T]) Deref() T

Deref returns the inner object. Deref should only be called if the reference is not closed. Otherwise UB happens.

func (*SharedReference[T]) Downgrade

func (sr *SharedReference[T]) Downgrade() *WeakReference[T]

Downgrade returns a new WeakReference with the same inner object. After downgrade, the SharedReference can not be used.

type SkipList

type SkipList[K constraints.Ordered, V any] struct {
	// contains filtered or unexported fields
}

SkipList generic skip list. with extra truncate and traverse-after feature.

func NewSkipList

func NewSkipList[K constraints.Ordered, V any](opts ...SkipListOption) (*SkipList[K, V], error)

NewSkipList creates a new SkipList with provided option.

func (*SkipList[K, V]) Delete

func (sl *SkipList[K, V]) Delete(key K) (value V, ok bool)

Delete removes node with provided key. returns value if found.

func (*SkipList[K, V]) Get

func (sl *SkipList[K, V]) Get(key K) (value V, ok bool)

Get searches skip list with provided key.

func (*SkipList[K, V]) ListAfter

func (sl *SkipList[K, V]) ListAfter(key K, include bool) []V

ListAfter returns values after provided key. include indicates value related to key is returned or not.

func (*SkipList[K, V]) TruncateBefore

func (sl *SkipList[K, V]) TruncateBefore(key K)

TruncateBefore truncates elements before key.

func (*SkipList[K, V]) Upsert

func (sl *SkipList[K, V]) Upsert(key K, value V)

Insert inserts an element into skip list.

type SkipListOption

type SkipListOption func(opt *skipListOpt)

SkipListOption setup function alias.

func WithMaxLevel

func WithMaxLevel(maxLevel int) SkipListOption

WithMaxLevel returns SkipListOption to setup max level.

func WithSkip

func WithSkip(skip int) SkipListOption

WithSkip returns SkipListOption to setup skip.

type Timestamp

type Timestamp = uint64

Timestamp is an alias of uint64

type UniqueID

type UniqueID = int64

UniqueID is an alias of int64

type UniqueSet

type UniqueSet = Set[UniqueID]

UniqueSet is set type, which contains only UniqueIDs, the underlying type is map[UniqueID]struct{}. Create a UniqueSet instance with make(UniqueSet) like creating a map instance.

func NewUniqueSet

func NewUniqueSet(ids ...UniqueID) UniqueSet

type Version

type Version interface {
	// GT returns true if v > v2.
	GT(Version) bool

	// EQ returns true if v == v2.
	EQ(Version) bool
}

Version is a interface for version comparison.

type VersionInt64

type VersionInt64 int64

VersionInt64 is a int64 type version.

func (VersionInt64) EQ

func (v VersionInt64) EQ(v2 Version) bool

func (VersionInt64) GT

func (v VersionInt64) GT(v2 Version) bool

type VersionInt64Pair

type VersionInt64Pair struct {
	Global int64
	Local  int64
}

VersionInt64Pair is a pair of int64 type version. It's easy to be used in multi node version comparison.

func (VersionInt64Pair) EQ

func (v VersionInt64Pair) EQ(v2 Version) bool

func (VersionInt64Pair) GT

func (v VersionInt64Pair) GT(v2 Version) bool

type WeakReference

type WeakReference[T Closable] struct {
	// contains filtered or unexported fields
}

WeakReference is a weak reference type that can be shared with only one close operation.

func (*WeakReference[T]) Upgrade

func (wr *WeakReference[T]) Upgrade() *SharedReference[T]

Jump to

Keyboard shortcuts

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