common

package
v2.6.17 Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: Apache-2.0 Imports: 15 Imported by: 7

Documentation

Index

Constants

View Source
const (
	// StartOfUserFieldID represents the starting ID of the user-defined field
	StartOfUserFieldID = 100

	// StartOfUserFunctionID represents the starting ID of the user-defined function
	StartOfUserFunctionID = 100
	// RowIDField is the ID of the RowID field reserved by the system
	RowIDField = 0

	// TimeStampField is the ID of the Timestamp field reserved by the system
	TimeStampField = 1

	// RowIDFieldName defines the name of the RowID field
	RowIDFieldName = "RowID"

	// TimeStampFieldName defines the name of the Timestamp field
	TimeStampFieldName = "Timestamp"

	// NamespaceFieldName defines the name of the Namespace field
	NamespaceFieldName = "$namespace_id"

	// MetaFieldName is the field name of dynamic schema
	MetaFieldName = "$meta"

	// DefaultShardsNum defines the default number of shards when creating a collection
	DefaultShardsNum = int32(1)

	// DefaultPartitionsWithPartitionKey defines the default number of partitions when use partition key
	DefaultPartitionsWithPartitionKey = int64(16)

	// InvalidPartitionID indicates that the partition is not specified. It will be set when the partitionName is empty
	InvalidPartitionID = int64(-1)

	// AllPartitionsID indicates data applies to all partitions.
	AllPartitionsID = int64(-1)

	// PkFilter values for SearchRequest/RetrieveRequest.PkFilter field.
	// Proxy sets this to let delegator skip plan unmarshal when no PK predicate exists.
	PkFilterNotChecked  = int32(0) // old proxy or not checked (backward compat)
	PkFilterHasPkFilter = int32(1) // plan contains optimizable PK predicate
	PkFilterNoPkFilter  = int32(2) // plan has no PK predicate, skip segment filter

	// InvalidFieldID indicates that the field does not exist . It will be set when the field is not found.
	InvalidFieldID = int64(-1)

	// NotRegisteredID means node is not registered into etcd.
	NotRegisteredID = int64(-1)

	// InvalidNodeID indicates that node is not valid in querycoord replica or shard cluster.
	InvalidNodeID = int64(-1)

	SystemFieldsNum = int64(2)
)
View Source
const (
	// Scalar index engine version tracks the *capability* of a Milvus node
	// (which index types / features it supports). It is reported by QueryNodes
	// in their session and aggregated by datacoord so that newly built indexes
	// are clamped to a version every node in the cluster can load — this is
	// what makes rolling upgrades safe.
	//
	// Engine version is distinct from the on-disk file format version
	// (see MILVUS_V3_FORMAT_VERSION in IndexEntryWriter.h). Multiple engine
	// versions can share the same file format; bumping the engine version
	// does not necessarily imply a format change.
	//
	// Scalar index engine version 3:
	// - Packed single-file index layout (file format v3) becomes the default
	// - HYBRID/AUTOINDEX high-cardinality scalar indexes switched from
	//   INVERTED to STL_SORT
	MinimalScalarIndexEngineVersion = int32(0)
	CurrentScalarIndexEngineVersion = int32(2)
	MaximumScalarIndexEngineVersion = int32(3)
)
View Source
const (
	// SegmentInsertLogPath storage path const for segment insert binlog.
	SegmentInsertLogPath = `insert_log`

	// SegmentDeltaLogPath storage path const for segment delta log.
	SegmentDeltaLogPath = `delta_log`

	// SegmentStatslogPath storage path const for segment stats log.
	SegmentStatslogPath = `stats_log`

	// SegmentIndexPath storage path const for segment index files.
	SegmentIndexPath = `index_files`

	// SegmentBm25LogPath storage path const for bm25 statistic
	SegmentBm25LogPath = `bm25_stats`

	// PartitionStatsPath storage path const for partition stats files
	PartitionStatsPath = `part_stats`

	// AnalyzeStatsPath storage path const for analyze.
	AnalyzeStatsPath = `analyze_stats`
	OffsetMapping    = `offset_mapping`
	Centroids        = "centroids"

	// TextIndexPath storage path const for text index
	TextIndexPath = "text_log"

	// JSONIndexPath storage path const for json index
	JSONIndexPath = "json_key_index_log"

	// JSONStatsPath storage path const for json stats
	JSONStatsPath = "json_stats"

	DefaultResourceGroupName = "__default_resource_group"
)
View Source
const (
	TopKKey         = "topk"
	SearchParamKey  = "search_param"
	SegmentNumKey   = "segment_num"
	WithFilterKey   = "with_filter"
	DataTypeKey     = "data_type"
	ChannelNumKey   = "channel_num"
	WithOptimizeKey = "with_optimize"
	CollectionKey   = "collection"
	RecallEvalKey   = "recall_eval"

	ParamsKey      = "params"
	IndexTypeKey   = "index_type"
	MetricTypeKey  = "metric_type"
	DimKey         = "dim"
	MaxLengthKey   = "max_length"
	MaxCapacityKey = "max_capacity"

	DropRatioBuildKey = "drop_ratio_build"

	IsSparseKey                       = "is_sparse"
	AutoIndexName                     = "AUTOINDEX"
	BitmapCardinalityLimitKey         = "bitmap_cardinality_limit"
	HybridLowCardinalityIndexTypeKey  = "hybrid_low_cardinality_index_type"
	HybridHighCardinalityIndexTypeKey = "hybrid_high_cardinality_index_type"
	IgnoreGrowing                     = "ignore_growing"
	ConsistencyLevel                  = "consistency_level"
	HintsKey                          = "hints"

	JSONCastTypeKey     = "json_cast_type"
	JSONPathKey         = "json_path"
	JSONCastFunctionKey = "json_cast_function"
)

