2021-01-15 14:38:36 +08:00
|
|
|
package proxynode
|
2020-11-03 14:53:36 +08:00
|
|
|
|
|
|
|
import (
|
2020-11-05 18:01:33 +08:00
|
|
|
"errors"
|
2020-11-05 19:11:12 +08:00
|
|
|
"log"
|
2020-11-26 16:01:31 +08:00
|
|
|
"math"
|
|
|
|
"strconv"
|
|
|
|
|
2021-01-30 15:30:38 +08:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/datapb"
|
|
|
|
|
2020-11-26 16:01:31 +08:00
|
|
|
"github.com/golang/protobuf/proto"
|
2020-11-20 17:53:31 +08:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/allocator"
|
2020-11-05 18:01:33 +08:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/msgstream"
|
2021-01-20 10:02:59 +08:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/msgstream/pulsarms"
|
2020-11-05 18:01:33 +08:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/commonpb"
|
2021-01-18 19:32:08 +08:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/internalpb2"
|
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/milvuspb"
|
2020-11-26 16:01:31 +08:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/schemapb"
|
2020-12-23 19:06:11 +08:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/util/typeutil"
|
2020-11-03 14:53:36 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
type task interface {
|
2020-11-23 16:52:17 +08:00
|
|
|
ID() UniqueID // return ReqID
|
|
|
|
SetID(uid UniqueID) // set ReqID
|
2021-01-16 15:06:19 +08:00
|
|
|
Type() commonpb.MsgType
|
2020-11-05 18:01:33 +08:00
|
|
|
BeginTs() Timestamp
|
|
|
|
EndTs() Timestamp
|
2020-11-04 17:58:43 +08:00
|
|
|
SetTs(ts Timestamp)
|
2021-01-22 09:36:18 +08:00
|
|
|
OnEnqueue() error
|
2020-11-03 14:53:36 +08:00
|
|
|
PreExecute() error
|
|
|
|
Execute() error
|
|
|
|
PostExecute() error
|
|
|
|
WaitToFinish() error
|
2020-11-05 18:01:33 +08:00
|
|
|
Notify(err error)
|
2020-11-03 14:53:36 +08:00
|
|
|
}
|
|
|
|
|
2020-11-07 16:18:23 +08:00
|
|
|
type BaseInsertTask = msgstream.InsertMsg
|
2020-11-05 18:01:33 +08:00
|
|
|
|
|
|
|
type InsertTask struct {
|
2020-11-07 16:18:23 +08:00
|
|
|
BaseInsertTask
|
2020-11-17 20:00:23 +08:00
|
|
|
Condition
|
2021-01-30 15:30:38 +08:00
|
|
|
dataServiceClient DataServiceClient
|
|
|
|
result *milvuspb.InsertResponse
|
|
|
|
rowIDAllocator *allocator.IDAllocator
|
2020-11-05 18:01:33 +08:00
|
|
|
}
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
func (it *InsertTask) OnEnqueue() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-11-23 16:52:17 +08:00
|
|
|
func (it *InsertTask) SetID(uid UniqueID) {
|
2021-01-18 19:32:08 +08:00
|
|
|
it.Base.MsgID = uid
|
2020-11-23 16:52:17 +08:00
|
|
|
}
|
|
|
|
|
2020-11-05 18:01:33 +08:00
|
|
|
func (it *InsertTask) SetTs(ts Timestamp) {
|
2020-11-26 16:01:31 +08:00
|
|
|
rowNum := len(it.RowData)
|
|
|
|
it.Timestamps = make([]uint64, rowNum)
|
|
|
|
for index := range it.Timestamps {
|
|
|
|
it.Timestamps[index] = ts
|
|
|
|
}
|
|
|
|
it.BeginTimestamp = ts
|
|
|
|
it.EndTimestamp = ts
|
2020-11-05 18:01:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (it *InsertTask) BeginTs() Timestamp {
|
2020-11-26 16:01:31 +08:00
|
|
|
return it.BeginTimestamp
|
2020-11-05 18:01:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (it *InsertTask) EndTs() Timestamp {
|
2020-11-26 16:01:31 +08:00
|
|
|
return it.EndTimestamp
|
2020-11-05 18:01:33 +08:00
|
|
|
}
|
|
|
|
|
2020-11-12 12:04:12 +08:00
|
|
|
func (it *InsertTask) ID() UniqueID {
|
2021-01-18 19:32:08 +08:00
|
|
|
return it.Base.MsgID
|
2020-11-05 18:01:33 +08:00
|
|
|
}
|
|
|
|
|
2021-01-16 15:06:19 +08:00
|
|
|
func (it *InsertTask) Type() commonpb.MsgType {
|
2021-01-18 19:32:08 +08:00
|
|
|
return it.Base.MsgType
|
2020-11-05 18:01:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (it *InsertTask) PreExecute() error {
|
2021-01-22 09:36:18 +08:00
|
|
|
it.Base.MsgType = commonpb.MsgType_kInsert
|
2021-01-28 20:51:44 +08:00
|
|
|
it.Base.SourceID = Params.ProxyID
|
2021-01-22 09:36:18 +08:00
|
|
|
|
2020-11-26 16:01:31 +08:00
|
|
|
collectionName := it.BaseInsertTask.CollectionName
|
|
|
|
if err := ValidateCollectionName(collectionName); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2021-01-18 19:32:08 +08:00
|
|
|
partitionTag := it.BaseInsertTask.PartitionName
|
2020-11-26 16:01:31 +08:00
|
|
|
if err := ValidatePartitionTag(partitionTag, true); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-11-05 18:01:33 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (it *InsertTask) Execute() error {
|
2020-11-20 17:53:31 +08:00
|
|
|
collectionName := it.BaseInsertTask.CollectionName
|
2021-01-31 14:55:36 +08:00
|
|
|
collSchema, err := globalMetaCache.GetCollectionSchema(collectionName)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2020-11-20 17:53:31 +08:00
|
|
|
}
|
2021-01-31 14:55:36 +08:00
|
|
|
autoID := collSchema.AutoID
|
|
|
|
collID, err := globalMetaCache.GetCollectionID(collectionName)
|
|
|
|
if err != nil {
|
2020-11-20 17:53:31 +08:00
|
|
|
return err
|
|
|
|
}
|
2021-01-31 14:55:36 +08:00
|
|
|
it.CollectionID = collID
|
2021-02-03 16:40:23 +08:00
|
|
|
var partitionID UniqueID
|
|
|
|
if len(it.PartitionName) > 0 {
|
|
|
|
partitionID, err = globalMetaCache.GetPartitionID(collectionName, it.PartitionName)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
partitionID, err = globalMetaCache.GetPartitionID(collectionName, Params.DefaultPartitionTag)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2021-01-31 14:55:36 +08:00
|
|
|
}
|
|
|
|
it.PartitionID = partitionID
|
2020-11-30 12:08:47 +08:00
|
|
|
var rowIDBegin UniqueID
|
|
|
|
var rowIDEnd UniqueID
|
2020-12-03 19:00:11 +08:00
|
|
|
rowNums := len(it.BaseInsertTask.RowData)
|
|
|
|
rowIDBegin, rowIDEnd, _ = it.rowIDAllocator.Alloc(uint32(rowNums))
|
2021-02-03 16:34:56 +08:00
|
|
|
|
2020-12-03 19:00:11 +08:00
|
|
|
it.BaseInsertTask.RowIDs = make([]UniqueID, rowNums)
|
|
|
|
for i := rowIDBegin; i < rowIDEnd; i++ {
|
|
|
|
offset := i - rowIDBegin
|
|
|
|
it.BaseInsertTask.RowIDs[offset] = i
|
|
|
|
}
|
|
|
|
|
|
|
|
if autoID {
|
2020-11-30 19:38:23 +08:00
|
|
|
if it.HashValues == nil || len(it.HashValues) == 0 {
|
|
|
|
it.HashValues = make([]uint32, 0)
|
|
|
|
}
|
2020-12-03 19:00:11 +08:00
|
|
|
for _, rowID := range it.RowIDs {
|
|
|
|
hashValue, _ := typeutil.Hash32Int64(rowID)
|
2020-11-30 19:38:23 +08:00
|
|
|
it.HashValues = append(it.HashValues, hashValue)
|
2020-11-20 17:53:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-07 16:18:23 +08:00
|
|
|
var tsMsg msgstream.TsMsg = &it.BaseInsertTask
|
2020-11-05 18:01:33 +08:00
|
|
|
msgPack := &msgstream.MsgPack{
|
|
|
|
BeginTs: it.BeginTs(),
|
|
|
|
EndTs: it.EndTs(),
|
2020-11-17 14:10:07 +08:00
|
|
|
Msgs: make([]msgstream.TsMsg, 1),
|
2020-11-05 18:01:33 +08:00
|
|
|
}
|
2021-02-03 16:34:56 +08:00
|
|
|
tsMsg.SetMsgContext(it.Ctx())
|
2020-12-03 19:00:11 +08:00
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
it.result = &milvuspb.InsertResponse{
|
2020-11-14 18:18:10 +08:00
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_SUCCESS,
|
|
|
|
},
|
2021-01-22 09:36:18 +08:00
|
|
|
RowIDBegin: rowIDBegin,
|
|
|
|
RowIDEnd: rowIDEnd,
|
2020-11-14 18:18:10 +08:00
|
|
|
}
|
2021-01-30 15:30:38 +08:00
|
|
|
|
|
|
|
msgPack.Msgs[0] = tsMsg
|
|
|
|
|
2021-01-31 14:55:36 +08:00
|
|
|
stream, err := globalInsertChannelsMap.getInsertMsgStream(collID)
|
2021-01-30 15:30:38 +08:00
|
|
|
if err != nil {
|
|
|
|
collectionInsertChannels, err := it.dataServiceClient.GetInsertChannels(&datapb.InsertChannelRequest{
|
|
|
|
Base: &commonpb.MsgBase{
|
|
|
|
MsgType: commonpb.MsgType_kInsert, // todo
|
|
|
|
MsgID: it.Base.MsgID, // todo
|
|
|
|
Timestamp: 0, // todo
|
|
|
|
SourceID: Params.ProxyID,
|
|
|
|
},
|
|
|
|
DbID: 0, // todo
|
2021-01-31 14:55:36 +08:00
|
|
|
CollectionID: collID,
|
2021-01-30 15:30:38 +08:00
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2021-01-31 14:55:36 +08:00
|
|
|
err = globalInsertChannelsMap.createInsertMsgStream(collID, collectionInsertChannels)
|
2021-01-30 15:30:38 +08:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2021-01-31 14:55:36 +08:00
|
|
|
stream, err = globalInsertChannelsMap.getInsertMsgStream(collID)
|
2021-01-30 15:30:38 +08:00
|
|
|
if err != nil {
|
|
|
|
it.result.Status.ErrorCode = commonpb.ErrorCode_UNEXPECTED_ERROR
|
|
|
|
it.result.Status.Reason = err.Error()
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = stream.Produce(msgPack)
|
2020-11-14 18:18:10 +08:00
|
|
|
if err != nil {
|
|
|
|
it.result.Status.ErrorCode = commonpb.ErrorCode_UNEXPECTED_ERROR
|
|
|
|
it.result.Status.Reason = err.Error()
|
2021-01-30 15:30:38 +08:00
|
|
|
return err
|
2020-11-14 18:18:10 +08:00
|
|
|
}
|
2021-01-30 15:30:38 +08:00
|
|
|
|
2020-11-05 18:01:33 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (it *InsertTask) PostExecute() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type CreateCollectionTask struct {
|
2020-11-17 20:00:23 +08:00
|
|
|
Condition
|
2021-01-22 09:36:18 +08:00
|
|
|
*milvuspb.CreateCollectionRequest
|
2021-01-30 15:30:38 +08:00
|
|
|
masterClient MasterClient
|
|
|
|
dataServiceClient DataServiceClient
|
|
|
|
result *commonpb.Status
|
|
|
|
schema *schemapb.CollectionSchema
|
2020-11-05 18:01:33 +08:00
|
|
|
}
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
func (cct *CreateCollectionTask) OnEnqueue() error {
|
|
|
|
cct.Base = &commonpb.MsgBase{}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-11-12 12:04:12 +08:00
|
|
|
func (cct *CreateCollectionTask) ID() UniqueID {
|
2021-01-18 19:32:08 +08:00
|
|
|
return cct.Base.MsgID
|
2020-11-05 18:01:33 +08:00
|
|
|
}
|
|
|
|
|
2020-11-23 16:52:17 +08:00
|
|
|
func (cct *CreateCollectionTask) SetID(uid UniqueID) {
|
2021-01-18 19:32:08 +08:00
|
|
|
cct.Base.MsgID = uid
|
2020-11-23 16:52:17 +08:00
|
|
|
}
|
|
|
|
|
2021-01-16 15:06:19 +08:00
|
|
|
func (cct *CreateCollectionTask) Type() commonpb.MsgType {
|
2021-01-18 19:32:08 +08:00
|
|
|
return cct.Base.MsgType
|
2020-11-05 18:01:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (cct *CreateCollectionTask) BeginTs() Timestamp {
|
2021-01-18 19:32:08 +08:00
|
|
|
return cct.Base.Timestamp
|
2020-11-05 18:01:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (cct *CreateCollectionTask) EndTs() Timestamp {
|
2021-01-18 19:32:08 +08:00
|
|
|
return cct.Base.Timestamp
|
2020-11-05 18:01:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (cct *CreateCollectionTask) SetTs(ts Timestamp) {
|
2021-01-18 19:32:08 +08:00
|
|
|
cct.Base.Timestamp = ts
|
2020-11-05 18:01:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (cct *CreateCollectionTask) PreExecute() error {
|
2021-01-22 09:36:18 +08:00
|
|
|
cct.Base.MsgType = commonpb.MsgType_kCreateCollection
|
2021-01-28 20:51:44 +08:00
|
|
|
cct.Base.SourceID = Params.ProxyID
|
2021-01-22 09:36:18 +08:00
|
|
|
|
|
|
|
cct.schema = &schemapb.CollectionSchema{}
|
|
|
|
err := proto.Unmarshal(cct.Schema, cct.schema)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-01-28 20:51:44 +08:00
|
|
|
if int64(len(cct.schema.Fields)) > Params.MaxFieldNum {
|
|
|
|
return errors.New("maximum field's number should be limited to " + strconv.FormatInt(Params.MaxFieldNum, 10))
|
2020-11-26 16:01:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// validate collection name
|
|
|
|
if err := ValidateCollectionName(cct.schema.Name); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-11-30 19:38:23 +08:00
|
|
|
if err := ValidateDuplicatedFieldName(cct.schema.Fields); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := ValidatePrimaryKey(cct.schema); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-11-26 16:01:31 +08:00
|
|
|
// validate field name
|
|
|
|
for _, field := range cct.schema.Fields {
|
|
|
|
if err := ValidateFieldName(field.Name); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if field.DataType == schemapb.DataType_VECTOR_FLOAT || field.DataType == schemapb.DataType_VECTOR_BINARY {
|
|
|
|
exist := false
|
|
|
|
var dim int64 = 0
|
|
|
|
for _, param := range field.TypeParams {
|
|
|
|
if param.Key == "dim" {
|
|
|
|
exist = true
|
|
|
|
tmp, err := strconv.ParseInt(param.Value, 10, 64)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
dim = tmp
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if !exist {
|
|
|
|
return errors.New("dimension is not defined in field type params")
|
|
|
|
}
|
|
|
|
if field.DataType == schemapb.DataType_VECTOR_FLOAT {
|
|
|
|
if err := ValidateDimension(dim, false); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if err := ValidateDimension(dim, true); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-11-30 19:38:23 +08:00
|
|
|
if err := ValidateVectorFieldMetricType(field); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-11-26 16:01:31 +08:00
|
|
|
}
|
|
|
|
|
2020-11-05 18:01:33 +08:00
|
|
|
return nil
|
2020-11-03 14:53:36 +08:00
|
|
|
}
|
|
|
|
|
2020-11-05 18:01:33 +08:00
|
|
|
func (cct *CreateCollectionTask) Execute() error {
|
2021-01-22 09:36:18 +08:00
|
|
|
var err error
|
2021-01-28 20:51:44 +08:00
|
|
|
cct.result, err = cct.masterClient.CreateCollection(cct.CreateCollectionRequest)
|
2021-01-30 15:30:38 +08:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if cct.result.ErrorCode == commonpb.ErrorCode_SUCCESS {
|
2021-01-31 14:55:36 +08:00
|
|
|
collID, err := globalMetaCache.GetCollectionID(cct.CollectionName)
|
2021-01-30 15:30:38 +08:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
collectionInsertChannels, err := cct.dataServiceClient.GetInsertChannels(&datapb.InsertChannelRequest{
|
|
|
|
Base: &commonpb.MsgBase{
|
|
|
|
MsgType: commonpb.MsgType_kInsert, // todo
|
|
|
|
MsgID: cct.Base.MsgID, // todo
|
|
|
|
Timestamp: 0, // todo
|
|
|
|
SourceID: Params.ProxyID,
|
|
|
|
},
|
|
|
|
DbID: 0, // todo
|
2021-01-31 14:55:36 +08:00
|
|
|
CollectionID: collID,
|
2021-01-30 15:30:38 +08:00
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2021-01-31 14:55:36 +08:00
|
|
|
err = globalInsertChannelsMap.createInsertMsgStream(collID, collectionInsertChannels)
|
2021-01-30 15:30:38 +08:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
2020-11-03 14:53:36 +08:00
|
|
|
}
|
|
|
|
|
2020-11-05 18:01:33 +08:00
|
|
|
func (cct *CreateCollectionTask) PostExecute() error {
|
|
|
|
return nil
|
2020-11-03 14:53:36 +08:00
|
|
|
}
|
|
|
|
|
2020-11-09 17:25:53 +08:00
|
|
|
type DropCollectionTask struct {
|
2020-11-17 20:00:23 +08:00
|
|
|
Condition
|
2021-01-22 09:36:18 +08:00
|
|
|
*milvuspb.DropCollectionRequest
|
2021-02-02 10:58:39 +08:00
|
|
|
masterClient MasterClient
|
|
|
|
result *commonpb.Status
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
func (dct *DropCollectionTask) OnEnqueue() error {
|
|
|
|
dct.Base = &commonpb.MsgBase{}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-11-12 12:04:12 +08:00
|
|
|
func (dct *DropCollectionTask) ID() UniqueID {
|
2021-01-18 19:32:08 +08:00
|
|
|
return dct.Base.MsgID
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
2020-11-23 16:52:17 +08:00
|
|
|
func (dct *DropCollectionTask) SetID(uid UniqueID) {
|
2021-01-18 19:32:08 +08:00
|
|
|
dct.Base.MsgID = uid
|
2020-11-23 16:52:17 +08:00
|
|
|
}
|
|
|
|
|
2021-01-16 15:06:19 +08:00
|
|
|
func (dct *DropCollectionTask) Type() commonpb.MsgType {
|
2021-01-18 19:32:08 +08:00
|
|
|
return dct.Base.MsgType
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (dct *DropCollectionTask) BeginTs() Timestamp {
|
2021-01-18 19:32:08 +08:00
|
|
|
return dct.Base.Timestamp
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (dct *DropCollectionTask) EndTs() Timestamp {
|
2021-01-18 19:32:08 +08:00
|
|
|
return dct.Base.Timestamp
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (dct *DropCollectionTask) SetTs(ts Timestamp) {
|
2021-01-18 19:32:08 +08:00
|
|
|
dct.Base.Timestamp = ts
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (dct *DropCollectionTask) PreExecute() error {
|
2021-01-22 09:36:18 +08:00
|
|
|
dct.Base.MsgType = commonpb.MsgType_kDropCollection
|
2021-01-28 20:51:44 +08:00
|
|
|
dct.Base.SourceID = Params.ProxyID
|
2021-01-22 09:36:18 +08:00
|
|
|
|
2021-01-18 19:32:08 +08:00
|
|
|
if err := ValidateCollectionName(dct.CollectionName); err != nil {
|
2020-11-26 16:01:31 +08:00
|
|
|
return err
|
|
|
|
}
|
2020-11-09 17:25:53 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dct *DropCollectionTask) Execute() error {
|
2021-01-22 09:36:18 +08:00
|
|
|
var err error
|
2021-02-01 10:53:13 +08:00
|
|
|
collID, err := globalMetaCache.GetCollectionID(dct.CollectionName)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2021-01-28 20:51:44 +08:00
|
|
|
dct.result, err = dct.masterClient.DropCollection(dct.DropCollectionRequest)
|
2021-01-30 15:30:38 +08:00
|
|
|
if dct.result.ErrorCode == commonpb.ErrorCode_SUCCESS {
|
2021-01-31 14:55:36 +08:00
|
|
|
err = globalInsertChannelsMap.closeInsertMsgStream(collID)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2021-01-30 15:30:38 +08:00
|
|
|
}
|
2020-11-09 17:25:53 +08:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dct *DropCollectionTask) PostExecute() error {
|
2021-01-31 14:55:36 +08:00
|
|
|
globalMetaCache.RemoveCollection(dct.CollectionName)
|
2020-11-30 22:14:19 +08:00
|
|
|
return nil
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
2021-01-18 19:32:08 +08:00
|
|
|
type SearchTask struct {
|
2020-11-17 20:00:23 +08:00
|
|
|
Condition
|
2021-01-18 19:32:08 +08:00
|
|
|
internalpb2.SearchRequest
|
2021-01-20 10:02:59 +08:00
|
|
|
queryMsgStream *pulsarms.PulsarMsgStream
|
2021-01-18 19:32:08 +08:00
|
|
|
resultBuf chan []*internalpb2.SearchResults
|
2021-01-22 09:36:18 +08:00
|
|
|
result *milvuspb.SearchResults
|
|
|
|
query *milvuspb.SearchRequest
|
|
|
|
}
|
|
|
|
|
|
|
|
func (st *SearchTask) OnEnqueue() error {
|
|
|
|
return nil
|
2020-11-07 16:18:23 +08:00
|
|
|
}
|
|
|
|
|
2021-01-18 19:32:08 +08:00
|
|
|
func (st *SearchTask) ID() UniqueID {
|
|
|
|
return st.Base.MsgID
|
2020-11-07 16:18:23 +08:00
|
|
|
}
|
|
|
|
|
2021-01-18 19:32:08 +08:00
|
|
|
func (st *SearchTask) SetID(uid UniqueID) {
|
|
|
|
st.Base.MsgID = uid
|
2020-11-23 16:52:17 +08:00
|
|
|
}
|
|
|
|
|
2021-01-18 19:32:08 +08:00
|
|
|
func (st *SearchTask) Type() commonpb.MsgType {
|
|
|
|
return st.Base.MsgType
|
2020-11-07 16:18:23 +08:00
|
|
|
}
|
|
|
|
|
2021-01-18 19:32:08 +08:00
|
|
|
func (st *SearchTask) BeginTs() Timestamp {
|
|
|
|
return st.Base.Timestamp
|
2020-11-07 16:18:23 +08:00
|
|
|
}
|
|
|
|
|
2021-01-18 19:32:08 +08:00
|
|
|
func (st *SearchTask) EndTs() Timestamp {
|
|
|
|
return st.Base.Timestamp
|
2020-11-07 16:18:23 +08:00
|
|
|
}
|
|
|
|
|
2021-01-18 19:32:08 +08:00
|
|
|
func (st *SearchTask) SetTs(ts Timestamp) {
|
|
|
|
st.Base.Timestamp = ts
|
2020-11-07 16:18:23 +08:00
|
|
|
}
|
|
|
|
|
2021-01-18 19:32:08 +08:00
|
|
|
func (st *SearchTask) PreExecute() error {
|
2021-01-22 09:36:18 +08:00
|
|
|
st.Base.MsgType = commonpb.MsgType_kSearch
|
2021-01-28 20:51:44 +08:00
|
|
|
st.Base.SourceID = Params.ProxyID
|
2021-01-22 09:36:18 +08:00
|
|
|
|
2021-01-18 19:32:08 +08:00
|
|
|
collectionName := st.query.CollectionName
|
2021-01-31 14:55:36 +08:00
|
|
|
_, err := globalMetaCache.GetCollectionID(collectionName)
|
2020-11-30 19:08:32 +08:00
|
|
|
if err != nil { // err is not nil if collection not exists
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-01-18 19:32:08 +08:00
|
|
|
if err := ValidateCollectionName(st.query.CollectionName); err != nil {
|
2020-11-26 16:01:31 +08:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
for _, tag := range st.query.PartitionNames {
|
2020-11-26 16:01:31 +08:00
|
|
|
if err := ValidatePartitionTag(tag, false); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2021-01-18 19:32:08 +08:00
|
|
|
st.Base.MsgType = commonpb.MsgType_kSearch
|
|
|
|
queryBytes, err := proto.Marshal(st.query)
|
2020-11-28 19:06:48 +08:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2021-01-18 19:32:08 +08:00
|
|
|
st.Query = &commonpb.Blob{
|
2020-11-28 19:06:48 +08:00
|
|
|
Value: queryBytes,
|
|
|
|
}
|
2021-02-03 16:40:23 +08:00
|
|
|
|
|
|
|
st.ResultChannelID = Params.SearchResultChannelNames[0]
|
|
|
|
st.DbID = 0 // todo
|
|
|
|
collectionID, err := globalMetaCache.GetCollectionID(collectionName)
|
|
|
|
if err != nil { // err is not nil if collection not exists
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
st.CollectionID = collectionID
|
|
|
|
st.PartitionIDs = make([]UniqueID, 0)
|
|
|
|
for _, partitionName := range st.query.PartitionNames {
|
|
|
|
partitionID, err := globalMetaCache.GetPartitionID(collectionName, partitionName)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
st.PartitionIDs = append(st.PartitionIDs, partitionID)
|
|
|
|
}
|
|
|
|
st.Dsl = st.query.Dsl
|
|
|
|
st.PlaceholderGroup = st.query.PlaceholderGroup
|
|
|
|
|
2020-11-07 16:18:23 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-01-18 19:32:08 +08:00
|
|
|
func (st *SearchTask) Execute() error {
|
2020-11-07 16:18:23 +08:00
|
|
|
var tsMsg msgstream.TsMsg = &msgstream.SearchMsg{
|
2021-01-18 19:32:08 +08:00
|
|
|
SearchRequest: st.SearchRequest,
|
2020-11-07 16:18:23 +08:00
|
|
|
BaseMsg: msgstream.BaseMsg{
|
2021-01-28 20:51:44 +08:00
|
|
|
HashValues: []uint32{uint32(Params.ProxyID)},
|
2021-01-18 19:32:08 +08:00
|
|
|
BeginTimestamp: st.Base.Timestamp,
|
|
|
|
EndTimestamp: st.Base.Timestamp,
|
2020-11-07 16:18:23 +08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
msgPack := &msgstream.MsgPack{
|
2021-01-18 19:32:08 +08:00
|
|
|
BeginTs: st.Base.Timestamp,
|
|
|
|
EndTs: st.Base.Timestamp,
|
2020-11-17 14:10:07 +08:00
|
|
|
Msgs: make([]msgstream.TsMsg, 1),
|
2020-11-07 16:18:23 +08:00
|
|
|
}
|
2021-02-03 16:34:56 +08:00
|
|
|
tsMsg.SetMsgContext(st.Ctx())
|
2020-11-17 14:10:07 +08:00
|
|
|
msgPack.Msgs[0] = tsMsg
|
2021-01-18 19:32:08 +08:00
|
|
|
err := st.queryMsgStream.Produce(msgPack)
|
2021-01-22 09:36:18 +08:00
|
|
|
log.Printf("[NodeImpl] length of searchMsg: %v", len(msgPack.Msgs))
|
2020-11-28 19:06:48 +08:00
|
|
|
if err != nil {
|
2021-01-22 09:36:18 +08:00
|
|
|
log.Printf("[NodeImpl] send search request failed: %v", err)
|
2020-11-28 19:06:48 +08:00
|
|
|
}
|
|
|
|
return err
|
2020-11-07 16:18:23 +08:00
|
|
|
}
|
|
|
|
|
2021-01-18 19:32:08 +08:00
|
|
|
func (st *SearchTask) PostExecute() error {
|
2020-11-07 16:18:23 +08:00
|
|
|
for {
|
|
|
|
select {
|
2021-02-03 16:34:56 +08:00
|
|
|
case <-st.Ctx().Done():
|
2021-01-23 20:58:46 +08:00
|
|
|
log.Print("SearchTask: wait to finish failed, timeout!, taskID:", st.ID())
|
|
|
|
return errors.New("SearchTask:wait to finish failed, timeout:" + strconv.FormatInt(st.ID(), 10))
|
2021-01-18 19:32:08 +08:00
|
|
|
case searchResults := <-st.resultBuf:
|
2021-01-23 20:58:46 +08:00
|
|
|
// fmt.Println("searchResults: ", searchResults)
|
2021-01-18 19:32:08 +08:00
|
|
|
filterSearchResult := make([]*internalpb2.SearchResults, 0)
|
2020-11-30 22:14:19 +08:00
|
|
|
var filterReason string
|
2020-11-30 19:08:32 +08:00
|
|
|
for _, partialSearchResult := range searchResults {
|
|
|
|
if partialSearchResult.Status.ErrorCode == commonpb.ErrorCode_SUCCESS {
|
|
|
|
filterSearchResult = append(filterSearchResult, partialSearchResult)
|
2021-01-18 19:32:08 +08:00
|
|
|
// For debugging, please don't delete.
|
|
|
|
//for i := 0; i < len(partialSearchResult.Hits); i++ {
|
|
|
|
// testHits := milvuspb.Hits{}
|
|
|
|
// err := proto.Unmarshal(partialSearchResult.Hits[i], &testHits)
|
|
|
|
// if err != nil {
|
|
|
|
// panic(err)
|
|
|
|
// }
|
|
|
|
// fmt.Println(testHits.IDs)
|
|
|
|
// fmt.Println(testHits.Scores)
|
|
|
|
//}
|
2020-11-30 22:14:19 +08:00
|
|
|
} else {
|
|
|
|
filterReason += partialSearchResult.Status.Reason + "\n"
|
2020-11-30 19:08:32 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-10 16:31:09 +08:00
|
|
|
availableQueryNodeNum := len(filterSearchResult)
|
|
|
|
if availableQueryNodeNum <= 0 {
|
2021-01-22 09:36:18 +08:00
|
|
|
st.result = &milvuspb.SearchResults{
|
2020-11-30 22:14:19 +08:00
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
|
|
|
|
Reason: filterReason,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
return errors.New(filterReason)
|
2020-11-07 16:18:23 +08:00
|
|
|
}
|
2020-11-28 19:06:48 +08:00
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
hits := make([][]*milvuspb.Hits, 0)
|
2020-12-10 16:31:09 +08:00
|
|
|
for _, partialSearchResult := range filterSearchResult {
|
2021-01-12 18:03:24 +08:00
|
|
|
if partialSearchResult.Hits == nil || len(partialSearchResult.Hits) <= 0 {
|
2020-12-10 16:31:09 +08:00
|
|
|
filterReason += "nq is zero\n"
|
|
|
|
continue
|
|
|
|
}
|
2021-01-22 09:36:18 +08:00
|
|
|
partialHits := make([]*milvuspb.Hits, 0)
|
2020-12-10 16:31:09 +08:00
|
|
|
for _, bs := range partialSearchResult.Hits {
|
2021-01-22 09:36:18 +08:00
|
|
|
partialHit := &milvuspb.Hits{}
|
2020-12-10 16:31:09 +08:00
|
|
|
err := proto.Unmarshal(bs, partialHit)
|
2020-11-26 16:01:31 +08:00
|
|
|
if err != nil {
|
2020-11-30 11:22:59 +08:00
|
|
|
log.Println("unmarshal error")
|
2020-11-26 16:01:31 +08:00
|
|
|
return err
|
|
|
|
}
|
2020-12-10 16:31:09 +08:00
|
|
|
partialHits = append(partialHits, partialHit)
|
|
|
|
}
|
|
|
|
hits = append(hits, partialHits)
|
|
|
|
}
|
|
|
|
|
|
|
|
availableQueryNodeNum = len(hits)
|
|
|
|
if availableQueryNodeNum <= 0 {
|
2021-01-22 09:36:18 +08:00
|
|
|
st.result = &milvuspb.SearchResults{
|
2020-12-10 16:31:09 +08:00
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_SUCCESS,
|
|
|
|
Reason: filterReason,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
nq := len(hits[0])
|
|
|
|
if nq <= 0 {
|
2021-01-22 09:36:18 +08:00
|
|
|
st.result = &milvuspb.SearchResults{
|
2020-12-10 16:31:09 +08:00
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_SUCCESS,
|
|
|
|
Reason: filterReason,
|
|
|
|
},
|
2020-11-26 16:01:31 +08:00
|
|
|
}
|
2020-12-10 16:31:09 +08:00
|
|
|
return nil
|
2020-11-26 16:01:31 +08:00
|
|
|
}
|
2020-11-28 19:06:48 +08:00
|
|
|
|
2021-01-12 18:03:24 +08:00
|
|
|
topk := 0
|
|
|
|
getMax := func(a, b int) int {
|
|
|
|
if a > b {
|
|
|
|
return a
|
|
|
|
}
|
|
|
|
return b
|
|
|
|
}
|
|
|
|
for _, hit := range hits {
|
|
|
|
topk = getMax(topk, len(hit[0].IDs))
|
|
|
|
}
|
2021-01-22 09:36:18 +08:00
|
|
|
st.result = &milvuspb.SearchResults{
|
2020-11-07 16:18:23 +08:00
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: 0,
|
|
|
|
},
|
2020-11-28 19:06:48 +08:00
|
|
|
Hits: make([][]byte, 0),
|
2020-11-07 16:18:23 +08:00
|
|
|
}
|
2020-11-28 19:06:48 +08:00
|
|
|
|
2020-12-27 09:05:24 +08:00
|
|
|
const minFloat32 = -1 * float32(math.MaxFloat32)
|
2020-12-10 16:31:09 +08:00
|
|
|
for i := 0; i < nq; i++ {
|
|
|
|
locs := make([]int, availableQueryNodeNum)
|
2021-01-22 09:36:18 +08:00
|
|
|
reducedHits := &milvuspb.Hits{
|
2020-11-28 19:06:48 +08:00
|
|
|
IDs: make([]int64, 0),
|
|
|
|
RowData: make([][]byte, 0),
|
|
|
|
Scores: make([]float32, 0),
|
|
|
|
}
|
|
|
|
|
2020-12-10 16:31:09 +08:00
|
|
|
for j := 0; j < topk; j++ {
|
2021-01-12 18:03:24 +08:00
|
|
|
valid := false
|
2020-12-27 09:05:24 +08:00
|
|
|
choice, maxDistance := 0, minFloat32
|
2020-11-07 16:18:23 +08:00
|
|
|
for q, loc := range locs { // query num, the number of ways to merge
|
2021-01-12 18:03:24 +08:00
|
|
|
if loc >= len(hits[q][i].IDs) {
|
|
|
|
continue
|
|
|
|
}
|
2020-11-26 16:01:31 +08:00
|
|
|
distance := hits[q][i].Scores[loc]
|
2021-01-13 13:36:27 +08:00
|
|
|
if distance > maxDistance || (math.Abs(float64(distance-maxDistance)) < math.SmallestNonzeroFloat32 && choice != q) {
|
2020-11-07 16:18:23 +08:00
|
|
|
choice = q
|
2020-12-27 09:05:24 +08:00
|
|
|
maxDistance = distance
|
2021-01-12 18:03:24 +08:00
|
|
|
valid = true
|
2020-11-07 16:18:23 +08:00
|
|
|
}
|
|
|
|
}
|
2021-01-12 18:03:24 +08:00
|
|
|
if !valid {
|
|
|
|
break
|
|
|
|
}
|
2020-11-07 16:18:23 +08:00
|
|
|
choiceOffset := locs[choice]
|
2020-11-30 19:08:32 +08:00
|
|
|
// check if distance is valid, `invalid` here means very very big,
|
|
|
|
// in this process, distance here is the smallest, so the rest of distance are all invalid
|
2020-12-27 09:05:24 +08:00
|
|
|
if hits[choice][i].Scores[choiceOffset] <= minFloat32 {
|
2020-12-01 02:16:53 +08:00
|
|
|
break
|
2020-11-30 19:08:32 +08:00
|
|
|
}
|
2020-11-26 16:01:31 +08:00
|
|
|
reducedHits.IDs = append(reducedHits.IDs, hits[choice][i].IDs[choiceOffset])
|
2020-11-28 19:06:48 +08:00
|
|
|
if hits[choice][i].RowData != nil && len(hits[choice][i].RowData) > 0 {
|
|
|
|
reducedHits.RowData = append(reducedHits.RowData, hits[choice][i].RowData[choiceOffset])
|
|
|
|
}
|
2020-11-26 16:01:31 +08:00
|
|
|
reducedHits.Scores = append(reducedHits.Scores, hits[choice][i].Scores[choiceOffset])
|
2020-11-07 16:18:23 +08:00
|
|
|
locs[choice]++
|
|
|
|
}
|
2020-12-27 09:05:24 +08:00
|
|
|
if searchResults[0].MetricType != "IP" {
|
|
|
|
for k := range reducedHits.Scores {
|
|
|
|
reducedHits.Scores[k] *= -1
|
|
|
|
}
|
|
|
|
}
|
2020-11-26 16:01:31 +08:00
|
|
|
reducedHitsBs, err := proto.Marshal(reducedHits)
|
|
|
|
if err != nil {
|
2020-11-30 11:22:59 +08:00
|
|
|
log.Println("marshal error")
|
2020-11-26 16:01:31 +08:00
|
|
|
return err
|
|
|
|
}
|
2021-01-18 19:32:08 +08:00
|
|
|
st.result.Hits = append(st.result.Hits, reducedHitsBs)
|
2020-11-07 16:18:23 +08:00
|
|
|
}
|
2020-11-28 19:06:48 +08:00
|
|
|
return nil
|
2020-11-07 16:18:23 +08:00
|
|
|
}
|
|
|
|
}
|
2020-11-16 17:01:10 +08:00
|
|
|
}
|
|
|
|
|
2020-11-09 17:25:53 +08:00
|
|
|
type HasCollectionTask struct {
|
2020-11-17 20:00:23 +08:00
|
|
|
Condition
|
2021-01-22 09:36:18 +08:00
|
|
|
*milvuspb.HasCollectionRequest
|
2021-01-29 09:27:26 +08:00
|
|
|
masterClient MasterClient
|
2021-01-22 09:36:18 +08:00
|
|
|
result *milvuspb.BoolResponse
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
func (hct *HasCollectionTask) OnEnqueue() error {
|
|
|
|
hct.Base = &commonpb.MsgBase{}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-11-12 12:04:12 +08:00
|
|
|
func (hct *HasCollectionTask) ID() UniqueID {
|
2021-01-18 19:32:08 +08:00
|
|
|
return hct.Base.MsgID
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
2020-11-23 16:52:17 +08:00
|
|
|
func (hct *HasCollectionTask) SetID(uid UniqueID) {
|
2021-01-18 19:32:08 +08:00
|
|
|
hct.Base.MsgID = uid
|
2020-11-23 16:52:17 +08:00
|
|
|
}
|
|
|
|
|
2021-01-16 15:06:19 +08:00
|
|
|
func (hct *HasCollectionTask) Type() commonpb.MsgType {
|
2021-01-18 19:32:08 +08:00
|
|
|
return hct.Base.MsgType
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (hct *HasCollectionTask) BeginTs() Timestamp {
|
2021-01-18 19:32:08 +08:00
|
|
|
return hct.Base.Timestamp
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (hct *HasCollectionTask) EndTs() Timestamp {
|
2021-01-18 19:32:08 +08:00
|
|
|
return hct.Base.Timestamp
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (hct *HasCollectionTask) SetTs(ts Timestamp) {
|
2021-01-18 19:32:08 +08:00
|
|
|
hct.Base.Timestamp = ts
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (hct *HasCollectionTask) PreExecute() error {
|
2021-01-22 09:36:18 +08:00
|
|
|
hct.Base.MsgType = commonpb.MsgType_kHasCollection
|
2021-01-28 20:51:44 +08:00
|
|
|
hct.Base.SourceID = Params.ProxyID
|
2021-01-22 09:36:18 +08:00
|
|
|
|
2021-01-18 19:32:08 +08:00
|
|
|
if err := ValidateCollectionName(hct.CollectionName); err != nil {
|
2020-11-26 16:01:31 +08:00
|
|
|
return err
|
|
|
|
}
|
2020-11-09 17:25:53 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (hct *HasCollectionTask) Execute() error {
|
2021-01-22 09:36:18 +08:00
|
|
|
var err error
|
2021-01-28 20:51:44 +08:00
|
|
|
hct.result, err = hct.masterClient.HasCollection(hct.HasCollectionRequest)
|
2020-11-09 17:25:53 +08:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (hct *HasCollectionTask) PostExecute() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type DescribeCollectionTask struct {
|
2020-11-17 20:00:23 +08:00
|
|
|
Condition
|
2021-01-22 09:36:18 +08:00
|
|
|
*milvuspb.DescribeCollectionRequest
|
2021-01-29 09:27:26 +08:00
|
|
|
masterClient MasterClient
|
2021-01-22 09:36:18 +08:00
|
|
|
result *milvuspb.DescribeCollectionResponse
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
func (dct *DescribeCollectionTask) OnEnqueue() error {
|
|
|
|
dct.Base = &commonpb.MsgBase{}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-11-12 12:04:12 +08:00
|
|
|
func (dct *DescribeCollectionTask) ID() UniqueID {
|
2021-01-18 19:32:08 +08:00
|
|
|
return dct.Base.MsgID
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
2020-11-23 16:52:17 +08:00
|
|
|
func (dct *DescribeCollectionTask) SetID(uid UniqueID) {
|
2021-01-18 19:32:08 +08:00
|
|
|
dct.Base.MsgID = uid
|
2020-11-23 16:52:17 +08:00
|
|
|
}
|
|
|
|
|
2021-01-16 15:06:19 +08:00
|
|
|
func (dct *DescribeCollectionTask) Type() commonpb.MsgType {
|
2021-01-18 19:32:08 +08:00
|
|
|
return dct.Base.MsgType
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (dct *DescribeCollectionTask) BeginTs() Timestamp {
|
2021-01-18 19:32:08 +08:00
|
|
|
return dct.Base.Timestamp
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (dct *DescribeCollectionTask) EndTs() Timestamp {
|
2021-01-18 19:32:08 +08:00
|
|
|
return dct.Base.Timestamp
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (dct *DescribeCollectionTask) SetTs(ts Timestamp) {
|
2021-01-18 19:32:08 +08:00
|
|
|
dct.Base.Timestamp = ts
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (dct *DescribeCollectionTask) PreExecute() error {
|
2021-01-22 09:36:18 +08:00
|
|
|
dct.Base.MsgType = commonpb.MsgType_kDescribeCollection
|
2021-01-28 20:51:44 +08:00
|
|
|
dct.Base.SourceID = Params.ProxyID
|
2021-01-22 09:36:18 +08:00
|
|
|
|
2021-01-18 19:32:08 +08:00
|
|
|
if err := ValidateCollectionName(dct.CollectionName); err != nil {
|
2020-11-26 16:01:31 +08:00
|
|
|
return err
|
|
|
|
}
|
2020-11-09 17:25:53 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dct *DescribeCollectionTask) Execute() error {
|
2021-01-22 09:36:18 +08:00
|
|
|
var err error
|
2021-01-28 20:51:44 +08:00
|
|
|
dct.result, err = dct.masterClient.DescribeCollection(dct.DescribeCollectionRequest)
|
2021-01-11 18:35:54 +08:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2021-01-31 14:55:36 +08:00
|
|
|
return nil
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (dct *DescribeCollectionTask) PostExecute() error {
|
2021-02-02 19:54:31 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type GetCollectionsStatisticsTask struct {
|
|
|
|
Condition
|
|
|
|
*milvuspb.CollectionStatsRequest
|
|
|
|
dataServiceClient DataServiceClient
|
|
|
|
result *milvuspb.CollectionStatsResponse
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *GetCollectionsStatisticsTask) ID() UniqueID {
|
|
|
|
return g.Base.MsgID
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *GetCollectionsStatisticsTask) SetID(uid UniqueID) {
|
|
|
|
g.Base.MsgID = uid
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *GetCollectionsStatisticsTask) Type() commonpb.MsgType {
|
|
|
|
return g.Base.MsgType
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *GetCollectionsStatisticsTask) BeginTs() Timestamp {
|
|
|
|
return g.Base.Timestamp
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *GetCollectionsStatisticsTask) EndTs() Timestamp {
|
|
|
|
return g.Base.Timestamp
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *GetCollectionsStatisticsTask) SetTs(ts Timestamp) {
|
|
|
|
g.Base.Timestamp = ts
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *GetCollectionsStatisticsTask) OnEnqueue() error {
|
|
|
|
g.Base = &commonpb.MsgBase{}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *GetCollectionsStatisticsTask) PreExecute() error {
|
|
|
|
g.Base.MsgType = commonpb.MsgType_kGetCollectionStatistics
|
|
|
|
g.Base.SourceID = Params.ProxyID
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *GetCollectionsStatisticsTask) Execute() error {
|
|
|
|
collID, err := globalMetaCache.GetCollectionID(g.CollectionName)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
req := &datapb.CollectionStatsRequest{
|
|
|
|
Base: &commonpb.MsgBase{
|
|
|
|
MsgType: commonpb.MsgType_kGetCollectionStatistics,
|
|
|
|
MsgID: g.Base.MsgID,
|
|
|
|
Timestamp: g.Base.Timestamp,
|
|
|
|
SourceID: g.Base.SourceID,
|
|
|
|
},
|
|
|
|
CollectionID: collID,
|
|
|
|
}
|
|
|
|
|
|
|
|
result, err := g.dataServiceClient.GetCollectionStatistics(req)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
g.result = &milvuspb.CollectionStatsResponse{
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_SUCCESS,
|
|
|
|
Reason: "",
|
|
|
|
},
|
|
|
|
Stats: result.Stats,
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *GetCollectionsStatisticsTask) PostExecute() error {
|
2020-11-09 17:25:53 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type ShowCollectionsTask struct {
|
2020-11-17 20:00:23 +08:00
|
|
|
Condition
|
2021-01-22 09:36:18 +08:00
|
|
|
*milvuspb.ShowCollectionRequest
|
2021-01-29 09:27:26 +08:00
|
|
|
masterClient MasterClient
|
2021-01-22 09:36:18 +08:00
|
|
|
result *milvuspb.ShowCollectionResponse
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
func (sct *ShowCollectionsTask) OnEnqueue() error {
|
|
|
|
sct.Base = &commonpb.MsgBase{}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-11-12 12:04:12 +08:00
|
|
|
func (sct *ShowCollectionsTask) ID() UniqueID {
|
2021-01-18 19:32:08 +08:00
|
|
|
return sct.Base.MsgID
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
2020-11-23 16:52:17 +08:00
|
|
|
func (sct *ShowCollectionsTask) SetID(uid UniqueID) {
|
2021-01-18 19:32:08 +08:00
|
|
|
sct.Base.MsgID = uid
|
2020-11-23 16:52:17 +08:00
|
|
|
}
|
|
|
|
|
2021-01-16 15:06:19 +08:00
|
|
|
func (sct *ShowCollectionsTask) Type() commonpb.MsgType {
|
2021-01-18 19:32:08 +08:00
|
|
|
return sct.Base.MsgType
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (sct *ShowCollectionsTask) BeginTs() Timestamp {
|
2021-01-18 19:32:08 +08:00
|
|
|
return sct.Base.Timestamp
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (sct *ShowCollectionsTask) EndTs() Timestamp {
|
2021-01-18 19:32:08 +08:00
|
|
|
return sct.Base.Timestamp
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (sct *ShowCollectionsTask) SetTs(ts Timestamp) {
|
2021-01-18 19:32:08 +08:00
|
|
|
sct.Base.Timestamp = ts
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (sct *ShowCollectionsTask) PreExecute() error {
|
2021-01-22 09:36:18 +08:00
|
|
|
sct.Base.MsgType = commonpb.MsgType_kShowCollections
|
2021-01-28 20:51:44 +08:00
|
|
|
sct.Base.SourceID = Params.ProxyID
|
2021-01-22 09:36:18 +08:00
|
|
|
|
2020-11-09 17:25:53 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (sct *ShowCollectionsTask) Execute() error {
|
2021-01-22 09:36:18 +08:00
|
|
|
var err error
|
2021-01-28 20:51:44 +08:00
|
|
|
sct.result, err = sct.masterClient.ShowCollections(sct.ShowCollectionRequest)
|
2020-11-09 17:25:53 +08:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (sct *ShowCollectionsTask) PostExecute() error {
|
|
|
|
return nil
|
|
|
|
}
|
2020-11-19 17:09:22 +08:00
|
|
|
|
|
|
|
type CreatePartitionTask struct {
|
|
|
|
Condition
|
2021-01-22 09:36:18 +08:00
|
|
|
*milvuspb.CreatePartitionRequest
|
2021-01-29 09:27:26 +08:00
|
|
|
masterClient MasterClient
|
2020-11-19 17:09:22 +08:00
|
|
|
result *commonpb.Status
|
|
|
|
}
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
func (cpt *CreatePartitionTask) OnEnqueue() error {
|
|
|
|
cpt.Base = &commonpb.MsgBase{}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-11-19 17:09:22 +08:00
|
|
|
func (cpt *CreatePartitionTask) ID() UniqueID {
|
2021-01-18 19:32:08 +08:00
|
|
|
return cpt.Base.MsgID
|
2020-11-19 17:09:22 +08:00
|
|
|
}
|
|
|
|
|
2020-11-23 16:52:17 +08:00
|
|
|
func (cpt *CreatePartitionTask) SetID(uid UniqueID) {
|
2021-01-18 19:32:08 +08:00
|
|
|
cpt.Base.MsgID = uid
|
2020-11-23 16:52:17 +08:00
|
|
|
}
|
|
|
|
|
2021-01-16 15:06:19 +08:00
|
|
|
func (cpt *CreatePartitionTask) Type() commonpb.MsgType {
|
2021-01-18 19:32:08 +08:00
|
|
|
return cpt.Base.MsgType
|
2020-11-19 17:09:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (cpt *CreatePartitionTask) BeginTs() Timestamp {
|
2021-01-18 19:32:08 +08:00
|
|
|
return cpt.Base.Timestamp
|
2020-11-19 17:09:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (cpt *CreatePartitionTask) EndTs() Timestamp {
|
2021-01-18 19:32:08 +08:00
|
|
|
return cpt.Base.Timestamp
|
2020-11-19 17:09:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (cpt *CreatePartitionTask) SetTs(ts Timestamp) {
|
2021-01-18 19:32:08 +08:00
|
|
|
cpt.Base.Timestamp = ts
|
2020-11-19 17:09:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (cpt *CreatePartitionTask) PreExecute() error {
|
2021-01-22 09:36:18 +08:00
|
|
|
cpt.Base.MsgType = commonpb.MsgType_kCreatePartition
|
2021-01-28 20:51:44 +08:00
|
|
|
cpt.Base.SourceID = Params.ProxyID
|
2021-01-22 09:36:18 +08:00
|
|
|
|
2021-01-18 19:32:08 +08:00
|
|
|
collName, partitionTag := cpt.CollectionName, cpt.PartitionName
|
2020-11-26 16:01:31 +08:00
|
|
|
|
|
|
|
if err := ValidateCollectionName(collName); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := ValidatePartitionTag(partitionTag, true); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-11-19 17:09:22 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cpt *CreatePartitionTask) Execute() (err error) {
|
2021-01-28 20:51:44 +08:00
|
|
|
cpt.result, err = cpt.masterClient.CreatePartition(cpt.CreatePartitionRequest)
|
2020-11-19 17:09:22 +08:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cpt *CreatePartitionTask) PostExecute() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type DropPartitionTask struct {
|
|
|
|
Condition
|
2021-01-22 09:36:18 +08:00
|
|
|
*milvuspb.DropPartitionRequest
|
2021-01-29 09:27:26 +08:00
|
|
|
masterClient MasterClient
|
2020-11-19 17:09:22 +08:00
|
|
|
result *commonpb.Status
|
|
|
|
}
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
func (dpt *DropPartitionTask) OnEnqueue() error {
|
|
|
|
dpt.Base = &commonpb.MsgBase{}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-11-19 17:09:22 +08:00
|
|
|
func (dpt *DropPartitionTask) ID() UniqueID {
|
2021-01-18 19:32:08 +08:00
|
|
|
return dpt.Base.MsgID
|
2020-11-19 17:09:22 +08:00
|
|
|
}
|
|
|
|
|
2020-11-23 16:52:17 +08:00
|
|
|
func (dpt *DropPartitionTask) SetID(uid UniqueID) {
|
2021-01-18 19:32:08 +08:00
|
|
|
dpt.Base.MsgID = uid
|
2020-11-23 16:52:17 +08:00
|
|
|
}
|
|
|
|
|
2021-01-16 15:06:19 +08:00
|
|
|
func (dpt *DropPartitionTask) Type() commonpb.MsgType {
|
2021-01-18 19:32:08 +08:00
|
|
|
return dpt.Base.MsgType
|
2020-11-19 17:09:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (dpt *DropPartitionTask) BeginTs() Timestamp {
|
2021-01-18 19:32:08 +08:00
|
|
|
return dpt.Base.Timestamp
|
2020-11-19 17:09:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (dpt *DropPartitionTask) EndTs() Timestamp {
|
2021-01-18 19:32:08 +08:00
|
|
|
return dpt.Base.Timestamp
|
2020-11-19 17:09:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (dpt *DropPartitionTask) SetTs(ts Timestamp) {
|
2021-01-18 19:32:08 +08:00
|
|
|
dpt.Base.Timestamp = ts
|
2020-11-19 17:09:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (dpt *DropPartitionTask) PreExecute() error {
|
2021-01-22 09:36:18 +08:00
|
|
|
dpt.Base.MsgType = commonpb.MsgType_kDropPartition
|
2021-01-28 20:51:44 +08:00
|
|
|
dpt.Base.SourceID = Params.ProxyID
|
2021-01-22 09:36:18 +08:00
|
|
|
|
2021-01-18 19:32:08 +08:00
|
|
|
collName, partitionTag := dpt.CollectionName, dpt.PartitionName
|
2020-11-26 16:01:31 +08:00
|
|
|
|
|
|
|
if err := ValidateCollectionName(collName); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := ValidatePartitionTag(partitionTag, true); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-11-19 17:09:22 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dpt *DropPartitionTask) Execute() (err error) {
|
2021-01-28 20:51:44 +08:00
|
|
|
dpt.result, err = dpt.masterClient.DropPartition(dpt.DropPartitionRequest)
|
2020-11-19 17:09:22 +08:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dpt *DropPartitionTask) PostExecute() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type HasPartitionTask struct {
|
|
|
|
Condition
|
2021-01-22 09:36:18 +08:00
|
|
|
*milvuspb.HasPartitionRequest
|
2021-01-29 09:27:26 +08:00
|
|
|
masterClient MasterClient
|
2021-01-22 09:36:18 +08:00
|
|
|
result *milvuspb.BoolResponse
|
2020-11-19 17:09:22 +08:00
|
|
|
}
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
func (hpt *HasPartitionTask) OnEnqueue() error {
|
|
|
|
hpt.Base = &commonpb.MsgBase{}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-11-19 17:09:22 +08:00
|
|
|
func (hpt *HasPartitionTask) ID() UniqueID {
|
2021-01-18 19:32:08 +08:00
|
|
|
return hpt.Base.MsgID
|
2020-11-19 17:09:22 +08:00
|
|
|
}
|
|
|
|
|
2020-11-23 16:52:17 +08:00
|
|
|
func (hpt *HasPartitionTask) SetID(uid UniqueID) {
|
2021-01-18 19:32:08 +08:00
|
|
|
hpt.Base.MsgID = uid
|
2020-11-23 16:52:17 +08:00
|
|
|
}
|
|
|
|
|
2021-01-16 15:06:19 +08:00
|
|
|
func (hpt *HasPartitionTask) Type() commonpb.MsgType {
|
2021-01-18 19:32:08 +08:00
|
|
|
return hpt.Base.MsgType
|
2020-11-19 17:09:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (hpt *HasPartitionTask) BeginTs() Timestamp {
|
2021-01-18 19:32:08 +08:00
|
|
|
return hpt.Base.Timestamp
|
2020-11-19 17:09:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (hpt *HasPartitionTask) EndTs() Timestamp {
|
2021-01-18 19:32:08 +08:00
|
|
|
return hpt.Base.Timestamp
|
2020-11-19 17:09:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (hpt *HasPartitionTask) SetTs(ts Timestamp) {
|
2021-01-18 19:32:08 +08:00
|
|
|
hpt.Base.Timestamp = ts
|
2020-11-19 17:09:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (hpt *HasPartitionTask) PreExecute() error {
|
2021-01-22 09:36:18 +08:00
|
|
|
hpt.Base.MsgType = commonpb.MsgType_kHasPartition
|
2021-01-28 20:51:44 +08:00
|
|
|
hpt.Base.SourceID = Params.ProxyID
|
2021-01-22 09:36:18 +08:00
|
|
|
|
2021-01-18 19:32:08 +08:00
|
|
|
collName, partitionTag := hpt.CollectionName, hpt.PartitionName
|
2020-11-26 16:01:31 +08:00
|
|
|
|
|
|
|
if err := ValidateCollectionName(collName); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := ValidatePartitionTag(partitionTag, true); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-11-19 17:09:22 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (hpt *HasPartitionTask) Execute() (err error) {
|
2021-01-28 20:51:44 +08:00
|
|
|
hpt.result, err = hpt.masterClient.HasPartition(hpt.HasPartitionRequest)
|
2020-11-19 17:09:22 +08:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (hpt *HasPartitionTask) PostExecute() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type ShowPartitionsTask struct {
|
|
|
|
Condition
|
2021-01-22 09:36:18 +08:00
|
|
|
*milvuspb.ShowPartitionRequest
|
2021-01-29 09:27:26 +08:00
|
|
|
masterClient MasterClient
|
2021-01-22 09:36:18 +08:00
|
|
|
result *milvuspb.ShowPartitionResponse
|
2020-11-19 17:09:22 +08:00
|
|
|
}
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
func (spt *ShowPartitionsTask) OnEnqueue() error {
|
|
|
|
spt.Base = &commonpb.MsgBase{}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-11-19 17:09:22 +08:00
|
|
|
func (spt *ShowPartitionsTask) ID() UniqueID {
|
2021-01-18 19:32:08 +08:00
|
|
|
return spt.Base.MsgID
|
2020-11-19 17:09:22 +08:00
|
|
|
}
|
|
|
|
|
2020-11-23 16:52:17 +08:00
|
|
|
func (spt *ShowPartitionsTask) SetID(uid UniqueID) {
|
2021-01-18 19:32:08 +08:00
|
|
|
spt.Base.MsgID = uid
|
2020-11-23 16:52:17 +08:00
|
|
|
}
|
|
|
|
|
2021-01-16 15:06:19 +08:00
|
|
|
func (spt *ShowPartitionsTask) Type() commonpb.MsgType {
|
2021-01-18 19:32:08 +08:00
|
|
|
return spt.Base.MsgType
|
2020-11-19 17:09:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (spt *ShowPartitionsTask) BeginTs() Timestamp {
|
2021-01-18 19:32:08 +08:00
|
|
|
return spt.Base.Timestamp
|
2020-11-19 17:09:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (spt *ShowPartitionsTask) EndTs() Timestamp {
|
2021-01-18 19:32:08 +08:00
|
|
|
return spt.Base.Timestamp
|
2020-11-19 17:09:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (spt *ShowPartitionsTask) SetTs(ts Timestamp) {
|
2021-01-18 19:32:08 +08:00
|
|
|
spt.Base.Timestamp = ts
|
2020-11-19 17:09:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (spt *ShowPartitionsTask) PreExecute() error {
|
2021-01-22 09:36:18 +08:00
|
|
|
spt.Base.MsgType = commonpb.MsgType_kShowPartitions
|
2021-01-28 20:51:44 +08:00
|
|
|
spt.Base.SourceID = Params.ProxyID
|
2021-01-22 09:36:18 +08:00
|
|
|
|
2021-01-18 19:32:08 +08:00
|
|
|
if err := ValidateCollectionName(spt.CollectionName); err != nil {
|
2020-11-26 16:01:31 +08:00
|
|
|
return err
|
|
|
|
}
|
2020-11-19 17:09:22 +08:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-01-18 19:32:08 +08:00
|
|
|
func (spt *ShowPartitionsTask) Execute() error {
|
2021-01-22 09:36:18 +08:00
|
|
|
var err error
|
2021-01-28 20:51:44 +08:00
|
|
|
spt.result, err = spt.masterClient.ShowPartitions(spt.ShowPartitionRequest)
|
2021-01-31 14:55:36 +08:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
2020-11-19 17:09:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (spt *ShowPartitionsTask) PostExecute() error {
|
|
|
|
return nil
|
|
|
|
}
|
2020-12-22 15:39:10 +08:00
|
|
|
|
|
|
|
type CreateIndexTask struct {
|
|
|
|
Condition
|
2021-01-22 09:36:18 +08:00
|
|
|
*milvuspb.CreateIndexRequest
|
2021-01-29 09:27:26 +08:00
|
|
|
masterClient MasterClient
|
2020-12-22 15:39:10 +08:00
|
|
|
result *commonpb.Status
|
|
|
|
}
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
func (cit *CreateIndexTask) OnEnqueue() error {
|
|
|
|
cit.Base = &commonpb.MsgBase{}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-12-22 15:39:10 +08:00
|
|
|
func (cit *CreateIndexTask) ID() UniqueID {
|
2021-01-18 19:32:08 +08:00
|
|
|
return cit.Base.MsgID
|
2020-12-22 15:39:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (cit *CreateIndexTask) SetID(uid UniqueID) {
|
2021-01-18 19:32:08 +08:00
|
|
|
cit.Base.MsgID = uid
|
2020-12-22 15:39:10 +08:00
|
|
|
}
|
|
|
|
|
2021-01-16 15:06:19 +08:00
|
|
|
func (cit *CreateIndexTask) Type() commonpb.MsgType {
|
2021-01-18 19:32:08 +08:00
|
|
|
return cit.Base.MsgType
|
2020-12-22 15:39:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (cit *CreateIndexTask) BeginTs() Timestamp {
|
2021-01-18 19:32:08 +08:00
|
|
|
return cit.Base.Timestamp
|
2020-12-22 15:39:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (cit *CreateIndexTask) EndTs() Timestamp {
|
2021-01-18 19:32:08 +08:00
|
|
|
return cit.Base.Timestamp
|
2020-12-22 15:39:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (cit *CreateIndexTask) SetTs(ts Timestamp) {
|
2021-01-18 19:32:08 +08:00
|
|
|
cit.Base.Timestamp = ts
|
2020-12-22 15:39:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (cit *CreateIndexTask) PreExecute() error {
|
2021-01-22 09:36:18 +08:00
|
|
|
cit.Base.MsgType = commonpb.MsgType_kCreateIndex
|
2021-01-28 20:51:44 +08:00
|
|
|
cit.Base.SourceID = Params.ProxyID
|
2021-01-22 09:36:18 +08:00
|
|
|
|
2020-12-22 15:39:10 +08:00
|
|
|
collName, fieldName := cit.CollectionName, cit.FieldName
|
|
|
|
|
|
|
|
if err := ValidateCollectionName(collName); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := ValidateFieldName(fieldName); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cit *CreateIndexTask) Execute() (err error) {
|
2021-01-28 20:51:44 +08:00
|
|
|
cit.result, err = cit.masterClient.CreateIndex(cit.CreateIndexRequest)
|
2020-12-22 15:39:10 +08:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cit *CreateIndexTask) PostExecute() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type DescribeIndexTask struct {
|
|
|
|
Condition
|
2021-01-22 09:36:18 +08:00
|
|
|
*milvuspb.DescribeIndexRequest
|
2021-01-29 09:27:26 +08:00
|
|
|
masterClient MasterClient
|
2021-01-22 09:36:18 +08:00
|
|
|
result *milvuspb.DescribeIndexResponse
|
2020-12-22 15:39:10 +08:00
|
|
|
}
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
func (dit *DescribeIndexTask) OnEnqueue() error {
|
|
|
|
dit.Base = &commonpb.MsgBase{}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-12-22 15:39:10 +08:00
|
|
|
func (dit *DescribeIndexTask) ID() UniqueID {
|
2021-01-18 19:32:08 +08:00
|
|
|
return dit.Base.MsgID
|
2020-12-22 15:39:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (dit *DescribeIndexTask) SetID(uid UniqueID) {
|
2021-01-18 19:32:08 +08:00
|
|
|
dit.Base.MsgID = uid
|
2020-12-22 15:39:10 +08:00
|
|
|
}
|
|
|
|
|
2021-01-16 15:06:19 +08:00
|
|
|
func (dit *DescribeIndexTask) Type() commonpb.MsgType {
|
2021-01-18 19:32:08 +08:00
|
|
|
return dit.Base.MsgType
|
2020-12-22 15:39:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (dit *DescribeIndexTask) BeginTs() Timestamp {
|
2021-01-18 19:32:08 +08:00
|
|
|
return dit.Base.Timestamp
|
2020-12-22 15:39:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (dit *DescribeIndexTask) EndTs() Timestamp {
|
2021-01-18 19:32:08 +08:00
|
|
|
return dit.Base.Timestamp
|
2020-12-22 15:39:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (dit *DescribeIndexTask) SetTs(ts Timestamp) {
|
2021-01-18 19:32:08 +08:00
|
|
|
dit.Base.Timestamp = ts
|
2020-12-22 15:39:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (dit *DescribeIndexTask) PreExecute() error {
|
2021-01-22 09:36:18 +08:00
|
|
|
dit.Base.MsgType = commonpb.MsgType_kDescribeIndex
|
2021-01-28 20:51:44 +08:00
|
|
|
dit.Base.SourceID = Params.ProxyID
|
2021-01-22 09:36:18 +08:00
|
|
|
|
2020-12-22 15:39:10 +08:00
|
|
|
collName, fieldName := dit.CollectionName, dit.FieldName
|
|
|
|
|
|
|
|
if err := ValidateCollectionName(collName); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := ValidateFieldName(fieldName); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-01-18 19:32:08 +08:00
|
|
|
func (dit *DescribeIndexTask) Execute() error {
|
2021-01-22 09:36:18 +08:00
|
|
|
var err error
|
2021-01-28 20:51:44 +08:00
|
|
|
dit.result, err = dit.masterClient.DescribeIndex(dit.DescribeIndexRequest)
|
2020-12-22 15:39:10 +08:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dit *DescribeIndexTask) PostExecute() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
type GetIndexStateTask struct {
|
2020-12-22 15:39:10 +08:00
|
|
|
Condition
|
2021-01-22 09:36:18 +08:00
|
|
|
*milvuspb.IndexStateRequest
|
2021-01-28 20:51:44 +08:00
|
|
|
indexServiceClient IndexServiceClient
|
|
|
|
result *milvuspb.IndexStateResponse
|
2020-12-22 15:39:10 +08:00
|
|
|
}
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
func (dipt *GetIndexStateTask) OnEnqueue() error {
|
|
|
|
dipt.Base = &commonpb.MsgBase{}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dipt *GetIndexStateTask) ID() UniqueID {
|
2021-01-18 19:32:08 +08:00
|
|
|
return dipt.Base.MsgID
|
2020-12-22 15:39:10 +08:00
|
|
|
}
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
func (dipt *GetIndexStateTask) SetID(uid UniqueID) {
|
2021-01-18 19:32:08 +08:00
|
|
|
dipt.Base.MsgID = uid
|
2020-12-22 15:39:10 +08:00
|
|
|
}
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
func (dipt *GetIndexStateTask) Type() commonpb.MsgType {
|
2021-01-18 19:32:08 +08:00
|
|
|
return dipt.Base.MsgType
|
2020-12-22 15:39:10 +08:00
|
|
|
}
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
func (dipt *GetIndexStateTask) BeginTs() Timestamp {
|
2021-01-18 19:32:08 +08:00
|
|
|
return dipt.Base.Timestamp
|
2020-12-22 15:39:10 +08:00
|
|
|
}
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
func (dipt *GetIndexStateTask) EndTs() Timestamp {
|
2021-01-18 19:32:08 +08:00
|
|
|
return dipt.Base.Timestamp
|
2020-12-22 15:39:10 +08:00
|
|
|
}
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
func (dipt *GetIndexStateTask) SetTs(ts Timestamp) {
|
2021-01-18 19:32:08 +08:00
|
|
|
dipt.Base.Timestamp = ts
|
2020-12-22 15:39:10 +08:00
|
|
|
}
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
func (dipt *GetIndexStateTask) PreExecute() error {
|
|
|
|
dipt.Base.MsgType = commonpb.MsgType_kGetIndexState
|
2021-01-28 20:51:44 +08:00
|
|
|
dipt.Base.SourceID = Params.ProxyID
|
2021-01-22 09:36:18 +08:00
|
|
|
|
2020-12-22 15:39:10 +08:00
|
|
|
collName, fieldName := dipt.CollectionName, dipt.FieldName
|
|
|
|
|
|
|
|
if err := ValidateCollectionName(collName); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := ValidateFieldName(fieldName); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
func (dipt *GetIndexStateTask) Execute() error {
|
2021-01-28 20:51:44 +08:00
|
|
|
// TODO: use index service client
|
|
|
|
//var err error
|
|
|
|
//dipt.result, err = dipt.masterClient.GetIndexState(dipt.IndexStateRequest)
|
|
|
|
//return err
|
|
|
|
dipt.result = &milvuspb.IndexStateResponse{
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: 0,
|
|
|
|
Reason: "",
|
|
|
|
},
|
|
|
|
State: commonpb.IndexState_FINISHED,
|
|
|
|
}
|
|
|
|
return nil
|
2020-12-22 15:39:10 +08:00
|
|
|
}
|
|
|
|
|
2021-01-22 09:36:18 +08:00
|
|
|
func (dipt *GetIndexStateTask) PostExecute() error {
|
2020-12-22 15:39:10 +08:00
|
|
|
return nil
|
|
|
|
}
|
2021-02-02 10:58:39 +08:00
|
|
|
|
|
|
|
type FlushTask struct {
|
|
|
|
Condition
|
|
|
|
*milvuspb.FlushRequest
|
|
|
|
dataServiceClient DataServiceClient
|
|
|
|
result *commonpb.Status
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ft *FlushTask) OnEnqueue() error {
|
|
|
|
ft.Base = &commonpb.MsgBase{}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ft *FlushTask) ID() UniqueID {
|
|
|
|
return ft.Base.MsgID
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ft *FlushTask) SetID(uid UniqueID) {
|
|
|
|
ft.Base.MsgID = uid
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ft *FlushTask) Type() commonpb.MsgType {
|
|
|
|
return ft.Base.MsgType
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ft *FlushTask) BeginTs() Timestamp {
|
|
|
|
return ft.Base.Timestamp
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ft *FlushTask) EndTs() Timestamp {
|
|
|
|
return ft.Base.Timestamp
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ft *FlushTask) SetTs(ts Timestamp) {
|
|
|
|
ft.Base.Timestamp = ts
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ft *FlushTask) PreExecute() error {
|
|
|
|
ft.Base.MsgType = commonpb.MsgType_kFlush
|
|
|
|
ft.Base.SourceID = Params.ProxyID
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ft *FlushTask) Execute() error {
|
2021-02-03 16:34:56 +08:00
|
|
|
for _, collName := range ft.CollectionNames {
|
|
|
|
collID, err := globalMetaCache.GetCollectionID(collName)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
flushReq := &datapb.FlushRequest{
|
|
|
|
Base: &commonpb.MsgBase{
|
|
|
|
MsgType: commonpb.MsgType_kFlush,
|
|
|
|
MsgID: ft.Base.MsgID,
|
|
|
|
Timestamp: ft.Base.Timestamp,
|
|
|
|
SourceID: ft.Base.SourceID,
|
|
|
|
},
|
|
|
|
DbID: 0,
|
|
|
|
CollectionID: collID,
|
|
|
|
}
|
|
|
|
var status *commonpb.Status
|
|
|
|
status, err = ft.dataServiceClient.Flush(flushReq)
|
|
|
|
if err != nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
if status.ErrorCode != commonpb.ErrorCode_SUCCESS {
|
|
|
|
return errors.New(status.Reason)
|
|
|
|
}
|
2021-02-02 10:58:39 +08:00
|
|
|
}
|
2021-02-03 16:34:56 +08:00
|
|
|
ft.result = &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_SUCCESS,
|
2021-02-02 10:58:39 +08:00
|
|
|
}
|
2021-02-03 16:34:56 +08:00
|
|
|
return nil
|
2021-02-02 10:58:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (ft *FlushTask) PostExecute() error {
|
|
|
|
return nil
|
|
|
|
}
|