entity

package
v2.0.0-...-accfacf Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2024 License: Apache-2.0 Imports: 11 Imported by: 3

Documentation

Index

Constants

View Source
const (
	FunctionTypeUnknown       = schemapb.FunctionType_Unknown
	FunctionTypeBM25          = schemapb.FunctionType_BM25
	FunctionTypeTextEmbedding = schemapb.FunctionType_TextEmbedding
)

provide package alias

View Source
const (
	// TypeParamDim is the const for field type param dimension
	TypeParamDim = "dim"

	// TypeParamMaxLength is the const for varchar type maximal length
	TypeParamMaxLength = "max_length"

	// TypeParamMaxCapacity is the const for array type max capacity
	TypeParamMaxCapacity = `max_capacity`

	// ClStrong strong consistency level
	ClStrong ConsistencyLevel = ConsistencyLevel(commonpb.ConsistencyLevel_Strong)
	// ClBounded bounded consistency level with default tolerance of 5 seconds
	ClBounded ConsistencyLevel = ConsistencyLevel(commonpb.ConsistencyLevel_Bounded)
	// ClSession session consistency level
	ClSession ConsistencyLevel = ConsistencyLevel(commonpb.ConsistencyLevel_Session)
	// ClEvenually eventually consistency level
	ClEventually ConsistencyLevel = ConsistencyLevel(commonpb.ConsistencyLevel_Eventually)
	// ClCustomized customized consistency level and users pass their own `guarantee_timestamp`.
	ClCustomized ConsistencyLevel = ConsistencyLevel(commonpb.ConsistencyLevel_Customized)
)
View Source
const DefaultShardNumber int32 = 0

DefaultShardNumber const value for using Milvus default shard number.

Variables

This section is empty.

Functions

func CollectionAutoCompactionEnabled

func CollectionAutoCompactionEnabled(enabled bool) autoCompactionCollAttr

CollectionAutoCompactionEnabled returns collection attribute to set collection auto compaction enabled.

func CollectionTTL

func CollectionTTL(ttl int64) ttlCollAttr

CollectionTTL returns collection attribute to set collection ttl in seconds.

func DeserializeSliceSparseEmbedding

func DeserializeSliceSparseEmbedding(bs []byte) (sliceSparseEmbedding, error)

func KvPairsMap

func KvPairsMap(kvps []*commonpb.KeyValuePair) map[string]string

KvPairsMap converts commonpb.KeyValuePair slices into map

func MapKvPairs

func MapKvPairs(m map[string]string) []*commonpb.KeyValuePair

MapKvPairs converts map into commonpb.KeyValuePair slice

Types

type Alias

type Alias struct {
	DbName         string
	Alias          string
	CollectionName string
}

Alias is the entity model for collection alias.

type BFloat16Vector

type BFloat16Vector []byte

FloatVector float32 vector wrapper.

func (BFloat16Vector) Dim

func (fv BFloat16Vector) Dim() int

Dim returns vector dimension.

func (BFloat16Vector) FieldType

func (fv BFloat16Vector) FieldType() FieldType

entity.FieldType returns coresponding field type.

func (BFloat16Vector) Serialize

func (fv BFloat16Vector) Serialize() []byte

func (BFloat16Vector) ToFloat32Vector

func (fv BFloat16Vector) ToFloat32Vector() FloatVector

type BinaryVector

type BinaryVector []byte

BinaryVector []byte vector wrapper

func (BinaryVector) Dim

func (bv BinaryVector) Dim() int

Dim return vector dimension, note that binary vector is bits count

func (BinaryVector) FieldType

func (bv BinaryVector) FieldType() FieldType

entity.FieldType returns coresponding field type.

func (BinaryVector) Serialize

func (bv BinaryVector) Serialize() []byte

Serialize just return bytes

type Collection

type Collection struct {
	ID               int64   // collection id
	Name             string  // collection name
	Schema           *Schema // collection schema, with fields schema and primary key definition
	PhysicalChannels []string
	VirtualChannels  []string
	Loaded           bool
	ConsistencyLevel ConsistencyLevel
	ShardNum         int32
	Properties       map[string]string
}

Collection represent collection meta in Milvus

type CollectionAttribute

type CollectionAttribute interface {
	KeyValue() (string, string)
	Valid() error
}

CollectionAttribute is the interface for altering collection attributes.

type CompactionState

type CompactionState commonpb.CompactionState

CompactionState enum type for compaction state

CompactionState Constants

type ConsistencyLevel

type ConsistencyLevel commonpb.ConsistencyLevel

ConsistencyLevel enum type for collection Consistency Level

const DefaultConsistencyLevel ConsistencyLevel = ClBounded