Search, Index parameter keys

View Source
const (
	EnableAnalyzerKey = `enable_analyzer`
	AnalyzerParamKey  = `analyzer_params`
)

Doc-in-doc-out

View Source
const (
	CollectionTTLConfigKey      = "collection.ttl.seconds"
	CollectionAutoCompactionKey = "collection.autocompaction.enabled"
	CollectionDescription       = "collection.description"
	MaxTTLSeconds               = 3155760000 // 100 years

	// Deprecated: will be removed in the 3.0 after implementing ack sync up semantic.
	CollectionOnTruncatingKey = "collection.on.truncating" // when collection is on truncating, forbid the compaction of current collection.

	// Note:
	// Function output fields cannot be included in inserted data.
	// In particular, the `bm25` function output field is always disallowed
	// and is not controlled by this option.
	CollectionAllowInsertNonBM25FunctionOutputs = "collection.function.allowInsertNonBM25FunctionOutputs"

	// rate limit
	CollectionInsertRateMaxKey   = "collection.insertRate.max.mb"
	CollectionInsertRateMinKey   = "collection.insertRate.min.mb"
	CollectionDeleteRateMaxKey   = "collection.deleteRate.max.mb"
	CollectionDeleteRateMinKey   = "collection.deleteRate.min.mb"
	CollectionBulkLoadRateMaxKey = "collection.bulkLoadRate.max.mb"
	CollectionBulkLoadRateMinKey = "collection.bulkLoadRate.min.mb"
	CollectionQueryRateMaxKey    = "collection.queryRate.max.qps"
	CollectionQueryRateMinKey    = "collection.queryRate.min.qps"
	CollectionSearchRateMaxKey   = "collection.searchRate.max.vps"
	CollectionSearchRateMinKey   = "collection.searchRate.min.vps"
	CollectionDiskQuotaKey       = "collection.diskProtection.diskQuota.mb"

	PartitionDiskQuotaKey = "partition.diskProtection.diskQuota.mb"

	// database level properties
	DatabaseReplicaNumber       = "database.replica.number"
	DatabaseResourceGroups      = "database.resource_groups"
	DatabaseDiskQuotaKey        = "database.diskQuota.mb"
	DatabaseMaxCollectionsKey   = "database.max.collections"
	DatabaseForceDenyWritingKey = "database.force.deny.writing"
	DatabaseForceDenyReadingKey = "database.force.deny.reading"

	DatabaseForceDenyDDLKey           = "database.force.deny.ddl" // all ddl
	DatabaseForceDenyCollectionDDLKey = "database.force.deny.collectionDDL"
	DatabaseForceDenyPartitionDDLKey  = "database.force.deny.partitionDDL"
	DatabaseForceDenyIndexDDLKey      = "database.force.deny.index"
	DatabaseForceDenyFlushDDLKey      = "database.force.deny.flush"
	DatabaseForceDenyCompactionDDLKey = "database.force.deny.compaction"

	// collection level load properties
	CollectionReplicaNumber  = "collection.replica.number"
	CollectionResourceGroups = "collection.resource_groups"

	// CMEK related property keys, used in db and collection properties
	EncryptionEnabledKey = "cipher.enabled"
	EncryptionRootKeyKey = "cipher.key"
	EncryptionEzIDKey    = "cipher.ezID"
)
View Source
const (
	MmapEnabledKey             = "mmap.enabled"
	LazyLoadEnableKey          = "lazyload.enabled" // deprecated by warmup related params
	LoadPriorityKey            = "load_priority"
	PartitionKeyIsolationKey   = "partitionkey.isolation"
	FieldSkipLoadKey           = "field.skipLoad"
	IndexOffsetCacheEnabledKey = "indexoffsetcache.enabled"
	ReplicateIDKey             = "replicate.id"
	ReplicateEndTSKey          = "replicate.endTS"
	IndexNonEncoding           = "index.nonEncoding"
	EnableDynamicSchemaKey     = `dynamicfield.enabled`
	NamespaceEnabledKey        = "namespace.enabled"

	// timezone releated
	TimezoneKey             = "timezone"
	AllowInsertAutoIDKey    = "allow_insert_auto_id"
	DisableFuncRuntimeCheck = "disable_func_runtime_check"

	// query mode
	QueryModeKey       = "query_mode"
	QueryModeLargeTopK = "large_topk"
	ValidQueryModes    = QueryModeLargeTopK // comma-separated if more modes added later

	// warmup related
	WarmupKey            = "warmup"
	WarmupScalarFieldKey = "warmup.scalarField"
	WarmupScalarIndexKey = "warmup.scalarIndex"
	WarmupVectorFieldKey = "warmup.vectorField"
	WarmupVectorIndexKey = "warmup.vectorIndex"
	WarmupDisable        = "disable"
	WarmupSync           = "sync"
)

