client

package
v2.0.0-...-cf564f5 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

Package client provides milvus client functions

Index

Constants

View Source
const (
	StrongTimestamp     uint64 = 0
	EventuallyTimestamp uint64 = 1
	BoundedTimestamp    uint64 = 2
)

Magical timestamps for communicating with server

View Source
const (
	RetryOnRateLimit ctxKey = iota
)

Variables

View Source
var (
	//ErrClientNotReady error indicates client not ready
	ErrClientNotReady = errors.New("client not ready")
	//ErrStatusNil error indicates response has nil status
	ErrStatusNil = errors.New("response status is nil")
)
View Source
var DefaultGrpcOpts = []grpc.DialOption{
	grpc.WithBlock(),
	grpc.WithKeepaliveParams(keepalive.ClientParameters{
		Time:                5 * time.Second,
		Timeout:             10 * time.Second,
		PermitWithoutStream: true,
	}),
	grpc.WithConnectParams(grpc.ConnectParams{
		Backoff: backoff.Config{
			BaseDelay:  100 * time.Millisecond,
			Multiplier: 1.6,
			Jitter:     0.2,
			MaxDelay:   3 * time.Second,
		},
		MinConnectTimeout: 3 * time.Second,
	}),
}
View Source
var (
	// ErrFieldTypeNotMatch error for field type not match
	ErrFieldTypeNotMatch = errors.New("field type not matched")
)
View Source
var MaxBackOff = 60 * time.Second
View Source
var MetaCache = metaCache{
	// contains filtered or unexported fields
}

Functions

func AuthenticationInterceptor

func AuthenticationInterceptor(ctx context.Context, username, password string) context.Context

AuthenticationInterceptor appends credential into context metadata

func BadRequestStatus

func BadRequestStatus() (*common.Status, error)

func BadStatus

func BadStatus() (*common.Status, error)

func CreateAuthenticationStreamInterceptor

func CreateAuthenticationStreamInterceptor(username, password string) grpc.StreamClientInterceptor

CreateAuthenticationStreamInterceptor creates a stream interceptor for authentication

func CreateAuthenticationUnaryInterceptor

func CreateAuthenticationUnaryInterceptor(username, password string) grpc.UnaryClientInterceptor

CreateAuthenticationUnaryInterceptor creates a unary interceptor for authentication

func PKs2Expr

func PKs2Expr(backName string, ids entity.Column) string

func RetryOnRateLimitInterceptor

func RetryOnRateLimitInterceptor(maxRetry uint, backoffFunc grpc_retry.BackoffFuncContext) grpc.UnaryClientInterceptor

RetryOnRateLimitInterceptor returns a new retrying unary client interceptor.

func SetFieldValue

func SetFieldValue(field *entity.Field, f reflect.Value, fieldData *schema.FieldData, idx int) error

SetFieldValue set row field value with reflection

func SuccessStatus

func SuccessStatus() (*common.Status, error)

func WithClientRequestID

func WithClientRequestID(ctx context.Context, reqID string) context.Context

func WithDebugLogLevel

func WithDebugLogLevel(ctx context.Context) context.Context

func WithErrorLogLevel

func WithErrorLogLevel(ctx context.Context) context.Context

func WithInfoLogLevel

func WithInfoLogLevel(ctx context.Context) context.Context

func WithWarnLogLevel

func WithWarnLogLevel(ctx context.Context) context.Context

Types

type BulkInsertOption

type BulkInsertOption func(request *server.ImportRequest)

BulkInsertOption is an option that is used to modify ImportRequest

func WithEndTs

func WithEndTs(endTs int64) BulkInsertOption

WithEndTs specifies a specific endTs

func WithStartTs

func WithStartTs(startTs int64) BulkInsertOption

WithStartTs specifies a specific startTs

type Client

