github.com/milvus-io/milvus-sdk-go/v2@v2.4.1/test/testcases/option.go (about)

     1  package testcases
     2  
     3  import (
     4  	"github.com/milvus-io/milvus-sdk-go/v2/client"
     5  	"github.com/milvus-io/milvus-sdk-go/v2/entity"
     6  )
     7  
     8  type HelpPartitionColumns struct {
     9  	PartitionName string
    10  	IdsColumn     entity.Column
    11  	VectorColumn  entity.Column
    12  }
    13  
    14  type CollectionFieldsType string
    15  
    16  type CollectionParams struct {
    17  	CollectionFieldsType CollectionFieldsType // collection fields type
    18  	AutoID               bool                 // autoId
    19  	EnableDynamicField   bool                 // enable dynamic field
    20  	ShardsNum            int32
    21  	Dim                  int64
    22  	MaxLength            int64
    23  	MaxCapacity          int64
    24  }
    25  
    26  type DataParams struct {
    27  	CollectionName       string // insert data into which collection
    28  	PartitionName        string
    29  	CollectionFieldsType CollectionFieldsType // collection fields type
    30  	start                int                  // start
    31  	nb                   int                  // insert how many data
    32  	dim                  int64
    33  	EnableDynamicField   bool // whether insert dynamic field data
    34  	WithRows             bool
    35  	DoInsert             bool
    36  	maxLenSparse         int
    37  }
    38  
    39  func (d DataParams) IsEmpty() bool {
    40  	return d.CollectionName == "" || d.nb == 0
    41  }
    42  
    43  type FlushParams struct {
    44  	DoFlush        bool
    45  	PartitionNames []string
    46  	async          bool
    47  }
    48  
    49  type IndexParams struct {
    50  	BuildIndex bool
    51  	Index      entity.Index
    52  	FieldName  string
    53  	async      bool
    54  }
    55  
    56  func (i IndexParams) IsEmpty() bool {
    57  	return i.Index == nil || i.FieldName == ""
    58  }
    59  
    60  type LoadParams struct {
    61  	DoLoad         bool
    62  	PartitionNames []string
    63  	async          bool
    64  }
    65  
    66  type ClientParamsOption struct {
    67  	DataParams  DataParams
    68  	FlushParams FlushParams
    69  	IndexParams []IndexParams
    70  	LoadParams  LoadParams
    71  	CreateOpts  client.CreateCollectionOption
    72  	IndexOpts   client.IndexOption
    73  	LoadOpts    client.LoadCollectionOption
    74  }
    75  
    76  type PrepareCollectionOption func(opt *ClientParamsOption)
    77  
    78  func WithDataParams(dp DataParams) PrepareCollectionOption {
    79  	return func(opt *ClientParamsOption) {
    80  		opt.DataParams = dp
    81  	}
    82  }
    83  
    84  func WithFlushParams(fp FlushParams) PrepareCollectionOption {
    85  	return func(opt *ClientParamsOption) {
    86  		opt.FlushParams = fp
    87  	}
    88  }
    89  
    90  func WithIndexParams(ips []IndexParams) PrepareCollectionOption {
    91  	return func(opt *ClientParamsOption) {
    92  		opt.IndexParams = ips
    93  	}
    94  }
    95  
    96  func WithLoadParams(lp LoadParams) PrepareCollectionOption {
    97  	return func(opt *ClientParamsOption) {
    98  		opt.LoadParams = lp
    99  	}
   100  }
   101  
   102  func WithCreateOption(createOpts client.CreateCollectionOption) PrepareCollectionOption {
   103  	return func(opt *ClientParamsOption) {
   104  		opt.CreateOpts = createOpts
   105  	}
   106  }
   107  
   108  func WithIndexOption(indexOpts client.IndexOption) PrepareCollectionOption {
   109  	return func(opt *ClientParamsOption) {
   110  		opt.IndexOpts = indexOpts
   111  	}
   112  }
   113  
   114  func WithLoadOption(loadOpts client.LoadCollectionOption) PrepareCollectionOption {
   115  	return func(opt *ClientParamsOption) {
   116  		opt.LoadOpts = loadOpts
   117  	}
   118  }