common properties

View Source
const (
	PropertiesKey        string = "properties"
	TraceIDKey           string = "uber-trace-id"
	ClientRequestMsecKey string = "client-request-unixmsec"
)
View Source
const (
	TszYear        string = "year"
	TszMonth       string = "month"
	TszDay         string = "day"
	TszHour        string = "hour"
	TszMinute      string = "minute"
	TszSecond      string = "second"
	TszMicrosecond string = "microsecond"
)

Timestamptz field

View Source
const DefaultTimezone = "UTC"
View Source
const (
	ExprUseJSONStatsKey = "expr_use_json_stats"
)

expr query params

View Source
const (
	FieldDescriptionKey = "field.description"
)

Field properties key

View Source
const (
	// Version 3: metadata moved to separate meta.json file (instead of parquet metadata)
	JSONStatsDataFormatVersion = 3
)
View Source
const (
	// LatestVerision is the magic number for watch latest revision
	LatestRevision = int64(-1)
)

Variables

Endian is type alias of binary.LittleEndian. Milvus uses little endian by default.

View Source
var ErrNodeIDNotMatch = errors.New("target node id not match")

ErrNodeIDNotMatch stands for the error that grpc target id and node session id not match.

View Source
var FieldNameKeywords = map[string]struct{}{
	"$meta":              {},
	"like":               {},
	"exists":             {},
	"EXISTS":             {},
	"and":                {},
	"or":                 {},
	"not":                {},
	"in":                 {},
	"json_contains":      {},
	"JSON_CONTAINS":      {},
	"json_contains_all":  {},
	"JSON_CONTAINS_ALL":  {},
	"json_contains_any":  {},
	"JSON_CONTAINS_ANY":  {},
	"array_contains":     {},
	"ARRAY_CONTAINS":     {},
	"array_contains_all": {},
	"ARRAY_CONTAINS_ALL": {},
	"array_contains_any": {},
	"ARRAY_CONTAINS_ANY": {},
	"array_length":       {},
	"ARRAY_LENGTH":       {},
	"true":               {},
	"True":               {},
	"TRUE":               {},
	"false":              {},
	"False":              {},
	"FALSE":              {},
	"text_match":         {},
	"TEXT_MATCH":         {},
	"phrase_match":       {},
	"PHRASE_MATCH":       {},
	"random_sample":      {},
	"RANDOM_SAMPLE":      {},
}
View Source
var Version semver.Version

