helper

package
v0.0.0-...-b3791a6 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CollPrepare CollectionPrepare
	FieldsFact  FieldsFactory
)
View Source
var SupportBinIvfFlatMetricType = []entity.MetricType{
	entity.JACCARD,
	entity.HAMMING,
}
View Source
var SupportFloatMetricType = []entity.MetricType{
	entity.L2,
	entity.IP,
	entity.COSINE,
}

utils func

Functions

func CreateContext

func CreateContext(t *testing.T, timeout time.Duration) context.Context

func GenAllFieldsRows

func GenAllFieldsRows(nb int, enableDynamicField bool, option GenDataOption) []interface{}

func GenAllFloatIndex

func GenAllFloatIndex(metricType entity.MetricType) []index.Index

GenAllFloatIndex gen all float vector index

func GenArrayColumnData

func GenArrayColumnData(nb int, eleType entity.FieldType, option GenDataOption) column.Column

func GenColumnData

func GenColumnData(nb int, fieldType entity.FieldType, option GenDataOption) column.Column

GenColumnData GenColumnDataOption except dynamic column

func GenColumnDataWithFp32VecConversion

func GenColumnDataWithFp32VecConversion(nb int, fieldType entity.FieldType, option GenDataOption) column.Column

func GenColumnsBasedSchema

func GenColumnsBasedSchema(schema *entity.Schema, option *GenDataOption) ([]column.Column, []column.Column)

func GenColumnsBasedSchemaWithFp32VecConversion

func GenColumnsBasedSchemaWithFp32VecConversion(schema *entity.Schema, option *GenDataOption) ([]column.Column, []column.Column)

func GenDefaultJSONData

func GenDefaultJSONData(nb int, option GenDataOption) [][]byte

GenDefaultJSONData gen default column with data

func GenDynamicColumnData

func GenDynamicColumnData(start int, nb int) []column.Column

func GenFp16OrBf16VectorsFromFloatVector

func GenFp16OrBf16VectorsFromFloatVector(nq int, dim int, dataType entity.FieldType) []entity.Vector

func GenInt64VarcharSparseRows

func GenInt64VarcharSparseRows(nb int, enableDynamicField bool, autoID bool, option GenDataOption) []interface{}

func GenInt64VecRows

func GenInt64VecRows(nb int, enableDynamicField bool, autoID bool, option GenDataOption) []interface{}

func GenSchema

func GenSchema(option *GenSchemaOption) *entity.Schema

func GenSearchVectors

func GenSearchVectors(nq int, dim int, dataType entity.FieldType) []entity.Vector

GenSearchVectors gen search vectors

func GetAllArrayElementType

func GetAllArrayElementType() []entity.FieldType

var ArrayFieldType =

func GetAllFieldsType

func GetAllFieldsType() []entity.FieldType

func GetAllScalarFieldType

func GetAllScalarFieldType() []entity.FieldType

func GetAllVectorFieldType

func GetAllVectorFieldType() []entity.FieldType

func GetDefaultVectorIndex

func GetDefaultVectorIndex(fieldType entity.FieldType) index.Index

func GetFieldNameByElementType

func GetFieldNameByElementType(t entity.FieldType) string

func GetFieldNameByFieldType

func GetFieldNameByFieldType(t entity.FieldType, opts ...GetFieldNameOpt) string

func GetInvalidPartitionKeyFieldType

func GetInvalidPartitionKeyFieldType() []entity.FieldType

func GetInvalidPkFieldType

func GetInvalidPkFieldType() []entity.FieldType

func MergeColumnsToDynamic

func MergeColumnsToDynamic(nb int, columns []column.Column, columnName string) *column.ColumnJSONBytes

func SupportScalarIndexFieldType

func SupportScalarIndexFieldType(field entity.FieldType) bool

Types

type Array

type Array struct {
	BoolArray    []bool    `json:"boolArray,omitempty" milvus:"name:boolArray"`
	Int8Array    []int8    `json:"int8Array,omitempty" milvus:"name:int8Array"`
	Int16Array   []int16   `json:"int16Array,omitempty" milvus:"name:int16Array"`
	Int32Array   []int32   `json:"int32Array,omitempty" milvus:"name:int32Array"`
	Int64Array   []int64   `json:"int64Array,omitempty" milvus:"name:int64Array"`
	FloatArray   []float32 `json:"floatArray,omitempty" milvus:"name:floatArray"`
	DoubleArray  []float64 `json:"doubleArray,omitempty" milvus:"name:doubleArray"`
	VarcharArray [][]byte  `json:"varcharArray,omitempty" milvus:"name:varcharArray"`
}