type Client interface {
	// Close close the remaining connection resources
	Close() error

	// ListCollections list collections from connection
	ListCollections(ctx context.Context) ([]*entity.Collection, error)
	// CreateCollection create collection using provided schema
	CreateCollection(ctx context.Context, schema *entity.Schema, shardsNum int32, opts ...CreateCollectionOption) error
	// DescribeCollection describe collection meta
	DescribeCollection(ctx context.Context, collName string) (*entity.Collection, error)
	// DropCollection drop the specified collection
	DropCollection(ctx context.Context, collName string) error
	// GetCollectionStatistics get collection statistics
	GetCollectionStatistics(ctx context.Context, collName string) (map[string]string, error)
	// LoadCollection load collection into memory
	LoadCollection(ctx context.Context, collName string, async bool, opts ...LoadCollectionOption) error
	// ReleaseCollection release loaded collection
	ReleaseCollection(ctx context.Context, collName string) error
	// HasCollection check whether collection exists
	HasCollection(ctx context.Context, collName string) (bool, error)

	// CreateAlias creates an alias for collection
	CreateAlias(ctx context.Context, collName string, alias string) error
	// DropAlias drops the specified Alias
	DropAlias(ctx context.Context, alias string) error
	// AlterAlias changes collection alias to provided alias
	AlterAlias(ctx context.Context, collName string, alias string) error

	// GetReplicas gets the replica groups as well as their querynodes and shards information
	GetReplicas(ctx context.Context, collName string) ([]*entity.ReplicaGroup, error)

	// CreateCredential create new user and password
	CreateCredential(ctx context.Context, username string, password string) error
	// UpdateCredential update password for a user
	UpdateCredential(ctx context.Context, username string, oldPassword string, newPassword string) error
	// DeleteCredential delete a user
	DeleteCredential(ctx context.Context, username string) error
	// ListCredUsers list all usernames
	ListCredUsers(ctx context.Context) ([]string, error)

	// CreatePartition create partition for collection
	CreatePartition(ctx context.Context, collName string, partitionName string) error
	// DropPartition drop partition from collection
	DropPartition(ctx context.Context, collName string, partitionName string) error
	// ShowPartitions list all partitions from collection
	ShowPartitions(ctx context.Context, collName string) ([]*entity.Partition, error)
	// HasPartition check whether partition exists in collection
	HasPartition(ctx context.Context, collName string, partitionName string) (bool, error)
	// LoadPartitions load partitions into memory
	LoadPartitions(ctx context.Context, collName string, partitionNames []string, async bool) error
	// ReleasePartitions release partitions
	ReleasePartitions(ctx context.Context, collName string, partitionNames []string) error

	// -- segment --
	GetPersistentSegmentInfo(ctx context.Context, collName string) ([]*entity.Segment, error)

	// CreateIndex create index for field of specified collection
	// currently index naming is not supported, so only one index on vector field is supported
	CreateIndex(ctx context.Context, collName string, fieldName string, idx entity.Index, async bool, opts ...IndexOption) error
	// DescribeIndex describe index on collection
	// currently index naming is not supported, so only one index on vector field is supported
	DescribeIndex(ctx context.Context, collName string, fieldName string, opts ...IndexOption) ([]entity.Index, error)
	// DropIndex drop index from collection with specified field name
	DropIndex(ctx context.Context, collName string, fieldName string, opts ...IndexOption) error
	// GetIndexState get index state with specified collection and field name
	// index naming is not supported yet
	GetIndexState(ctx context.Context, collName string, fieldName string, opts ...IndexOption) (entity.IndexState, error)

	// Insert column-based data into collection, returns id column values
	Insert(ctx context.Context, collName string, partitionName string, columns ...entity.Column) (entity.Column, error)
	// Flush flush collection, specified
	Flush(ctx context.Context, collName string, async bool) error
	// Delete deletes entries with bool expression
	Delete(ctx context.Context, collName string, partitionName string, expr string) error
	// DeleteByPks deletes entries related to provided primary keys
	DeleteByPks(ctx context.Context, collName string, partitionName string, ids entity.Column) error
	// Search search with bool expression
	Search(ctx context.Context, collName string, partitions []string,
		expr string, outputFields []string, vectors []entity.Vector, vectorField string, metricType entity.MetricType, topK int, sp entity.SearchParam, opts ...SearchQueryOptionFunc) ([]SearchResult, error)
	// QueryByPks query record by specified primary key(s).
	QueryByPks(ctx context.Context, collectionName string, partitionNames []string, ids entity.Column, outputFields []string, opts ...SearchQueryOptionFunc) ([]entity.Column, error)
	// Query performs query records with boolean expression.
	Query(ctx context.Context, collectionName string, partitionNames []string, expr string, outputFields []string, opts ...SearchQueryOptionFunc) ([]entity.Column, error)

	// CalcDistance calculate the distance between vectors specified by ids or provided
	CalcDistance(ctx context.Context, collName string, partitions []string,
		metricType entity.MetricType, opLeft, opRight entity.Column) (entity.Column, error)

	// CreateCollectionByRow create collection by row
	CreateCollectionByRow(ctx context.Context, row entity.Row, shardNum int32) error
	// InsertByRows insert by rows
	InsertByRows(ctx context.Context, collName string, paritionName string, rows []entity.Row) (entity.Column, error)

	// ManualCompaction triggers a compaction on provided collection
	ManualCompaction(ctx context.Context, collName string, toleranceDuration time.Duration) (int64, error)
	// GetCompactionState get compaction state of provided compaction id
	GetCompactionState(ctx context.Context, id int64) (entity.CompactionState, error)
	// GetCompactionStateWithPlans get compaction state with plans of provided compaction id
	GetCompactionStateWithPlans(ctx context.Context, id int64) (entity.CompactionState, []entity.CompactionPlan, error)

	// BulkInsert import data files(json, numpy, etc.) on MinIO/S3 storage, read and parse them into sealed segments
	BulkInsert(ctx context.Context, collName string, partitionName string, files []string, opts ...BulkInsertOption) (int64, error)
	// GetBulkInsertState checks import task state
	GetBulkInsertState(ctx context.Context, taskID int64) (*entity.BulkInsertTaskState, error)
	// ListBulkInsertTasks list state of all import tasks
	ListBulkInsertTasks(ctx context.Context, collName string, limit int64) ([]*entity.BulkInsertTaskState, error)

	// CreateRole creates a role entity in Milvus.
	CreateRole(ctx context.Context, name string) error
	// DropRole drops a role entity in Milvus.
	DropRole(ctx context.Context, name string) error
	// AddUserRole adds one role for user.
	AddUserRole(ctx context.Context, username string, role string) error
	// RemoveUserRole removes one role from user.
	RemoveUserRole(ctx context.Context, username string, role string) error
	// ListRoles lists the role objects in system.
	ListRoles(ctx context.Context) ([]entity.Role, error)
	// ListUsers lists the user objects in system.
	ListUsers(ctx context.Context) ([]entity.User, error)
	// Grant adds object privileged for role.
	Grant(ctx context.Context, role string, objectType entity.PriviledgeObjectType, object string) error
	// Revoke removes privilege from role.
	Revoke(ctx context.Context, role string, objectType entity.PriviledgeObjectType, object string) error

	// GetLoadingProgress get the collection or partitions loading progress
	GetLoadingProgress(ctx context.Context, collectionName string, partitionNames []string) (int64, error)
	// GetLoadState get the collection or partitions load state
	GetLoadState(ctx context.Context, collectionName string, partitionNames []string) (entity.LoadState, error)

	// GetVersion get milvus version
	GetVersion(ctx context.Context) (string, error)
}