Version current version for session

Functions

func AllocAutoID added in v2.5.19

func AllocAutoID(allocFunc func(uint32) (int64, int64, error), rowNum uint32, clusterID uint64) (int64, int64, error)

func ClampScalarIndexVersion added in v2.6.17

func ClampScalarIndexVersion(v int32) int32

ClampScalarIndexVersion clamps the given scalar index version to MaximumScalarIndexEngineVersion. Used by DataNode to ensure the version written back to metadata does not exceed what the cluster can handle.

func CloneMap added in v2.6.11

func CloneMap[K comparable, V any](m map[K]V) map[K]V

CloneMap clones a map with comparable keys

func CollectionLevelReplicaNumber

func CollectionLevelReplicaNumber(kvs []*commonpb.KeyValuePair) (int64, error)

func CollectionLevelResourceGroups

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

func ConvertWKBToWKT added in v2.5.26

func ConvertWKBToWKT(wkbData []byte) (string, error)

func ConvertWKTToWKB added in v2.5.20

func ConvertWKTToWKB(wktStr string) ([]byte, error)

func DatabaseLevelReplicaNumber

func DatabaseLevelReplicaNumber(kvs []*commonpb.KeyValuePair) (int64, error)

func DatabaseLevelResourceGroups

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

func FieldHasMmapKey

func FieldHasMmapKey(schema *schemapb.CollectionSchema, fieldID int64) bool

func FieldHasWarmupKey added in v2.6.11

func FieldHasWarmupKey(schema *schemapb.CollectionSchema, fieldID int64) bool

FieldHasWarmupKey checks if a field has warmup key set in its TypeParams

func GetCollectionAllowInsertNonBM25FunctionOutputs added in v2.6.3

func GetCollectionAllowInsertNonBM25FunctionOutputs(kvs []*commonpb.KeyValuePair) bool

func GetCollectionLoadFields

func GetCollectionLoadFields(schema *schemapb.CollectionSchema, skipDynamicField bool) []int64

GetCollectionLoadFields returns the load field ids according to the type params.

func GetCollectionTTL added in v2.6.9

func GetCollectionTTL(kvs []*commonpb.KeyValuePair, defaultValue time.Duration) (time.Duration, error)

func GetCollectionTTLFromMap added in v2.6.9

func GetCollectionTTLFromMap(kvs map[string]string, defaultValue time.Duration) (time.Duration, error)

func GetIndexType

func GetIndexType(indexParams []*commonpb.KeyValuePair) string

func GetInt64Value added in v2.6.8

func GetInt64Value(kvs []*commonpb.KeyValuePair, key string) (result int64, parseErr error, exist bool)