func GenAllArrayRow

func GenAllArrayRow(index int, option GenDataOption) Array

type BaseRow

type BaseRow struct {
	*BoolStruct
	Int8      int8                   `json:"int8,omitempty" milvus:"name:int8"`
	Int16     int16                  `json:"int16,omitempty" milvus:"name:int16"`
	Int32     int32                  `json:"int32,omitempty" milvus:"name:int32"`
	Int64     int64                  `json:"int64,omitempty" milvus:"name:int64"`
	Float     float32                `json:"float,omitempty" milvus:"name:float"`
	Double    float64                `json:"double,omitempty" milvus:"name:double"`
	Varchar   string                 `json:"varchar,omitempty" milvus:"name:varchar"`
	JSON      *JSONStruct            `json:"json,omitempty" milvus:"name:json"`
	FloatVec  []float32              `json:"floatVec,omitempty" milvus:"name:floatVec"`
	Fp16Vec   []byte                 `json:"fp16Vec,omitempty" milvus:"name:fp16Vec"`
	Bf16Vec   []byte                 `json:"bf16Vec,omitempty" milvus:"name:bf16Vec"`
	BinaryVec []byte                 `json:"binaryVec,omitempty" milvus:"name:binaryVec"`
	SparseVec entity.SparseEmbedding `json:"sparseVec,omitempty" milvus:"name:sparseVec"`
	Array
	Dynamic
}

type BoolDynamic

type BoolDynamic struct {
	Bool bool `json:"dynamicBool" milvus:"name:dynamicBool"`
}

type BoolStruct

type BoolStruct struct {
	Bool bool `json:"bool" milvus:"name:bool"`
}

type CollectionFields

type CollectionFields interface {
	GenFields(opts GenFieldsOption) []*entity.Field
}

product

type CollectionFieldsType

type CollectionFieldsType int32
const (
	// FieldTypeNone zero value place holder
	Int64Vec              CollectionFieldsType = 1 // int64 + floatVec
	VarcharBinary         CollectionFieldsType = 2 // varchar + binaryVec
	Int64VecJSON          CollectionFieldsType = 3 // int64 + floatVec + json
	Int64VecArray         CollectionFieldsType = 4 // int64 + floatVec + array
	Int64VarcharSparseVec CollectionFieldsType = 5 // int64 + varchar + sparse vector
	Int64MultiVec         CollectionFieldsType = 6 // int64 + floatVec + binaryVec + fp16Vec + bf16vec
	AllFields             CollectionFieldsType = 7 // all fields excepted sparse
	Int64VecAllScalar     CollectionFieldsType = 8 // int64 + floatVec + all scalar fields
)

type CollectionPrepare

type CollectionPrepare struct{}

CollectionPrepare ----------------- prepare data --------------------------

func (*CollectionPrepare) CreateCollection

func (chainTask *CollectionPrepare) CreateCollection(ctx context.Context, t *testing.T, mc *base.MilvusClient,
	cp *CreateCollectionParams, fieldOpt *GenFieldsOption, schemaOpt *GenSchemaOption,
) (*CollectionPrepare, *entity.Schema)

func (*CollectionPrepare) CreateIndex

func (chainTask *CollectionPrepare) CreateIndex(ctx context.Context, t *testing.T, mc *base.MilvusClient, ip *IndexParams) *CollectionPrepare

func (*CollectionPrepare) FlushData

func (chainTask *CollectionPrepare) FlushData(ctx context.Context, t *testing.T, mc *base.MilvusClient, collName string) *CollectionPrepare

func (*CollectionPrepare) InsertData

func (*CollectionPrepare) Load

type CreateCollectionParams

type CreateCollectionParams struct {
	CollectionFieldsType CollectionFieldsType // collection fields type
}

func NewCreateCollectionParams

func NewCreateCollectionParams(collectionFieldsType CollectionFieldsType) *CreateCollectionParams

