mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-01 03:18:29 +08:00
89541a6f68
Signed-off-by: longjiquan <jiquan.long@zilliz.com> Signed-off-by: longjiquan <jiquan.long@zilliz.com>
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package rootcoord
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/milvus-io/milvus-proto/go-api/commonpb"
|
|
"github.com/milvus-io/milvus-proto/go-api/milvuspb"
|
|
"github.com/milvus-io/milvus/internal/util/typeutil"
|
|
)
|
|
|
|
// hasPartitionTask has partition request task
|
|
type hasPartitionTask struct {
|
|
baseTask
|
|
Req *milvuspb.HasPartitionRequest
|
|
Rsp *milvuspb.BoolResponse
|
|
}
|
|
|
|
func (t *hasPartitionTask) Prepare(ctx context.Context) error {
|
|
if err := CheckMsgType(t.Req.Base.MsgType, commonpb.MsgType_HasPartition); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Execute task execution
|
|
func (t *hasPartitionTask) Execute(ctx context.Context) error {
|
|
t.Rsp.Status = succStatus()
|
|
t.Rsp.Value = false
|
|
// TODO: why HasPartitionRequest doesn't contain Timestamp but other requests do.
|
|
coll, err := t.core.meta.GetCollectionByName(ctx, t.Req.CollectionName, typeutil.MaxTimestamp)
|
|
if err != nil {
|
|
t.Rsp.Status = failStatus(commonpb.ErrorCode_CollectionNotExists, err.Error())
|
|
return err
|
|
}
|
|
for _, part := range coll.Partitions {
|
|
if part.PartitionName == t.Req.PartitionName {
|
|
t.Rsp.Value = true
|
|
break
|
|
}
|
|
}
|
|
return nil
|
|
}
|