func GetQueryMode added in v2.6.14

func GetQueryMode(kvs ...*commonpb.KeyValuePair) string

GetQueryMode extracts the query_mode value from properties. Returns empty string if not set.

func GetReplicateEndTS

func GetReplicateEndTS(kvs []*commonpb.KeyValuePair) (uint64, bool)

func GetReplicateID

func GetReplicateID(kvs []*commonpb.KeyValuePair) (string, bool)

func GetStringValue added in v2.6.8

func GetStringValue(kvs []*commonpb.KeyValuePair, key string) (result string, exist bool)

func GetWarmupPolicy added in v2.6.11

func GetWarmupPolicy(kvs ...*commonpb.KeyValuePair) (string, bool)

GetWarmupPolicy returns the warmup policy value and whether it exists from key-value pairs

func GetWarmupPolicyByKey added in v2.6.11

func GetWarmupPolicyByKey(key string, kvs ...*commonpb.KeyValuePair) (string, bool)

GetWarmupPolicyByKey returns the warmup policy for a specific key from key-value pairs

func HasLazyload

func HasLazyload(props []*commonpb.KeyValuePair) bool

func IsAllowInsertAutoID added in v2.5.19

func IsAllowInsertAutoID(kvs ...*commonpb.KeyValuePair) (bool, bool)

func IsCollectionLazyLoadEnabled

func IsCollectionLazyLoadEnabled(kvs ...*commonpb.KeyValuePair) bool

func IsCollectionWarmupKey added in v2.6.11

func IsCollectionWarmupKey(key string) bool

IsCollectionWarmupKey checks if a key is a collection/table-level warmup key

func IsDisableFuncRuntimeCheck added in v2.6.8

func IsDisableFuncRuntimeCheck(kvs ...*commonpb.KeyValuePair) (bool, error)

func IsEnableDynamicSchema added in v2.6.2

func IsEnableDynamicSchema(kvs []*commonpb.KeyValuePair) (found bool, value bool, err error)

func IsFieldWarmupKey added in v2.6.11

func IsFieldWarmupKey(key string) bool

IsFieldWarmupKey checks if a key is the field-level warmup key

func IsIgnorableError

func IsIgnorableError(err error) bool

func IsMmapDataEnabled

func IsMmapDataEnabled(kvs ...*commonpb.KeyValuePair) (bool, bool)

func IsMmapIndexEnabled

func IsMmapIndexEnabled(kvs ...*commonpb.KeyValuePair) (bool, bool)

func IsPartitionKeyIsolationKvEnabled

func IsPartitionKeyIsolationKvEnabled(kvs ...*commonpb.KeyValuePair) (bool, error)

func IsPartitionKeyIsolationPropEnabled

func IsPartitionKeyIsolationPropEnabled(props map[string]string) (bool, error)

func IsQueryModeKeyExists added in v2.6.14

func IsQueryModeKeyExists(kvs ...*commonpb.KeyValuePair) bool

IsQueryModeKeyExists checks if the query_mode key exists in the key-value pairs.

func IsQueryModeLargeTopK added in v2.6.14

func IsQueryModeLargeTopK(kvs ...*commonpb.KeyValuePair) bool

IsQueryModeLargeTopK checks if query_mode is set to "large_topk".

func IsReplicateEnabled

func IsReplicateEnabled(kvs []*commonpb.KeyValuePair) (bool, bool)

func IsSystemField

func IsSystemField(fieldID int64) bool

func IsWarmupKey added in v2.6.11

func IsWarmupKey(key string) bool

IsWarmupKey checks if a key is any of the warmup-related keys

func MapEqual added in v2.6.11

func MapEqual[K comparable, V comparable](m1, m2 map[K]V) bool

MapEqual compares two maps for equality

func NewIgnorableError

func NewIgnorableError(err error) error

func ParseNamespaceProp added in v2.6.2