Client is the interface used to communicate with Milvus

func NewDefaultGrpcClient

func NewDefaultGrpcClient(ctx context.Context, addr string) (Client, error)

func NewDefaultGrpcClientWithAuth

func NewDefaultGrpcClientWithAuth(ctx context.Context, addr, username, password string) (Client, error)

NewDefaultGrpcClientWithAuth disable transport security

func NewDefaultGrpcClientWithTLSAuth

func NewDefaultGrpcClientWithTLSAuth(ctx context.Context, addr, username, password string) (Client, error)

NewDefaultGrpcClientWithTLSAuth enable transport security

func NewDefaultGrpcClientWithURI

func NewDefaultGrpcClientWithURI(ctx context.Context, uri, username, password string) (Client, error)

func NewGrpcClient

func NewGrpcClient(ctx context.Context, addr string, dialOptions ...grpc.DialOption) (Client, error)

NewGrpcClient create client with grpc addr the `Connect` API will be called for you dialOptions contains the dial option(s) that control the grpc dialing process

type CreateCollectionOption

type CreateCollectionOption func(*server.CreateCollectionRequest)

CreateCollectionOption is an option that is used to modify CreateCollectionRequest

func WithCollectionProperty

func WithCollectionProperty(key string, value string) CreateCollectionOption

func WithConsistencyLevel

func WithConsistencyLevel(cl entity.ConsistencyLevel) CreateCollectionOption

WithConsistencyLevel specifies a specific ConsistencyLevel, rather than using the default ReaderProperties.

type ErrCollectionNotExists

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

ErrCollectionNotExists indicates the collection with specified collection name does not exist

func (ErrCollectionNotExists) Error

func (e ErrCollectionNotExists) Error() string

Error implement error

type ErrPartitionNotExists

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

ErrPartitionNotExists indicates the partition of collection does not exist

func (ErrPartitionNotExists) Error

func (e ErrPartitionNotExists) Error() string

Error implement error

type ErrServiceFailed