type Dynamic

type Dynamic struct {
	Number int32  `json:"dynamicNumber,omitempty" milvus:"name:dynamicNumber"`
	String string `json:"dynamicString,omitempty" milvus:"name:dynamicString"`
	*BoolDynamic
	List []int64 `json:"dynamicList,omitempty" milvus:"name:dynamicList"`
}

func GenDynamicRow

func GenDynamicRow(index int) Dynamic

type FieldsAllFields

type FieldsAllFields struct{} // except sparse vector field

func (FieldsAllFields) GenFields

func (cf FieldsAllFields) GenFields(option GenFieldsOption) []*entity.Field

type FieldsFactory

type FieldsFactory struct{}

factory

func (FieldsFactory) GenFieldsForCollection

func (ff FieldsFactory) GenFieldsForCollection(collectionFieldsType CollectionFieldsType, option *GenFieldsOption) []*entity.Field

type FieldsInt64MultiVec

type FieldsInt64MultiVec struct{}

func (FieldsInt64MultiVec) GenFields

func (cf FieldsInt64MultiVec) GenFields(option GenFieldsOption) []*entity.Field

type FieldsInt64VarcharSparseVec

type FieldsInt64VarcharSparseVec struct{}

func (FieldsInt64VarcharSparseVec) GenFields

func (cf FieldsInt64VarcharSparseVec) GenFields(option GenFieldsOption) []*entity.Field

type FieldsInt64Vec

type FieldsInt64Vec struct{}

func (FieldsInt64Vec) GenFields

func (cf FieldsInt64Vec) GenFields(option GenFieldsOption) []*entity.Field

type FieldsInt64VecAllScalar

type FieldsInt64VecAllScalar struct{} // except sparse vector field

func (FieldsInt64VecAllScalar) GenFields

func (cf FieldsInt64VecAllScalar) GenFields(option GenFieldsOption) []*entity.Field

type FieldsInt64VecArray

type FieldsInt64VecArray struct{}

func (FieldsInt64VecArray) GenFields

func (cf FieldsInt64VecArray) GenFields(option GenFieldsOption) []*entity.Field

type FieldsInt64VecJSON

type FieldsInt64VecJSON struct{}

func (FieldsInt64VecJSON) GenFields

func (cf FieldsInt64VecJSON) GenFields(option GenFieldsOption) []*entity.Field

type FieldsVarcharBinary

type FieldsVarcharBinary struct{}

func (FieldsVarcharBinary) GenFields

func (cf FieldsVarcharBinary) GenFields(option GenFieldsOption) []*entity.Field

type GenDataOption

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

GenColumnDataOption -- create column data --

func TNewDataOption

func TNewDataOption() *GenDataOption

func (*GenDataOption) TWithDim

func (opt *GenDataOption) TWithDim(dim int) *GenDataOption

func (*GenDataOption) TWithElementType

func (opt *GenDataOption) TWithElementType(eleType entity.FieldType) *GenDataOption

func (*GenDataOption) TWithFieldName

func (opt *GenDataOption) TWithFieldName(fieldName string) *GenDataOption

func (*GenDataOption) TWithMaxCapacity

func (opt *GenDataOption) TWithMaxCapacity(maxCap int) *GenDataOption

func (*GenDataOption) TWithMaxLen

func (opt *GenDataOption) TWithMaxLen(maxLen int) *GenDataOption

func (*GenDataOption) TWithNb

func (opt *GenDataOption) TWithNb(nb int) *GenDataOption

func (*GenDataOption) TWithSparseMaxLen

func (opt *GenDataOption) TWithSparseMaxLen(sparseMaxLen int) *GenDataOption

func (*GenDataOption) TWithStart

func (opt *GenDataOption) TWithStart(start int) *GenDataOption

type GenFieldsOption

type GenFieldsOption struct {
	AutoID         bool // is auto id
	Dim            int64
	IsDynamic      bool
	MaxLength      int64 // varchar len or array capacity
	MaxCapacity    int64
	IsPartitionKey bool
	ElementType    entity.FieldType
}

func TNewFieldsOption

func TNewFieldsOption() *GenFieldsOption

func (*GenFieldsOption) TWithAutoID