func ParseNamespaceProp(props ...*commonpb.KeyValuePair) (value bool, has bool, err error)

func ShouldFieldBeLoaded

func ShouldFieldBeLoaded(kvs []*commonpb.KeyValuePair) (bool, error)

func ValidateAutoIndexMmapConfig

func ValidateAutoIndexMmapConfig(autoIndexConfigEnable, isVectorField bool, indexParams map[string]string) error

func ValidateQueryMode added in v2.6.14

func ValidateQueryMode(kvs ...*commonpb.KeyValuePair) error

ValidateQueryMode validates the query_mode value. Returns nil if the value is valid or if query_mode is not set.

func ValidateWarmupPolicy added in v2.6.11

func ValidateWarmupPolicy(value string) error

ValidateWarmupPolicy validates that the warmup policy value is valid

func WrapNodeIDNotMatchError

func WrapNodeIDNotMatchError(targetID, nodeID int64) error

WrapNodeIDNotMatchError wraps `ErrNodeIDNotMatch` with targetID and sessionID.

func WrapNodeIDNotMatchMsg

func WrapNodeIDNotMatchMsg(targetID, nodeID int64) string

WrapNodeIDNotMatchMsg fmt error msg with `ErrNodeIDNotMatch`, targetID and sessionID.

Types

type ByteSlice

type ByteSlice []byte

func CloneByteSlice

func CloneByteSlice(s ByteSlice) ByteSlice

func (ByteSlice) Clone

func (s ByteSlice) Clone() ByteSlice

func (ByteSlice) Equal

func (s ByteSlice) Equal(other ByteSlice) bool

type ClusterStatus

type ClusterStatus struct {
	Health  bool       `json:"health_status"`
	Reason  string     `json:"unhealthy_reason"`
	Members []EPHealth `json:"members_health"`
}

type EPHealth

type EPHealth struct {
	EP     string `json:"endpoint"`
	Health bool   `json:"health"`
	Reason string `json:"error,omitempty"`
}

type IgnorableError

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

func (*IgnorableError) Error

func (i *IgnorableError) Error() string

type Int64Tuple

type Int64Tuple struct {
	Key, Value int64
}

type KeyDataPairs

type KeyDataPairs []*commonpb.KeyDataPair

func CloneKeyDataPairs

func CloneKeyDataPairs(pairs KeyDataPairs) KeyDataPairs

func (KeyDataPairs) Clone

func (pairs KeyDataPairs) Clone() KeyDataPairs

func (KeyDataPairs) Equal

func (pairs KeyDataPairs) Equal(other KeyDataPairs) bool

func (KeyDataPairs) ToMap

func (pairs KeyDataPairs) ToMap() map[string][]byte

type KeyValuePairs

type KeyValuePairs []*commonpb.KeyValuePair

func CloneKeyValuePairs

func CloneKeyValuePairs(pairs KeyValuePairs) KeyValuePairs

func NewKeyValuePairs added in v2.6.6

func NewKeyValuePairs(kvs map[string]string) KeyValuePairs

NewKeyValuePairs creates a new KeyValuePairs from a map[string]string.

func (KeyValuePairs) Clone

func (pairs KeyValuePairs) Clone() KeyValuePairs

func (KeyValuePairs) Equal

func (pairs KeyValuePairs) Equal(other KeyValuePairs) bool

func (KeyValuePairs) ToMap

func (pairs KeyValuePairs) ToMap() map[string]string

type MQClusterStatus

type MQClusterStatus struct {
	ClusterStatus
	MqType string `json:"mq_type"`
}

type MetaClusterStatus

type MetaClusterStatus struct {
	ClusterStatus
	MetaType string `json:"meta_type"`
}

type StringList

type StringList []string

func CloneStringList

func CloneStringList(l StringList) StringList

func (StringList) Clone

func (l StringList) Clone() StringList

func (StringList) Equal

func (l StringList) Equal(other StringList) bool

Jump to

Keyboard shortcuts

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