type ErrServiceFailed error

ErrServiceFailed indicates error returns from milvus Service

type GrpcClient

type GrpcClient struct {
	Conn    *grpc.ClientConn           // grpc connection instance
	Service server.MilvusServiceClient // Service client stub
}

GrpcClient, uses default grpc Service definition to connect with Milvus2.0

func (*GrpcClient) AddUserRole

func (c *GrpcClient) AddUserRole(ctx context.Context, username string, role string) error

AddUserRole adds one role for user.

func (*GrpcClient) AlterAlias

func (c *GrpcClient) AlterAlias(ctx context.Context, collName string, alias string) error

AlterAlias changes collection alias to provided alias

func (*GrpcClient) BulkInsert

func (c *GrpcClient) BulkInsert(ctx context.Context, collName string, partitionName string, files []string, opts ...BulkInsertOption) (int64, error)

BulkInsert data files(json, numpy, etc.) on MinIO/S3 storage, read and parse them into sealed segments

func (*GrpcClient) CalcDistance

func (c *GrpcClient) CalcDistance(ctx context.Context, collName string, partitions []string,
	metricType entity.MetricType, opLeft, opRight entity.Column) (entity.Column, error)

func (*GrpcClient) Close

func (c *GrpcClient) Close() error

Close close the connection

func (*GrpcClient) CreateAlias

func (c *GrpcClient) CreateAlias(ctx context.Context, collName string, alias string) error

CreateAlias creates an alias for collection

func (*GrpcClient) CreateCollection

func (c *GrpcClient) CreateCollection(ctx context.Context, collSchema *entity.Schema, shardNum int32, opts ...CreateCollectionOption) error

CreateCollection create collection with specified schema

func (*GrpcClient) CreateCollectionByRow

func (c *GrpcClient) CreateCollectionByRow(ctx context.Context, row entity.Row, shardNum int32) error

CreateCollectionByRow create collection by row

func (*GrpcClient) CreateCredential

func (c *GrpcClient) CreateCredential(ctx context.Context, username string, password string) error

CreateCredential create new user and password

func (*GrpcClient) CreateIndex

func (c *GrpcClient) CreateIndex(ctx context.Context, collName string, fieldName string,
	idx entity.Index, async bool, opts ...IndexOption) error

CreateIndex create index for collection Deprecated please use CreateIndexV2 instead.

func (*GrpcClient) CreatePartition

func (c *GrpcClient) CreatePartition(ctx context.Context, collName string, partitionName string) error

CreatePartition create partition for collection

func (*GrpcClient) CreateRole

func (c *GrpcClient) CreateRole(ctx context.Context, name string) error

CreateRole creates a role entity in Milvus.

func (*GrpcClient) Delete

func (c *GrpcClient) Delete(ctx context.Context, collName string, partitionName string, expr string) error

Delete deletes entries with bool expression

func (*GrpcClient) DeleteByPks

func (c *GrpcClient) DeleteByPks(ctx context.Context, collName string, partitionName string, ids entity.Column) error

DeleteByPks deletes entries related to provided primary keys

func (*GrpcClient) DeleteCredential

func (c *GrpcClient) DeleteCredential(ctx context.Context, username string) error

DeleteCredential delete a user

func (*GrpcClient) DescribeCollection

func (c *GrpcClient) DescribeCollection(ctx context.Context, collName string) (*entity.Collection, error)

DescribeCollection describe the collection by name

func (*GrpcClient) DescribeIndex

func (c *GrpcClient) DescribeIndex(ctx context.Context, collName string, fieldName string, opts ...IndexOption) ([]entity.Index, error)

DescribeIndex describe index Deprecate please use DescribeIndexV2 instead.

func (*GrpcClient) DropAlias

func (c *GrpcClient) DropAlias(ctx context.Context, alias string) error

DropAlias drops the specified Alias

func (*GrpcClient) DropCollection

func (c *GrpcClient) DropCollection(ctx context.Context, collName string) error

DropCollection drop collection by name

func (*GrpcClient) DropIndex

func (c *GrpcClient) DropIndex(ctx context.Context, collName string, fieldName string, opts ...IndexOption) error

DropIndex drop index from collection Deprecate please use DropIndexV2 instead.

func (*GrpcClient) DropPartition

func (c *GrpcClient) DropPartition(ctx context.Context, collName string, partitionName string) error

DropPartition drop partition from collection

func (*GrpcClient) DropRole

func (c *GrpcClient) DropRole(ctx context.Context, name string) error