DefaultConsistencyLevel const value for using Milvus default consistency level setting.

func (ConsistencyLevel) CommonConsistencyLevel

func (cl ConsistencyLevel) CommonConsistencyLevel() commonpb.ConsistencyLevel

CommonConsistencyLevel returns corresponding commonpb.ConsistencyLevel

type Database

type Database struct {
	Name       string
	Properties map[string]string
}

type Field

type Field struct {
	ID              int64  // field id, generated when collection is created, input value is ignored
	Name            string // field name
	PrimaryKey      bool   // is primary key
	AutoID          bool   // is auto id
	Description     string
	DataType        FieldType
	TypeParams      map[string]string
	IndexParams     map[string]string
	IsDynamic       bool
	IsPartitionKey  bool
	IsClusteringKey bool
	ElementType     FieldType
	DefaultValue    *schemapb.ValueField
	Nullable        bool
}

Field represent field schema in milvus

func NewField

func NewField() *Field

NewField creates a new Field with map initialized.

func (*Field) GetDim

func (f *Field) GetDim() (int64, error)

func (*Field) ProtoMessage

func (f *Field) ProtoMessage() *schemapb.FieldSchema

ProtoMessage generates corresponding FieldSchema

func (*Field) ReadProto

func (f *Field) ReadProto(p *schemapb.FieldSchema) *Field

ReadProto parses FieldSchema

func (*Field) WithAnalyzerParams

func (f *Field) WithAnalyzerParams(params map[string]any) *Field

func (*Field) WithDataType

func (f *Field) WithDataType(dataType FieldType) *Field

func (*Field) WithDefaultValueBool

func (f *Field) WithDefaultValueBool(defaultValue bool) *Field

func (*Field) WithDefaultValueDouble

func (f *Field) WithDefaultValueDouble(defaultValue float64) *Field

func (*Field) WithDefaultValueFloat

func (f *Field) WithDefaultValueFloat(defaultValue float32) *Field

func (*Field) WithDefaultValueInt

func (f *Field) WithDefaultValueInt(defaultValue int32) *Field

func (*Field) WithDefaultValueLong

func (f *Field) WithDefaultValueLong(defaultValue int64) *Field

func (*Field) WithDefaultValueString

func (f *Field) WithDefaultValueString(defaultValue string) *Field

func (*Field) WithDescription

func (f *Field) WithDescription(desc string) *Field

func (*Field) WithDim

func (f *Field) WithDim(dim int64) *Field

func (*Field) WithElementType

func (f *Field) WithElementType(eleType FieldType) *Field

func (*Field) WithEnableAnalyzer

func (f *Field) WithEnableAnalyzer(enable bool) *Field

func (*Field) WithIsAutoID

func (f *Field) WithIsAutoID(isAutoID bool) *Field

func (*Field) WithIsClusteringKey

func (f *Field) WithIsClusteringKey(isClusteringKey bool) *Field

func (*Field) WithIsDynamic

func (f *Field) WithIsDynamic(isDynamic bool) *Field

func (*Field) WithIsPartitionKey

func (f *Field) WithIsPartitionKey(isPartitionKey bool) *Field

func (*Field) WithIsPrimaryKey

func (f *Field) WithIsPrimaryKey(isPrimaryKey bool) *Field

func (*Field) WithMaxCapacity

func (f *Field) WithMaxCapacity(maxCap int64) *Field

func (*Field) WithMaxLength

func (f *Field) WithMaxLength(maxLen int64) *Field

func (*Field) WithName

func (f *Field) WithName(name string) *Field

func (*Field) WithNullable

func (f *Field) WithNullable(nullable bool) *Field

func (*Field) WithTypeParams

func (f *Field) WithTypeParams(key string, value string) *Field

type FieldType

type FieldType int32

FieldType field data type alias type used in go:generate trick, DO NOT modify names & string