func (opt *GenFieldsOption) TWithAutoID(autoID bool) *GenFieldsOption

func (*GenFieldsOption) TWithDim

func (opt *GenFieldsOption) TWithDim(dim int64) *GenFieldsOption

func (*GenFieldsOption) TWithElementType

func (opt *GenFieldsOption) TWithElementType(elementType entity.FieldType) *GenFieldsOption

func (*GenFieldsOption) TWithIsDynamic

func (opt *GenFieldsOption) TWithIsDynamic(isDynamic bool) *GenFieldsOption

func (*GenFieldsOption) TWithIsPartitionKey

func (opt *GenFieldsOption) TWithIsPartitionKey(isPartitionKey bool) *GenFieldsOption

func (*GenFieldsOption) TWithMaxCapacity

func (opt *GenFieldsOption) TWithMaxCapacity(maxCapacity int64) *GenFieldsOption

func (*GenFieldsOption) TWithMaxLen

func (opt *GenFieldsOption) TWithMaxLen(maxLen int64) *GenFieldsOption

type GenSchemaOption

type GenSchemaOption struct {
	CollectionName     string
	Description        string
	AutoID             bool
	Fields             []*entity.Field
	EnableDynamicField bool
}

func TNewSchemaOption

func TNewSchemaOption() *GenSchemaOption

func (*GenSchemaOption) TWithAutoID

func (opt *GenSchemaOption) TWithAutoID(autoID bool) *GenSchemaOption

func (*GenSchemaOption) TWithDescription

func (opt *GenSchemaOption) TWithDescription(description string) *GenSchemaOption

func (*GenSchemaOption) TWithEnableDynamicField

func (opt *GenSchemaOption) TWithEnableDynamicField(enableDynamicField bool) *GenSchemaOption

func (*GenSchemaOption) TWithFields

func (opt *GenSchemaOption) TWithFields(fields []*entity.Field) *GenSchemaOption

func (*GenSchemaOption) TWithName

func (opt *GenSchemaOption) TWithName(collectionName string) *GenSchemaOption

type GetFieldNameOpt

type GetFieldNameOpt func(opt *getFieldNameOpt)

func TWithElementType

func TWithElementType(eleType entity.FieldType) GetFieldNameOpt

func TWithIsDynamic

func TWithIsDynamic(isDynamic bool) GetFieldNameOpt

type IndexParams

type IndexParams struct {
	Schema        *entity.Schema
	FieldIndexMap map[string]index.Index
}

func TNewIndexParams

func TNewIndexParams(schema *entity.Schema) *IndexParams

func (*IndexParams) TWithFieldIndex

func (opt *IndexParams) TWithFieldIndex(mFieldIndex map[string]index.Index) *IndexParams

type InsertParams

type InsertParams struct {
	Schema        *entity.Schema
	PartitionName string
	IsRows        bool
}

insert params

func NewInsertParams

func NewInsertParams(schema *entity.Schema) *InsertParams

func (*InsertParams) TWithIsRows

func (opt *InsertParams) TWithIsRows(isRows bool) *InsertParams

func (*InsertParams) TWithPartitionName

func (opt *InsertParams) TWithPartitionName(partitionName string) *InsertParams

type JSONStruct

type JSONStruct struct {
	Number int32  `json:"number,omitempty" milvus:"name:number"`
	String string `json:"string,omitempty" milvus:"name:string"`
	*BoolStruct
	List []int64 `json:"list,omitempty" milvus:"name:list"`
}

func GenJSONRow

func GenJSONRow(index int) *JSONStruct

type LoadParams

type LoadParams struct {
	CollectionName       string
	Replica              int
	LoadFields           []string
	SkipLoadDynamicField bool
}

func NewLoadParams

func NewLoadParams(collectionName string) *LoadParams

func (*LoadParams) TWithLoadFields

func (opt *LoadParams) TWithLoadFields(loadFields ...string) *LoadParams

func (*LoadParams) TWithReplica

func (opt *LoadParams) TWithReplica(replica int) *LoadParams

func (*LoadParams) TWithSkipLoadDynamicField

func (opt *LoadParams) TWithSkipLoadDynamicField(skipFlag bool) *LoadParams

Jump to

Keyboard shortcuts

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