DropRole drops a role entity in Milvus.

func (*GrpcClient) Flush

func (c *GrpcClient) Flush(ctx context.Context, collName string, async bool) error

Flush force collection to flush memory records into storage in sync mode, flush will wait all segments to be flushed

func (*GrpcClient) GetBulkInsertState

func (c *GrpcClient) GetBulkInsertState(ctx context.Context, taskID int64) (*entity.BulkInsertTaskState, error)

GetBulkInsertState checks import task state

func (*GrpcClient) GetCollectionStatistics

func (c *GrpcClient) GetCollectionStatistics(ctx context.Context, collName string) (map[string]string, error)

GetCollectionStatistcis show collection statistics

func (*GrpcClient) GetCompactionState

func (c *GrpcClient) GetCompactionState(ctx context.Context, id int64) (entity.CompactionState, error)

GetCompactionState get compaction state of provided compaction id

func (*GrpcClient) GetCompactionStateWithPlans

func (c *GrpcClient) GetCompactionStateWithPlans(ctx context.Context, id int64) (entity.CompactionState, []entity.CompactionPlan, error)

GetCompactionStateWithPlans get compaction state with plans of provided compaction id

func (*GrpcClient) GetIndexBuildProgress

func (c *GrpcClient) GetIndexBuildProgress(ctx context.Context, collName string, fieldName string, opts ...IndexOption) (total, indexed int64, err error)

GetIndexBuildProgress get index building progress Deprecate please use DescribeIndexV2 instead.

func (*GrpcClient) GetIndexState

func (c *GrpcClient) GetIndexState(ctx context.Context, collName string, fieldName string, opts ...IndexOption) (entity.IndexState, error)

GetIndexState get index state Deprecate please use DescribeIndexV2 instead.

func (*GrpcClient) GetLoadState

func (c *GrpcClient) GetLoadState(ctx context.Context, collName string, partitionNames []string) (entity.LoadState, error)

GetLoadState get the collection or partitions load state

func (*GrpcClient) GetLoadingProgress

func (c *GrpcClient) GetLoadingProgress(ctx context.Context, collName string, partitionNames []string) (int64, error)

GetLoadingProgress get the collection or partitions loading progress

func (*GrpcClient) GetPersistentSegmentInfo

func (c *GrpcClient) GetPersistentSegmentInfo(ctx context.Context, collName string) ([]*entity.Segment, error)

GetPersistentSegmentInfo get persistent segment info

func (*GrpcClient) GetQuerySegmentInfo

func (c *GrpcClient) GetQuerySegmentInfo(ctx context.Context, collName string) ([]*entity.Segment, error)

GetQuerySegmentInfo get query query cluster segment loaded info

func (*GrpcClient) GetReplicas

func (c *GrpcClient) GetReplicas(ctx context.Context, collName string) ([]*entity.ReplicaGroup, error)

GetReplicas gets the replica groups as well as their querynodes and shards information

func (*GrpcClient) GetVersion

func (c *GrpcClient) GetVersion(ctx context.Context) (string, error)

func (*GrpcClient) Grant

func (c *GrpcClient) Grant(ctx context.Context, role string, objectType entity.PriviledgeObjectType, object string) error

Grant adds object privileged for role.

func (*GrpcClient) HasCollection

func (c *GrpcClient) HasCollection(ctx context.Context, collName string) (bool, error)

HasCollection check whether collection name exists

func (*GrpcClient) HasPartition

func (c *GrpcClient) HasPartition(ctx context.Context, collName string, partitionName string) (bool, error)

HasPartition check whether specified partition exists

func (*GrpcClient) Insert

func (c *GrpcClient) Insert(ctx context.Context, collName string, partitionName string, columns ...entity.Column) (entity.Column, error)

Insert Index into collection with column-based format collName is the collection name partitionName is the partition to insert, if not specified(empty), default partition will be used columns are slice of the column-based data

func (*GrpcClient) InsertByRows

func (c *GrpcClient) InsertByRows(ctx context.Context, collName string, partitionName string,
	rows []entity.Row) (entity.Column, error)

InsertByRows insert by rows

func (*GrpcClient) ListBulkInsertTasks

func (c *GrpcClient) ListBulkInsertTasks(ctx context.Context, collName string, limit int64) ([]*entity.BulkInsertTaskState, error)

ListBulkInsertTasks list state of all import tasks

func (*GrpcClient) ListCollections

func (c *GrpcClient) ListCollections(ctx context.Context) ([]*entity.Collection, error)