const (
	// FieldTypeNone zero value place holder
	FieldTypeNone FieldType = 0 // zero value place holder
	// FieldTypeBool field type boolean
	FieldTypeBool FieldType = 1
	// FieldTypeInt8 field type int8
	FieldTypeInt8 FieldType = 2
	// FieldTypeInt16 field type int16
	FieldTypeInt16 FieldType = 3
	// FieldTypeInt32 field type int32
	FieldTypeInt32 FieldType = 4
	// FieldTypeInt64 field type int64
	FieldTypeInt64 FieldType = 5
	// FieldTypeFloat field type float
	FieldTypeFloat FieldType = 10
	// FieldTypeDouble field type double
	FieldTypeDouble FieldType = 11
	// FieldTypeString field type string
	FieldTypeString FieldType = 20
	// FieldTypeVarChar field type varchar
	FieldTypeVarChar FieldType = 21 // variable-length strings with a specified maximum length
	// FieldTypeArray field type Array
	FieldTypeArray FieldType = 22
	// FieldTypeJSON field type JSON
	FieldTypeJSON FieldType = 23
	// FieldTypeBinaryVector field type binary vector
	FieldTypeBinaryVector FieldType = 100
	// FieldTypeFloatVector field type float vector
	FieldTypeFloatVector FieldType = 101
	// FieldTypeBinaryVector field type float16 vector
	FieldTypeFloat16Vector FieldType = 102
	// FieldTypeBinaryVector field type bf16 vector
	FieldTypeBFloat16Vector FieldType = 103
	// FieldTypeBinaryVector field type sparse vector
	FieldTypeSparseVector FieldType = 104
)

Match schema definition

func (FieldType) Name

func (t FieldType) Name() string

Name returns field type name

func (FieldType) PbFieldType

func (t FieldType) PbFieldType() (string, string)

PbFieldType represents FieldType corresponding schema pb type

func (FieldType) String

func (t FieldType) String() string

String returns field type

type Float16Vector

type Float16Vector []byte

FloatVector float32 vector wrapper.

func (Float16Vector) Dim

func (fv Float16Vector) Dim() int

Dim returns vector dimension.

func (Float16Vector) FieldType

func (fv Float16Vector) FieldType() FieldType

entity.FieldType returns coresponding field type.

func (Float16Vector) Serialize

func (fv Float16Vector) Serialize() []byte

func (Float16Vector) ToFloat32Vector

func (fv Float16Vector) ToFloat32Vector() FloatVector

type FloatVector

type FloatVector []float32

FloatVector float32 vector wrapper.

func (FloatVector) Dim

func (fv FloatVector) Dim() int

Dim returns vector dimension.

func (FloatVector) FieldType

func (fv FloatVector) FieldType() FieldType

entity.FieldType returns coresponding field type.

func (FloatVector) Serialize

func (fv FloatVector) Serialize() []byte

Serialize serializes vector into byte slice, used in search placeholder LittleEndian is used for convention

func (FloatVector) ToBFloat16Vector

func (fv FloatVector) ToBFloat16Vector() BFloat16Vector

SerializeToBFloat16Bytes serializes vector into bfloat16 byte slice, used in search placeholder

func (FloatVector) ToFloat16Vector

func (fv FloatVector) ToFloat16Vector() Float16Vector

type Function

type Function struct {
	Name        string
	Description string
	Type        FunctionType

	InputFieldNames  []string
	OutputFieldNames []string
	Params           map[string]string
	// contains filtered or unexported fields
}

func NewFunction

func NewFunction() *Function

func (*Function) ProtoMessage

func (f *Function) ProtoMessage() *schemapb.FunctionSchema

ProtoMessage returns corresponding schemapb.FunctionSchema

func (*Function) ReadProto

func (f *Function) ReadProto(p *schemapb.FunctionSchema) *Function

ReadProto parses proto Collection Schema

func (*Function) WithInputFields

func (f *Function) WithInputFields(inputFields ...string) *Function

func (*Function) WithName

func (f *Function) WithName(name string) *Function

func (*Function) WithOutputFields

func (f *Function) WithOutputFields(outputFields ...string) *Function

func (*Function) WithParam

func (f *Function) WithParam(key string, value any) *Function

func (*Function) WithType

func (f *Function) WithType(funcType FunctionType) *Function

type FunctionType

type FunctionType = schemapb.FunctionType

type GrantItem

type GrantItem struct {
	Object     string
	ObjectName string
	RoleName   string
	Grantor    string
	Privilege  string
}

type LoadState

type LoadState struct {
	State    LoadStateCode
	Progress int64
}

type LoadStateCode

type LoadStateCode commonpb.LoadState
const (
	// LoadStateNone      LoadStateCode = LoadStateCode(commonpb.LoadState)
	LoadStateLoading   LoadStateCode = LoadStateCode(commonpb.LoadState_LoadStateLoading)
	LoadStateLoaded    LoadStateCode = LoadStateCode(commonpb.LoadState_LoadStateLoaded)
	LoadStateUnloading LoadStateCode = LoadStateCode(commonpb.LoadState_LoadStateNotExist)
	LoadStateNotLoad   LoadStateCode = LoadStateCode(commonpb.LoadState_LoadStateNotLoad)
)

type MetricType

type MetricType string

MetricType metric type

