partition_options.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. // Licensed to the LF AI & Data foundation under one
  2. // or more contributor license agreements. See the NOTICE file
  3. // distributed with this work for additional information
  4. // regarding copyright ownership. The ASF licenses this file
  5. // to you under the Apache License, Version 2.0 (the
  6. // "License"); you may not use this file except in compliance
  7. // with the License. You may obtain a copy of the License at
  8. //
  9. // http://www.apache.org/licenses/LICENSE-2.0
  10. //
  11. // Unless required by applicable law or agreed to in writing, software
  12. // distributed under the License is distributed on an "AS IS" BASIS,
  13. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. // See the License for the specific language governing permissions and
  15. // limitations under the License.
  16. package client
  17. import "github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
  18. // CreatePartitionOption is the interface builds Create Partition request.
  19. type CreatePartitionOption interface {
  20. // Request is the method returns the composed request.
  21. Request() *milvuspb.CreatePartitionRequest
  22. }
  23. type createPartitionOpt struct {
  24. collectionName string
  25. partitionName string
  26. }
  27. func (opt *createPartitionOpt) Request() *milvuspb.CreatePartitionRequest {
  28. return &milvuspb.CreatePartitionRequest{
  29. CollectionName: opt.collectionName,
  30. PartitionName: opt.partitionName,
  31. }
  32. }
  33. func NewCreatePartitionOption(collectionName string, partitionName string) *createPartitionOpt {
  34. return &createPartitionOpt{
  35. collectionName: collectionName,
  36. partitionName: partitionName,
  37. }
  38. }
  39. // DropPartitionOption is the interface that builds Drop Partition request.
  40. type DropPartitionOption interface {
  41. // Request is the method returns the composed request.
  42. Request() *milvuspb.DropPartitionRequest
  43. }
  44. type dropPartitionOpt struct {
  45. collectionName string
  46. partitionName string
  47. }
  48. func (opt *dropPartitionOpt) Request() *milvuspb.DropPartitionRequest {
  49. return &milvuspb.DropPartitionRequest{
  50. CollectionName: opt.collectionName,
  51. PartitionName: opt.partitionName,
  52. }
  53. }
  54. func NewDropPartitionOption(collectionName string, partitionName string) *dropPartitionOpt {
  55. return &dropPartitionOpt{
  56. collectionName: collectionName,
  57. partitionName: partitionName,
  58. }
  59. }
  60. // HasPartitionOption is the interface builds HasPartition request.
  61. type HasPartitionOption interface {
  62. // Request is the method returns the composed request.
  63. Request() *milvuspb.HasPartitionRequest
  64. }
  65. var _ HasPartitionOption = (*hasPartitionOpt)(nil)
  66. type hasPartitionOpt struct {
  67. collectionName string
  68. partitionName string
  69. }
  70. func (opt *hasPartitionOpt) Request() *milvuspb.HasPartitionRequest {
  71. return &milvuspb.HasPartitionRequest{
  72. CollectionName: opt.collectionName,
  73. PartitionName: opt.partitionName,
  74. }
  75. }
  76. func NewHasPartitionOption(collectionName string, partitionName string) *hasPartitionOpt {
  77. return &hasPartitionOpt{
  78. collectionName: collectionName,
  79. partitionName: partitionName,
  80. }
  81. }
  82. // ListPartitionsOption is the interface builds List Partition request.
  83. type ListPartitionsOption interface {
  84. // Request is the method returns the composed request.
  85. Request() *milvuspb.ShowPartitionsRequest
  86. }
  87. type listPartitionsOpt struct {
  88. collectionName string
  89. }
  90. func (opt *listPartitionsOpt) Request() *milvuspb.ShowPartitionsRequest {
  91. return &milvuspb.ShowPartitionsRequest{
  92. CollectionName: opt.collectionName,
  93. Type: milvuspb.ShowType_All,
  94. }
  95. }
  96. func NewListPartitionOption(collectionName string) *listPartitionsOpt {
  97. return &listPartitionsOpt{
  98. collectionName: collectionName,
  99. }
  100. }