Skip to content

Commit

Permalink
Add json field and dynamic field test cases (milvus-io#513)
Browse files Browse the repository at this point in the history
Signed-off-by: ThreadDao <[email protected]>
  • Loading branch information
ThreadDao committed Aug 16, 2023
1 parent dd5a31f commit 71bfe8f
Show file tree
Hide file tree
Showing 15 changed files with 2,095 additions and 591 deletions.
81 changes: 41 additions & 40 deletions test/base/milvus_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func (mc *MilvusClient) Close() error {
}

// -- database --

// UsingDatabase for database operation after this function call.
// All request in any goroutine will be applied to new database on the same client. e.g.
// 1. goroutine A access DB1.
Expand Down Expand Up @@ -120,7 +121,7 @@ func (mc *MilvusClient) DropDatabase(ctx context.Context, dbName string) error {

// -- collection --

// Create Collection
// CreateCollection Create Collection
func (mc *MilvusClient) CreateCollection(ctx context.Context, collSchema *entity.Schema, shardsNum int32, opts ...client.CreateCollectionOption) error {
if collSchema == nil {
preRequest("CreateCollection", ctx, collSchema, shardsNum, opts)
Expand All @@ -132,39 +133,39 @@ func (mc *MilvusClient) CreateCollection(ctx context.Context, collSchema *entity
return err
}

// List Collections
// ListCollections list collections
func (mc *MilvusClient) ListCollections(ctx context.Context) ([]*entity.Collection, error) {
preRequest("ListCollections", ctx)
collections, err := mc.mClient.ListCollections(ctx)
postResponse("ListCollections", err, collections)
return collections, err
}

// Describe collection
// DescribeCollection Describe collection
func (mc *MilvusClient) DescribeCollection(ctx context.Context, collName string) (*entity.Collection, error) {
preRequest("DescribeCollection", ctx, collName)
collection, err := mc.mClient.DescribeCollection(ctx, collName)
postResponse("DescribeCollection", err, collection)
return collection, err
}

// Drop Collection
// DropCollection Drop Collection
func (mc *MilvusClient) DropCollection(ctx context.Context, collName string) error {
preRequest("DropCollection", ctx, collName)
err := mc.mClient.DropCollection(ctx, collName)
postResponse("DropCollection", err)
return err
}

// Get Collection Statistics
// GetCollectionStatistics Get Collection Statistics
func (mc *MilvusClient) GetCollectionStatistics(ctx context.Context, collName string) (map[string]string, error) {
preRequest("GetCollectionStatistics", ctx, collName)
stats, err := mc.mClient.GetCollectionStatistics(ctx, collName)
postResponse("GetCollectionStatistics", err, stats)
return stats, err
}

// Load Collection
// LoadCollection Load Collection
func (mc *MilvusClient) LoadCollection(ctx context.Context, collName string, async bool, opts ...client.LoadCollectionOption) error {
funcName := "LoadCollection"
preRequest(funcName, ctx, collName, opts)
Expand All @@ -173,15 +174,15 @@ func (mc *MilvusClient) LoadCollection(ctx context.Context, collName string, asy
return err
}

// Release Collection
// ReleaseCollection Release Collection
func (mc *MilvusClient) ReleaseCollection(ctx context.Context, collName string) error {
preRequest("ReleaseCollection", ctx, collName)
err := mc.mClient.ReleaseCollection(ctx, collName)
postResponse("ReleaseCollection", err)
return err
}

// Has Collection
// HasCollection Has Collection
func (mc *MilvusClient) HasCollection(ctx context.Context, collName string) (bool, error) {
preRequest("HasCollection", ctx, collName)
has, err := mc.mClient.HasCollection(ctx, collName)
Expand All @@ -191,31 +192,31 @@ func (mc *MilvusClient) HasCollection(ctx context.Context, collName string) (boo

// -- alias --

// Create Alias
// CreateAlias Create Alias
func (mc *MilvusClient) CreateAlias(ctx context.Context, collName string, alias string) error {
preRequest("CreateAlias", ctx, collName, alias)
err := mc.mClient.CreateAlias(ctx, collName, alias)
postResponse("CreateAlias", err)
return err
}

// Drop Alias
// DropAlias drop alias
func (mc *MilvusClient) DropAlias(ctx context.Context, alias string) error {
preRequest("DropAlias", ctx, alias)
err := mc.mClient.DropAlias(ctx, alias)
postResponse("DropAlias", err)
return err
}

// Alter Alias
// AlterAlias Alter Alias
func (mc *MilvusClient) AlterAlias(ctx context.Context, collName string, alias string) error {
preRequest("AlterAlias", ctx, collName, alias)
err := mc.mClient.AlterAlias(ctx, collName, alias)
postResponse("AlterAlias", err)
return err
}

// Get Replicas
// GetReplicas Get Replicas
func (mc *MilvusClient) GetReplicas(ctx context.Context, collName string) ([]*entity.ReplicaGroup, error) {
preRequest("GetReplicas", ctx, collName)
replicas, err := mc.mClient.GetReplicas(ctx, collName)
Expand All @@ -225,23 +226,23 @@ func (mc *MilvusClient) GetReplicas(ctx context.Context, collName string) ([]*en

// -- authentication --

// Create Credential
// CreateCredential Create Credential
func (mc *MilvusClient) CreateCredential(ctx context.Context, username string, password string) error {
preRequest("CreateCredential", ctx, username)
err := mc.mClient.CreateCredential(ctx, username, password)
postResponse("CreateCredential", err)
return err
}

// Update Credential
// UpdateCredential Update Credential
func (mc *MilvusClient) UpdateCredential(ctx context.Context, username string, oldPassword string, newPassword string) error {
preRequest("UpdateCredential", ctx, username)
err := mc.mClient.UpdateCredential(ctx, username, oldPassword, newPassword)
postResponse("UpdateCredential", err)
return err
}

// DeleteCredential
// DeleteCredential delete credential
func (mc *MilvusClient) DeleteCredential(ctx context.Context, username string) error {
preRequest("DeleteCredential", ctx, username)
err := mc.mClient.DeleteCredential(ctx, username)
Expand All @@ -259,39 +260,39 @@ func (mc *MilvusClient) ListCredUsers(ctx context.Context) ([]string, error) {

// -- partition --

// Create Partition
// CreatePartition Create Partition
func (mc *MilvusClient) CreatePartition(ctx context.Context, collName string, partitionName string) error {
preRequest("CreatePartition", ctx, collName, partitionName)
err := mc.mClient.CreatePartition(ctx, collName, partitionName)
postResponse("CreatePartition", err)
return err
}

// Drop Partition
// DropPartition Drop Partition
func (mc *MilvusClient) DropPartition(ctx context.Context, collName string, partitionName string) error {
preRequest("DropPartition", ctx, collName, partitionName)
err := mc.mClient.DropPartition(ctx, collName, partitionName)
postResponse("DropPartition", err)
return err
}

// Show Partitions
// ShowPartitions Show Partitions
func (mc *MilvusClient) ShowPartitions(ctx context.Context, collName string) ([]*entity.Partition, error) {
preRequest("ShowPartitions", ctx, collName)
partitions, err := mc.mClient.ShowPartitions(ctx, collName)
postResponse("ShowPartitions", err, partitions)
return partitions, err
}

// Has Partition
// HasPartition Has Partition
func (mc *MilvusClient) HasPartition(ctx context.Context, collName string, partitionName string) (bool, error) {
preRequest("HasPartition", ctx, collName)
has, err := mc.mClient.HasPartition(ctx, collName, partitionName)
postResponse("HasPartition", err, has)
return has, err
}

// Load Partitions
// LoadPartitions Load Partitions into memory
func (mc *MilvusClient) LoadPartitions(ctx context.Context, collName string, partitionNames []string, async bool) error {
preRequest("LoadPartitions", ctx, collName, partitionNames, async)
err := mc.mClient.LoadPartitions(ctx, collName, partitionNames, async)
Expand All @@ -307,39 +308,39 @@ func (mc *MilvusClient) ReleasePartitions(ctx context.Context, collName string,
return err
}

// Get Persistent Segment Info
// GetPersistentSegmentInfo Get Persistent Segment Info
func (mc *MilvusClient) GetPersistentSegmentInfo(ctx context.Context, collName string) ([]*entity.Segment, error) {
preRequest("GetPersistentSegmentInfo", ctx, collName)
segments, err := mc.mClient.GetPersistentSegmentInfo(ctx, collName)
postResponse("GetPersistentSegmentInfo", err, segments)
return segments, err
}

// Create Index
// CreateIndex Create Index
func (mc *MilvusClient) CreateIndex(ctx context.Context, collName string, fieldName string, idx entity.Index, async bool, opts ...client.IndexOption) error {
preRequest("CreateIndex", ctx, collName, fieldName, async, idx, opts)
err := mc.mClient.CreateIndex(ctx, collName, fieldName, idx, async, opts...)
postResponse("CreateIndex", err)
return err
}

// Describe Index
// DescribeIndex Describe Index
func (mc *MilvusClient) DescribeIndex(ctx context.Context, collectionName string, fieldName string, opts ...client.IndexOption) ([]entity.Index, error) {
preRequest("DescribeIndex", ctx, collectionName, fieldName, opts)
indexes, err := mc.mClient.DescribeIndex(ctx, collectionName, fieldName, opts...)
postResponse("DescribeIndex", err, indexes)
return indexes, err
}

// Drop Index
// DropIndex Drop Index
func (mc *MilvusClient) DropIndex(ctx context.Context, collName string, fieldName string, opts ...client.IndexOption) error {
preRequest("DropIndex", ctx, collName, fieldName, opts)
err := mc.mClient.DropIndex(ctx, collName, fieldName, opts...)
postResponse("DropIndex", err)
return err
}

// Get IndexState, index naming is not supported yet
// GetIndexState Get IndexState, index naming is not supported yet
func (mc *MilvusClient) GetIndexState(ctx context.Context, collName string, fieldName string, opts ...client.IndexOption) (entity.IndexState, error) {
preRequest("GetIndexState", ctx, collName, fieldName, opts)
indexState, err := mc.mClient.GetIndexState(ctx, collName, fieldName, opts...)
Expand All @@ -349,15 +350,15 @@ func (mc *MilvusClient) GetIndexState(ctx context.Context, collName string, fiel

// -- basic operation --

// Insert
// Insert insert data
func (mc *MilvusClient) Insert(ctx context.Context, collName string, partitionName string, columns ...entity.Column) (entity.Column, error) {
preRequest("Insert", ctx, collName, partitionName, columns)
ids, err := mc.mClient.Insert(ctx, collName, partitionName, columns...)
postResponse("Insert", err, ids)
return ids, err
}

// Flush
// Flush flush collection
func (mc *MilvusClient) Flush(ctx context.Context, collName string, async bool) error {
preRequest("Flush", ctx, collName, async)
err := mc.mClient.Flush(ctx, collName, async)
Expand All @@ -373,7 +374,7 @@ func (mc *MilvusClient) DeleteByPks(ctx context.Context, collName string, partit
return err
}

// Search
// Search search from collection
func (mc *MilvusClient) 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 ...client.SearchQueryOptionFunc,
) ([]client.SearchResult, error) {
Expand All @@ -386,7 +387,7 @@ func (mc *MilvusClient) Search(ctx context.Context, collName string, partitions
return searchResult, err
}

// Query
// Query query from collection
func (mc *MilvusClient) Query(ctx context.Context, collName string, partitions []string, ids entity.Column,
outputFields []string, opts ...client.SearchQueryOptionFunc,
) ([]entity.Column, error) {
Expand All @@ -401,7 +402,7 @@ func (mc *MilvusClient) Query(ctx context.Context, collName string, partitions [

// -- row based apis --

// Create Collection By Row
// CreateCollectionByRow Create Collection By Row
func (mc *MilvusClient) CreateCollectionByRow(ctx context.Context, row entity.Row, shardNum int32) error {
preRequest("CreateCollectionByRow", ctx, row, shardNum)
err := mc.mClient.CreateCollectionByRow(ctx, row, shardNum)
Expand All @@ -417,31 +418,31 @@ func (mc *MilvusClient) InsertRows(ctx context.Context, collName string, partiti
return column, err
}

// Manual Compaction
// Compact Manual Compaction
func (mc *MilvusClient) Compact(ctx context.Context, collName string, toleranceDuration time.Duration) (int64, error) {
preRequest("ManualCompaction", ctx, collName, toleranceDuration)
compactionID, err := mc.mClient.ManualCompaction(ctx, collName, toleranceDuration)
postResponse("ManualCompaction", err, compactionID)
return compactionID, err
}

// Get Compaction State
// GetCompactionState Get Compaction State
func (mc *MilvusClient) GetCompactionState(ctx context.Context, id int64) (entity.CompactionState, error) {
preRequest("GetCompactionState", ctx, id)
compactionState, err := mc.mClient.GetCompactionState(ctx, id)
postResponse("GetCompactionState", err, compactionState)
return compactionState, err
}

// Get Compaction State With Plans
// GetCompactionStateWithPlans Get Compaction State With Plans
func (mc *MilvusClient) GetCompactionStateWithPlans(ctx context.Context, id int64) (entity.CompactionState, []entity.CompactionPlan, error) {
preRequest("GetCompactionStateWithPlans", ctx, id)
compactionState, compactionPlan, err := mc.mClient.GetCompactionStateWithPlans(ctx, id)
postResponse("GetCompactionStateWithPlans", err, compactionState, compactionPlan)
return compactionState, compactionPlan, err
}

// Bulk Insert import data files(json, numpy, etc.) on MinIO/S3 storage, read and parse them into sealed segments
// BulkInsert Bulk Insert import data files(json, numpy, etc.) on MinIO/S3 storage, read and parse them into sealed segments
func (mc *MilvusClient) BulkInsert(ctx context.Context, collName string, partitionName string, files []string, opts ...client.BulkInsertOption) (int64, error) {
preRequest("BulkInsert", ctx, collName, partitionName, files, opts)
taskID, err := mc.mClient.BulkInsert(ctx, collName, partitionName, files, opts...)
Expand All @@ -457,7 +458,7 @@ func (mc *MilvusClient) GetBulkInsertState(ctx context.Context, taskID int64) (*
return bulkInsertTaskState, err
}

// List Bulk Insert Tasks
// ListBulkInsertTasks List Bulk Insert Tasks
func (mc *MilvusClient) ListBulkInsertTasks(ctx context.Context, collName string, limit int64) ([]*entity.BulkInsertTaskState, error) {
preRequest("ListBulkInsertTasks", ctx, collName, limit)
bulkInsertTaskStates, err := mc.mClient.ListBulkInsertTasks(ctx, collName, limit)
Expand All @@ -479,7 +480,7 @@ func (mc *MilvusClient) WaitForCompactionCompleted(ctx context.Context, compacti
}
}

// List Resource Groups
// ListResourceGroups List Resource Groups
func (mc *MilvusClient) ListResourceGroups(ctx context.Context) ([]string, error) {
preRequest("ListResourceGroups", ctx)
rgs, err := mc.mClient.ListResourceGroups(ctx)
Expand All @@ -495,31 +496,31 @@ func (mc *MilvusClient) CreateResourceGroup(ctx context.Context, rgName string)
return err
}

// DescribeResourceGroup
// DescribeResourceGroup describe resource group
func (mc *MilvusClient) DescribeResourceGroup(ctx context.Context, rgName string) (*entity.ResourceGroup, error) {
preRequest("DescribeResourceGroup", ctx, rgName)
rg, err := mc.mClient.DescribeResourceGroup(ctx, rgName)
postResponse("DescribeResourceGroup", err, rg)
return rg, err
}

// DropResourceGroup
// DropResourceGroup drop resource group
func (mc *MilvusClient) DropResourceGroup(ctx context.Context, rgName string) error {
preRequest("DropResourceGroup", ctx, rgName)
err := mc.mClient.DropResourceGroup(ctx, rgName)
postResponse("DropResourceGroup", err)
return err
}

// TransferNode
// TransferNode transfer node
func (mc *MilvusClient) TransferNode(ctx context.Context, sourceRg, targetRg string, nodesNum int32) error {
preRequest("TransferNode", ctx, sourceRg, targetRg, nodesNum)
err := mc.mClient.TransferNode(ctx, sourceRg, targetRg, nodesNum)
postResponse("TransferNode", err)
return err
}

// TransferReplica
// TransferReplica transfer replica
func (mc *MilvusClient) TransferReplica(ctx context.Context, sourceRg, targetRg string, collectionName string, replicaNum int64) error {
preRequest("TransferReplica", ctx, sourceRg, targetRg, collectionName, replicaNum)
err := mc.mClient.TransferReplica(ctx, sourceRg, targetRg, collectionName, replicaNum)
Expand Down
Loading

0 comments on commit 71bfe8f

Please sign in to comment.