ListCollections list collections from connection Note that schema info are not provided in collection list

func (*GrpcClient) ListCredUsers

func (c *GrpcClient) ListCredUsers(ctx context.Context) ([]string, error)

ListCredUsers list all usernames

func (*GrpcClient) ListRoles

func (c *GrpcClient) ListRoles(ctx context.Context) ([]entity.Role, error)

ListRoles lists the role objects in system.

func (*GrpcClient) ListUsers

func (c *GrpcClient) ListUsers(ctx context.Context) ([]entity.User, error)

ListUsers lists the user objects in system.

func (*GrpcClient) LoadCollection

func (c *GrpcClient) LoadCollection(ctx context.Context, collName string, async bool, opts ...LoadCollectionOption) error

LoadCollection load collection into memory

func (*GrpcClient) LoadPartitions

func (c *GrpcClient) LoadPartitions(ctx context.Context, collName string, partitionNames []string, async bool) error

LoadPartitions load collection paritions into memory

func (*GrpcClient) ManualCompaction

func (c *GrpcClient) ManualCompaction(ctx context.Context, collName string, toleranceDuration time.Duration) (int64, error)

ManualCompaction triggers a compaction on provided collection

func (*GrpcClient) Query

func (c *GrpcClient) Query(ctx context.Context, collectionName string, partitionNames []string, expr string, outputFields []string, opts ...SearchQueryOptionFunc) ([]entity.Column, error)

Query performs query by expression.

func (*GrpcClient) QueryByPks

func (c *GrpcClient) QueryByPks(ctx context.Context, collectionName string, partitionNames []string, ids entity.Column, outputFields []string, opts ...SearchQueryOptionFunc) ([]entity.Column, error)

QueryByPks query record by specified primary key(s)

func (*GrpcClient) ReleaseCollection

func (c *GrpcClient) ReleaseCollection(ctx context.Context, collName string) error

ReleaseCollection release loaded collection

func (*GrpcClient) ReleasePartitions

func (c *GrpcClient) ReleasePartitions(ctx context.Context, collName string, partitionNames []string) error

ReleasePartitions release partitions

func (*GrpcClient) RemoveUserRole

func (c *GrpcClient) RemoveUserRole(ctx context.Context, username string, role string) error

RemoveUserRole removes one role from user.

func (*GrpcClient) Revoke

func (c *GrpcClient) Revoke(ctx context.Context, role string, objectType entity.PriviledgeObjectType, object string) error

Revoke removes privilege from role.

func (*GrpcClient) Search

func (c *GrpcClient) Search(ctx context.Context, collName string, partitions []string,
	expr string, outputFields []string, vectors []entity.Vector, vectorField string, metricType entity.MetricType, topK int, sp entity.SearchParam, opts ...SearchQueryOptionFunc) ([]SearchResult, error)

Search with bool expression

func (*GrpcClient) ShowCollection

func (c *GrpcClient) ShowCollection(ctx context.Context, collName string) (*entity.Collection, error)

ShowCollection show collection status, used to check whether it is loaded or not

func (*GrpcClient) ShowPartitions

func (c *GrpcClient) ShowPartitions(ctx context.Context, collName string) ([]*entity.Partition, error)

ShowPartitions list all partitions from collection

func (*GrpcClient) UpdateCredential

func (c *GrpcClient) UpdateCredential(ctx context.Context, username string, oldPassword string, newPassword string) error

UpdateCredential update password for a user

type IndexOption

type IndexOption func(*indexDef)

IndexOption is the predefined function to alter index def. shared among create, describe, drop indexes operations.

func WithIndexName

func WithIndexName(name string) IndexOption

WithIndexName returns an IndexOption with customized index name.

type LoadCollectionOption

type LoadCollectionOption func(*server.LoadCollectionRequest)

LoadCollectionOption is an option that is used to modify LoadCollectionRequest

func WithReplicaNumber

func WithReplicaNumber(rn int32) LoadCollectionOption

WithReplicaNumber specifies a specific ReplicaNumber, rather than using the default ReplicaNumber.

type MockServer

type MockServer struct {
	sync.RWMutex
	Injections map[ServiceMethod]TestInjection
}

mock Milvus Server

func (*MockServer) AlterAlias

func (m *MockServer) AlterAlias(ctx context.Context, req *server.AlterAliasRequest) (*common.Status, error)

func (*MockServer) AlterCollection

func (m *MockServer) AlterCollection(ctx context.Context, req *server.AlterCollectionRequest) (*common.Status, error)

