diff --git a/client/client.go b/client/client.go index 1ae9dcda..1811781c 100644 --- a/client/client.go +++ b/client/client.go @@ -52,7 +52,7 @@ type Client interface { // NewCollection intializeds a new collection with pre defined attributes NewCollection(ctx context.Context, collName string, dimension int64, opts ...CreateCollectionOption) error // ListCollections list collections from connection - ListCollections(ctx context.Context) ([]*entity.Collection, error) + ListCollections(ctx context.Context, opts ...ListCollectionOption) ([]*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 diff --git a/client/collection.go b/client/collection.go index 98b0cb4b..bf5fdec7 100644 --- a/client/collection.go +++ b/client/collection.go @@ -45,14 +45,25 @@ func handleRespStatus(status *commonpb.Status) error { // ListCollections list collections from connection // Note that schema info are not provided in collection list -func (c *GrpcClient) ListCollections(ctx context.Context) ([]*entity.Collection, error) { +func (c *GrpcClient) ListCollections(ctx context.Context, opts ...ListCollectionOption) ([]*entity.Collection, error) { if c.Service == nil { return []*entity.Collection{}, ErrClientNotReady } + + o := &listCollectionOpt{} + for _, opt := range opts { + opt(o) + } + req := &milvuspb.ShowCollectionsRequest{ DbName: "", TimeStamp: 0, // means now } + + if o.showInMemory { + req.Type = milvuspb.ShowType_InMemory + } + resp, err := c.Service.ShowCollections(ctx, req) if err != nil { return []*entity.Collection{}, err diff --git a/client/options.go b/client/options.go index dc82454c..6ac2a962 100644 --- a/client/options.go +++ b/client/options.go @@ -289,6 +289,18 @@ func GetWithOutputFields(outputFields ...string) GetOption { } } +type listCollectionOpt struct { + showInMemory bool +} + +type ListCollectionOption func(*listCollectionOpt) + +func WithShowInMemory(value bool) ListCollectionOption { + return func(opt *listCollectionOpt) { + opt.showInMemory = value + } +} + type DropCollectionOption func(*milvuspb.DropCollectionRequest) type ReleaseCollectionOption func(*milvuspb.ReleaseCollectionRequest)