const (
	L2             MetricType = "L2"
	IP             MetricType = "IP"
	COSINE         MetricType = "COSINE"
	HAMMING        MetricType = "HAMMING"
	JACCARD        MetricType = "JACCARD"
	TANIMOTO       MetricType = "TANIMOTO"
	SUBSTRUCTURE   MetricType = "SUBSTRUCTURE"
	SUPERSTRUCTURE MetricType = "SUPERSTRUCTURE"
	BM25           MetricType = "BM25"
)

Metric Constants

type Partition

type Partition struct {
	ID     int64  // partition id
	Name   string // partition name
	Loaded bool   // partition loaded
}

Partition represent partition meta in Milvus

type PrivilegeGroup

type PrivilegeGroup struct {
	GroupName  string
	Privileges []string
}

PrivilegeGroup is the entity model for custom privilege group.

type RBACMeta

type RBACMeta struct {
	Users           []*UserInfo
	Roles           []*Role
	RoleGrants      []*RoleGrants
	PrivilegeGroups []*PrivilegeGroup
}

type ReplicaGroup

type ReplicaGroup struct {
	ReplicaID     int64
	NodeIDs       []int64
	ShardReplicas []*ShardReplica
}

ReplicaGroup represents a replica group

type Role

type Role struct {
	RoleName   string
	Privileges []GrantItem
}

type RoleGrants

type RoleGrants struct {
	Object        string
	ObjectName    string
	RoleName      string
	GrantorName   string
	PrivilegeName string
	DbName        string
}

RoleGrants is the model for RBAC role description object.

type Schema

type Schema struct {
	CollectionName     string
	Description        string
	AutoID             bool
	Fields             []*Field
	EnableDynamicField bool
	Functions          []*Function
	// contains filtered or unexported fields
}

Schema represents schema info of collection in milvus

func NewSchema

func NewSchema() *Schema

NewSchema creates an empty schema object.

func (*Schema) PKField

func (s *Schema) PKField() *Field

PKField returns PK Field schema for this schema.

func (*Schema) PKFieldName

func (s *Schema) PKFieldName() string

PKFieldName returns pk field name for this schemapb.

func (*Schema) ProtoMessage

func (s *Schema) ProtoMessage() *schemapb.CollectionSchema

ProtoMessage returns corresponding server.CollectionSchema

func (*Schema) ReadProto

func (s *Schema) ReadProto(p *schemapb.CollectionSchema) *Schema

ReadProto parses proto Collection Schema

func (*Schema) WithAutoID

func (s *Schema) WithAutoID(autoID bool) *Schema

func (*Schema) WithDescription

func (s *Schema) WithDescription(desc string) *Schema

WithDescription sets the description value of schema, returns schema itself.

func (*Schema) WithDynamicFieldEnabled

func (s *Schema) WithDynamicFieldEnabled(dynamicEnabled bool) *Schema

func (*Schema) WithField

func (s *Schema) WithField(f *Field) *Schema

WithField adds a field into schema and returns schema itself.

func (*Schema) WithFunction

func (s *Schema) WithFunction(f *Function) *Schema

func (*Schema) WithName

func (s *Schema) WithName(name string) *Schema

WithName sets the name value of schema, returns schema itself.

type Segment

type Segment struct {
	ID           int64
	CollectionID int64
	ParititionID int64

	NumRows int64
	State   commonpb.SegmentState
}

Segment represent segment in milvus

func (Segment) Flushed

func (s Segment) Flushed() bool

Flushed indicates segment is flushed

type ShardReplica

type ShardReplica struct {
	LeaderID      int64
	NodesIDs      []int64
	DmChannelName string
}

ShardReplica represents a shard in the ReplicaGroup

type SparseEmbedding

type SparseEmbedding interface {
	Dim() int // the dimension
	Len() int // the actual items in this vector
	Get(idx int) (pos uint32, value float32, ok bool)
	Serialize() []byte
	FieldType() FieldType
}

func NewSliceSparseEmbedding

func NewSliceSparseEmbedding(positions []uint32, values []float32) (SparseEmbedding, error)

type Text

type Text string

func (Text) Dim

func (t Text) Dim() int

Dim returns vector dimension.

func (Text) FieldType

func (t Text) FieldType() FieldType

entity.FieldType returns coresponding field type.

func (Text) Serialize

func (t Text) Serialize() []byte

type User

type User struct {
	UserName string
	Roles    []string
}

type UserDescription

type UserDescription struct {
	Name  string
	Roles []string
}

UserDescription is the model for RBAC user description object.

type UserInfo

type UserInfo struct {
	UserDescription
	Password string
}

type Vector

type Vector interface {
	Dim() int
	Serialize() []byte
	FieldType() FieldType
}

Vector interface vector used int search

Jump to

Keyboard shortcuts

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