func (*MockServer) CalcDistance

func (*MockServer) CheckHealth

func (*MockServer) CreateAlias

func (m *MockServer) CreateAlias(ctx context.Context, req *server.CreateAliasRequest) (*common.Status, error)

func (*MockServer) CreateCollection

func (m *MockServer) CreateCollection(ctx context.Context, req *server.CreateCollectionRequest) (*common.Status, error)

func (*MockServer) CreateIndex

func (m *MockServer) CreateIndex(ctx context.Context, req *server.CreateIndexRequest) (*common.Status, error)

func (*MockServer) CreatePartition

func (m *MockServer) CreatePartition(ctx context.Context, req *server.CreatePartitionRequest) (*common.Status, error)

func (*MockServer) DelInjection

func (m *MockServer) DelInjection(n ServiceMethod)

func (*MockServer) Delete

func (*MockServer) DeleteCredential

func (m *MockServer) DeleteCredential(ctx context.Context, req *server.DeleteCredentialRequest) (*common.Status, error)

func (*MockServer) DescribeIndex

func (*MockServer) DropAlias

func (m *MockServer) DropAlias(ctx context.Context, req *server.DropAliasRequest) (*common.Status, error)

func (*MockServer) DropCollection

func (m *MockServer) DropCollection(ctx context.Context, req *server.DropCollectionRequest) (*common.Status, error)

func (*MockServer) DropIndex

func (m *MockServer) DropIndex(ctx context.Context, req *server.DropIndexRequest) (*common.Status, error)

func (*MockServer) DropPartition

func (m *MockServer) DropPartition(ctx context.Context, req *server.DropPartitionRequest) (*common.Status, error)

func (*MockServer) DropRole

func (*MockServer) Dummy

func (*MockServer) Flush

func (*MockServer) GetCompactionStateWithPlans

func (m *MockServer) GetCompactionStateWithPlans(ctx context.Context, req *server.GetCompactionPlansRequest) (*server.GetCompactionPlansResponse, error)

func (*MockServer) GetComponentStates

func (*MockServer) GetFlushState

func (*MockServer) GetIndexState

func (*MockServer) GetInjection

func (m *MockServer) GetInjection(n ServiceMethod) TestInjection

func (*MockServer) GetLoadState

func (*MockServer) GetReplicas

func (*MockServer) GetVersion

func (*MockServer) HasCollection

func (*MockServer) HasPartition

func (*MockServer) Insert

func (*MockServer) ListCredUsers

func (*MockServer) LoadBalance

func (*MockServer) LoadCollection

func (m *MockServer) LoadCollection(ctx context.Context, req *server.LoadCollectionRequest) (*common.Status, error)

func (*MockServer) LoadPartitions

func (m *MockServer) LoadPartitions(ctx context.Context, req *server.LoadPartitionsRequest) (*common.Status, error)

func (*MockServer) ManualCompaction

func (*MockServer) OperatePrivilege

func (m *MockServer) OperatePrivilege(_ context.Context, _ *server.OperatePrivilegeRequest) (*common.Status, error)

func (*MockServer) OperateUserRole

func (m *MockServer) OperateUserRole(_ context.Context, _ *server.OperateUserRoleRequest) (*common.Status, error)

func (*MockServer) Query

TODO: remove

func (*MockServer) ReleaseCollection

func (m *MockServer) ReleaseCollection(ctx context.Context, req *server.ReleaseCollectionRequest) (*common.Status, error)

func (*MockServer) ReleasePartitions

func (m *MockServer) ReleasePartitions(ctx context.Context, req *server.ReleasePartitionsRequest) (*common.Status, error)

func (*MockServer) Search

func (*MockServer) SelectGrant

func (*MockServer) SelectRole

func (*MockServer) SelectUser

func (*MockServer) SetInjection

func (m *MockServer) SetInjection(n ServiceMethod, f TestInjection)

func (*MockServer) ShowCollections

func (*MockServer) ShowPartitions

func (*MockServer) UpdateCredential

func (m *MockServer) UpdateCredential(ctx context.Context, req *server.UpdateCredentialRequest) (*common.Status, error)

func (*MockServer) Upsert

type SearchQueryOption

type SearchQueryOption struct {
	// Consistency Level & Time travel
	ConsistencyLevel   entity.ConsistencyLevel
	GuaranteeTimestamp uint64
	TravelTimestamp    uint64
	// Pagination
	Limit  int64
	Offset int64
}

SearchQueryOption is an option of search/query request

type SearchQueryOptionFunc

type SearchQueryOptionFunc func(option *SearchQueryOption)

SearchQueryOptionFunc is a function which modifies SearchOption

func WithGuaranteeTimestamp

func WithGuaranteeTimestamp(gt uint64) SearchQueryOptionFunc

WithGuaranteeTimestamp specifies guarantee timestamp

func WithLimit

func WithLimit(limit int64) SearchQueryOptionFunc

WithLimit returns search/query option with limit.

func WithOffset

func WithOffset(offset int64) SearchQueryOptionFunc

WithOffset returns search/query option with offset.

func WithSearchQueryConsistencyLevel

func WithSearchQueryConsistencyLevel(cl entity.ConsistencyLevel) SearchQueryOptionFunc

WithSearchQueryConsistencyLevel specifies consistency level

func WithTravelTimestamp

func WithTravelTimestamp(tt uint64) SearchQueryOptionFunc

WithTravelTimestamp specifies time travel timestamp

type SearchResult

type SearchResult struct {
	ResultCount int             // the returning entry count
	IDs         entity.Column   // auto generated id, can be mapped to the columns from `Insert` API
	Fields      []entity.Column // output field data
	Scores      []float32       // distance to the target vector
	Err         error           // search error if any
}

SearchResult contains the result from Search api of client IDs is the auto generated id values for the entities Fields contains the data of `outputFieleds` specified or all columns if non Scores is actually the distance between the vector current record contains and the search target vector

type SearchResultByRows

type SearchResultByRows struct {
	ResultCount int
	Scores      []float32
	Rows        []entity.Row
	Err         error
}

SearchResultByRows search result for row-based Search

func SearchResultToRows

func SearchResultToRows(sch *entity.Schema, results *schema.SearchResultData, t reflect.Type, output map[string]struct{}) ([]SearchResultByRows, error)

SearchResultToRows converts search result proto to rows

type ServiceMethod

type ServiceMethod int

type alias for Service method

const (
	MCreateCollection        ServiceMethod = 101
	MDropCollection          ServiceMethod = 102
	MHasCollection           ServiceMethod = 103
	MLoadCollection          ServiceMethod = 104
	MReleaseCollection       ServiceMethod = 105
	MDescribeCollection      ServiceMethod = 106
	MListCollection          ServiceMethod = 107
	MGetCollectionStatistics ServiceMethod = 108
	MAlterCollection         ServiceMethod = 109
	MGetLoadingProgress      ServiceMethod = 110
	MGetLoadState            ServiceMethod = 111

	MCreatePartition   ServiceMethod = 201
	MDropPartition     ServiceMethod = 202
	MHasPartition      ServiceMethod = 203
	MLoadPartitions    ServiceMethod = 204
	MReleasePartitions ServiceMethod = 205
	MShowPartitions    ServiceMethod = 206

	MShowCollections ServiceMethod = 301
	MCreateAlias     ServiceMethod = 302
	MDropAlias       ServiceMethod = 303
	MAlterAlias      ServiceMethod = 304
	MGetReplicas     ServiceMethod = 305

	MCreateIndex           ServiceMethod = 401
	MDropIndex             ServiceMethod = 402
	MDescribeIndex         ServiceMethod = 403
	MGetIndexState         ServiceMethod = 404
	MGetIndexBuildProgress ServiceMethod = 405

	MCreateCredential ServiceMethod = 500
	MUpdateCredential ServiceMethod = 501
	MDeleteCredential ServiceMethod = 502
	MListCredUsers    ServiceMethod = 503

	MInsert        ServiceMethod = 600
	MFlush         ServiceMethod = 601
	MSearch        ServiceMethod = 602
	MCalcDistance  ServiceMethod = 603
	MGetFlushState ServiceMethod = 604
	MDelete        ServiceMethod = 605
	MQuery         ServiceMethod = 606
	MUpsert        ServiceMethod = 607

	MManualCompaction            ServiceMethod = 700
	MGetCompactionState          ServiceMethod = 701
	MGetCompactionStateWithPlans ServiceMethod = 702

	MGetPersistentSegmentInfo ServiceMethod = 800
	MGetQuerySegmentInfo      ServiceMethod = 801

	MGetComponentStates ServiceMethod = 900
	MGetVersion         ServiceMethod = 901
	MCheckHealth        ServiceMethod = 902
)

type TestInjection

type TestInjection func(context.Context, proto.Message) (proto.Message, error)

injection function definition

Jump to

Keyboard shortcuts

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