2020-11-03 14:53:36 +08:00
|
|
|
package proxy
|
|
|
|
|
|
|
|
import (
|
2020-11-05 18:01:33 +08:00
|
|
|
"context"
|
|
|
|
"errors"
|
2020-11-05 19:11:12 +08:00
|
|
|
"log"
|
|
|
|
|
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"
|
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/commonpb"
|
2020-11-03 14:53:36 +08:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/internalpb"
|
2020-11-05 18:01:33 +08:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/masterpb"
|
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/servicepb"
|
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
|
2020-11-04 16:28:14 +08:00
|
|
|
Type() internalpb.MsgType
|
2020-11-05 18:01:33 +08:00
|
|
|
BeginTs() Timestamp
|
|
|
|
EndTs() Timestamp
|
2020-11-04 17:58:43 +08:00
|
|
|
SetTs(ts Timestamp)
|
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
|
2020-11-26 13:21:06 +08:00
|
|
|
ts Timestamp
|
2020-11-14 11:24:49 +08:00
|
|
|
result *servicepb.IntegerRangeResponse
|
2020-11-05 18:01:33 +08:00
|
|
|
manipulationMsgStream *msgstream.PulsarMsgStream
|
|
|
|
ctx context.Context
|
2020-11-20 17:53:31 +08:00
|
|
|
rowIDAllocator *allocator.IDAllocator
|
2020-11-05 18:01:33 +08:00
|
|
|
}
|
|
|
|
|
2020-11-23 16:52:17 +08:00
|
|
|
func (it *InsertTask) SetID(uid UniqueID) {
|
|
|
|
it.ReqID = uid
|
|
|
|
}
|
|
|
|
|
2020-11-05 18:01:33 +08:00
|
|
|
func (it *InsertTask) SetTs(ts Timestamp) {
|
2020-11-26 13:21:06 +08:00
|
|
|
it.ts = ts
|
2020-11-05 18:01:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (it *InsertTask) BeginTs() Timestamp {
|
2020-11-26 13:21:06 +08:00
|
|
|
return it.ts
|
2020-11-05 18:01:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (it *InsertTask) EndTs() Timestamp {
|
2020-11-26 13:21:06 +08:00
|
|
|
return it.ts
|
2020-11-05 18:01:33 +08:00
|
|
|
}
|
|
|
|
|
2020-11-12 12:04:12 +08:00
|
|
|
func (it *InsertTask) ID() UniqueID {
|
2020-11-13 15:17:18 +08:00
|
|
|
return it.ReqID
|
2020-11-05 18:01:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (it *InsertTask) Type() internalpb.MsgType {
|
|
|
|
return it.MsgType
|
|
|
|
}
|
|
|
|
|
|
|
|
func (it *InsertTask) PreExecute() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (it *InsertTask) Execute() error {
|
2020-11-20 17:53:31 +08:00
|
|
|
collectionName := it.BaseInsertTask.CollectionName
|
|
|
|
if !globalMetaCache.Hit(collectionName) {
|
|
|
|
err := globalMetaCache.Update(collectionName)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
description, err := globalMetaCache.Get(collectionName)
|
|
|
|
if err != nil || description == nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
autoID := description.Schema.AutoID
|
|
|
|
if autoID || true {
|
|
|
|
rowNums := len(it.BaseInsertTask.RowData)
|
|
|
|
rowIDBegin, rowIDEnd, _ := it.rowIDAllocator.Alloc(uint32(rowNums))
|
|
|
|
it.BaseInsertTask.RowIDs = make([]UniqueID, rowNums)
|
|
|
|
for i := rowIDBegin; i < rowIDEnd; i++ {
|
|
|
|
offset := i - rowIDBegin
|
|
|
|
it.BaseInsertTask.RowIDs[offset] = i
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
2020-11-17 14:10:07 +08:00
|
|
|
msgPack.Msgs[0] = tsMsg
|
2020-11-20 17:53:31 +08:00
|
|
|
err = it.manipulationMsgStream.Produce(msgPack)
|
2020-11-14 18:18:10 +08:00
|
|
|
it.result = &servicepb.IntegerRangeResponse{
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_SUCCESS,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
if err != nil {
|
|
|
|
it.result.Status.ErrorCode = commonpb.ErrorCode_UNEXPECTED_ERROR
|
|
|
|
it.result.Status.Reason = err.Error()
|
|
|
|
}
|
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
|
2020-11-05 18:01:33 +08:00
|
|
|
internalpb.CreateCollectionRequest
|
|
|
|
masterClient masterpb.MasterClient
|
2020-11-14 11:24:49 +08:00
|
|
|
result *commonpb.Status
|
2020-11-05 19:11:12 +08:00
|
|
|
ctx context.Context
|
2020-11-05 18:01:33 +08:00
|
|
|
}
|
|
|
|
|
2020-11-12 12:04:12 +08:00
|
|
|
func (cct *CreateCollectionTask) ID() UniqueID {
|
2020-11-13 15:17:18 +08:00
|
|
|
return cct.ReqID
|
2020-11-05 18:01:33 +08:00
|
|
|
}
|
|
|
|
|
2020-11-23 16:52:17 +08:00
|
|
|
func (cct *CreateCollectionTask) SetID(uid UniqueID) {
|
|
|
|
cct.ReqID = uid
|
|
|
|
}
|
|
|
|
|
2020-11-05 18:01:33 +08:00
|
|
|
func (cct *CreateCollectionTask) Type() internalpb.MsgType {
|
|
|
|
return cct.MsgType
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cct *CreateCollectionTask) BeginTs() Timestamp {
|
|
|
|
return cct.Timestamp
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cct *CreateCollectionTask) EndTs() Timestamp {
|
|
|
|
return cct.Timestamp
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cct *CreateCollectionTask) SetTs(ts Timestamp) {
|
|
|
|
cct.Timestamp = ts
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cct *CreateCollectionTask) PreExecute() error {
|
|
|
|
return nil
|
2020-11-03 14:53:36 +08:00
|
|
|
}
|
|
|
|
|
2020-11-05 18:01:33 +08:00
|
|
|
func (cct *CreateCollectionTask) Execute() error {
|
|
|
|
resp, err := cct.masterClient.CreateCollection(cct.ctx, &cct.CreateCollectionRequest)
|
|
|
|
if err != nil {
|
|
|
|
log.Printf("create collection failed, error= %v", err)
|
2020-11-14 11:24:49 +08:00
|
|
|
cct.result = &commonpb.Status{
|
2020-11-05 18:01:33 +08:00
|
|
|
ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
|
2020-11-05 19:11:12 +08:00
|
|
|
Reason: err.Error(),
|
2020-11-05 18:01:33 +08:00
|
|
|
}
|
|
|
|
} else {
|
2020-11-14 11:24:49 +08:00
|
|
|
cct.result = resp
|
2020-11-05 18:01:33 +08:00
|
|
|
}
|
|
|
|
return err
|
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
|
2020-11-09 17:25:53 +08:00
|
|
|
internalpb.DropCollectionRequest
|
|
|
|
masterClient masterpb.MasterClient
|
2020-11-14 11:24:49 +08:00
|
|
|
result *commonpb.Status
|
2020-11-09 17:25:53 +08:00
|
|
|
ctx context.Context
|
|
|
|
}
|
|
|
|
|
2020-11-12 12:04:12 +08:00
|
|
|
func (dct *DropCollectionTask) ID() UniqueID {
|
2020-11-13 15:17:18 +08:00
|
|
|
return dct.ReqID
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
2020-11-23 16:52:17 +08:00
|
|
|
func (dct *DropCollectionTask) SetID(uid UniqueID) {
|
|
|
|
dct.ReqID = uid
|
|
|
|
}
|
|
|
|
|
2020-11-09 17:25:53 +08:00
|
|
|
func (dct *DropCollectionTask) Type() internalpb.MsgType {
|
|
|
|
return dct.MsgType
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dct *DropCollectionTask) BeginTs() Timestamp {
|
|
|
|
return dct.Timestamp
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dct *DropCollectionTask) EndTs() Timestamp {
|
|
|
|
return dct.Timestamp
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dct *DropCollectionTask) SetTs(ts Timestamp) {
|
|
|
|
dct.Timestamp = ts
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dct *DropCollectionTask) PreExecute() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dct *DropCollectionTask) Execute() error {
|
|
|
|
resp, err := dct.masterClient.DropCollection(dct.ctx, &dct.DropCollectionRequest)
|
|
|
|
if err != nil {
|
|
|
|
log.Printf("drop collection failed, error= %v", err)
|
2020-11-14 11:24:49 +08:00
|
|
|
dct.result = &commonpb.Status{
|
2020-11-09 17:25:53 +08:00
|
|
|
ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
|
|
|
|
Reason: err.Error(),
|
|
|
|
}
|
|
|
|
} else {
|
2020-11-14 11:24:49 +08:00
|
|
|
dct.result = resp
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dct *DropCollectionTask) PostExecute() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-11-07 16:18:23 +08:00
|
|
|
type QueryTask struct {
|
2020-11-17 20:00:23 +08:00
|
|
|
Condition
|
2020-11-07 16:18:23 +08:00
|
|
|
internalpb.SearchRequest
|
|
|
|
queryMsgStream *msgstream.PulsarMsgStream
|
|
|
|
resultBuf chan []*internalpb.SearchResult
|
2020-11-14 11:24:49 +08:00
|
|
|
result *servicepb.QueryResult
|
2020-11-07 16:18:23 +08:00
|
|
|
ctx context.Context
|
|
|
|
}
|
|
|
|
|
2020-11-12 12:04:12 +08:00
|
|
|
func (qt *QueryTask) ID() UniqueID {
|
2020-11-13 15:17:18 +08:00
|
|
|
return qt.ReqID
|
2020-11-07 16:18:23 +08:00
|
|
|
}
|
|
|
|
|
2020-11-23 16:52:17 +08:00
|
|
|
func (qt *QueryTask) SetID(uid UniqueID) {
|
|
|
|
qt.ReqID = uid
|
|
|
|
}
|
|
|
|
|
2020-11-07 16:18:23 +08:00
|
|
|
func (qt *QueryTask) Type() internalpb.MsgType {
|
|
|
|
return qt.MsgType
|
|
|
|
}
|
|
|
|
|
|
|
|
func (qt *QueryTask) BeginTs() Timestamp {
|
|
|
|
return qt.Timestamp
|
|
|
|
}
|
|
|
|
|
|
|
|
func (qt *QueryTask) EndTs() Timestamp {
|
|
|
|
return qt.Timestamp
|
|
|
|
}
|
|
|
|
|
|
|
|
func (qt *QueryTask) SetTs(ts Timestamp) {
|
|
|
|
qt.Timestamp = ts
|
|
|
|
}
|
|
|
|
|
|
|
|
func (qt *QueryTask) PreExecute() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (qt *QueryTask) Execute() error {
|
|
|
|
var tsMsg msgstream.TsMsg = &msgstream.SearchMsg{
|
|
|
|
SearchRequest: qt.SearchRequest,
|
|
|
|
BaseMsg: msgstream.BaseMsg{
|
|
|
|
BeginTimestamp: qt.Timestamp,
|
|
|
|
EndTimestamp: qt.Timestamp,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
msgPack := &msgstream.MsgPack{
|
|
|
|
BeginTs: qt.Timestamp,
|
|
|
|
EndTs: qt.Timestamp,
|
2020-11-17 14:10:07 +08:00
|
|
|
Msgs: make([]msgstream.TsMsg, 1),
|
2020-11-07 16:18:23 +08:00
|
|
|
}
|
2020-11-17 14:10:07 +08:00
|
|
|
msgPack.Msgs[0] = tsMsg
|
2020-11-07 16:18:23 +08:00
|
|
|
qt.queryMsgStream.Produce(msgPack)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (qt *QueryTask) PostExecute() error {
|
|
|
|
for {
|
|
|
|
select {
|
|
|
|
case <-qt.ctx.Done():
|
|
|
|
log.Print("wait to finish failed, timeout!")
|
2020-11-12 12:04:12 +08:00
|
|
|
return errors.New("wait to finish failed, timeout")
|
2020-11-07 16:18:23 +08:00
|
|
|
case searchResults := <-qt.resultBuf:
|
|
|
|
rlen := len(searchResults) // query num
|
|
|
|
if rlen <= 0 {
|
2020-11-14 11:24:49 +08:00
|
|
|
qt.result = &servicepb.QueryResult{}
|
2020-11-16 17:01:10 +08:00
|
|
|
return nil
|
2020-11-07 16:18:23 +08:00
|
|
|
}
|
|
|
|
n := len(searchResults[0].Hits) // n
|
|
|
|
if n <= 0 {
|
2020-11-14 11:24:49 +08:00
|
|
|
qt.result = &servicepb.QueryResult{}
|
2020-11-16 17:01:10 +08:00
|
|
|
return nil
|
2020-11-07 16:18:23 +08:00
|
|
|
}
|
2020-11-26 11:38:04 +08:00
|
|
|
k := len(searchResults[0].Hits[0].IDs) // k
|
2020-11-07 16:18:23 +08:00
|
|
|
queryResult := &servicepb.QueryResult{
|
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: 0,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
// reduce by score, TODO: use better algorithm
|
|
|
|
// use merge-sort here, the number of ways to merge is `rlen`
|
|
|
|
// in this process, we must make sure:
|
|
|
|
// len(queryResult.Hits) == n
|
|
|
|
// len(queryResult.Hits[i].Ids) == k for i in range(n)
|
|
|
|
for i := 0; i < n; n++ { // n
|
|
|
|
locs := make([]int, rlen)
|
2020-11-26 11:38:04 +08:00
|
|
|
hits := &servicepb.Hits{}
|
2020-11-07 16:18:23 +08:00
|
|
|
for j := 0; j < k; j++ { // k
|
2020-11-26 11:38:04 +08:00
|
|
|
choice, maxScore := 0, float32(0)
|
2020-11-07 16:18:23 +08:00
|
|
|
for q, loc := range locs { // query num, the number of ways to merge
|
2020-11-26 11:38:04 +08:00
|
|
|
score := func(score *servicepb.Score) float32 {
|
|
|
|
// TODO: get score of root
|
|
|
|
return 0.0
|
|
|
|
}(searchResults[q].Hits[i].Scores[loc])
|
|
|
|
if score > maxScore {
|
2020-11-07 16:18:23 +08:00
|
|
|
choice = q
|
2020-11-26 11:38:04 +08:00
|
|
|
maxScore = score
|
2020-11-07 16:18:23 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
choiceOffset := locs[choice]
|
2020-11-26 11:38:04 +08:00
|
|
|
hits.IDs = append(hits.IDs, searchResults[choice].Hits[i].IDs[choiceOffset])
|
|
|
|
hits.RowData = append(hits.RowData, searchResults[choice].Hits[i].RowData[choiceOffset])
|
|
|
|
hits.Scores = append(hits.Scores, searchResults[choice].Hits[i].Scores[choiceOffset])
|
2020-11-07 16:18:23 +08:00
|
|
|
locs[choice]++
|
|
|
|
}
|
2020-11-26 11:38:04 +08:00
|
|
|
queryResult.Hits = append(queryResult.Hits, hits)
|
2020-11-07 16:18:23 +08:00
|
|
|
}
|
2020-11-14 11:24:49 +08:00
|
|
|
qt.result = queryResult
|
2020-11-07 16:18:23 +08:00
|
|
|
}
|
|
|
|
}
|
2020-11-16 17:01:10 +08:00
|
|
|
//return nil
|
|
|
|
}
|
|
|
|
|
2020-11-09 17:25:53 +08:00
|
|
|
type HasCollectionTask struct {
|
2020-11-17 20:00:23 +08:00
|
|
|
Condition
|
2020-11-09 17:25:53 +08:00
|
|
|
internalpb.HasCollectionRequest
|
|
|
|
masterClient masterpb.MasterClient
|
2020-11-14 11:24:49 +08:00
|
|
|
result *servicepb.BoolResponse
|
2020-11-09 17:25:53 +08:00
|
|
|
ctx context.Context
|
|
|
|
}
|
|
|
|
|
2020-11-12 12:04:12 +08:00
|
|
|
func (hct *HasCollectionTask) ID() UniqueID {
|
2020-11-13 15:17:18 +08:00
|
|
|
return hct.ReqID
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
2020-11-23 16:52:17 +08:00
|
|
|
func (hct *HasCollectionTask) SetID(uid UniqueID) {
|
|
|
|
hct.ReqID = uid
|
|
|
|
}
|
|
|
|
|
2020-11-09 17:25:53 +08:00
|
|
|
func (hct *HasCollectionTask) Type() internalpb.MsgType {
|
|
|
|
return hct.MsgType
|
|
|
|
}
|
|
|
|
|
|
|
|
func (hct *HasCollectionTask) BeginTs() Timestamp {
|
|
|
|
return hct.Timestamp
|
|
|
|
}
|
|
|
|
|
|
|
|
func (hct *HasCollectionTask) EndTs() Timestamp {
|
|
|
|
return hct.Timestamp
|
|
|
|
}
|
|
|
|
|
|
|
|
func (hct *HasCollectionTask) SetTs(ts Timestamp) {
|
|
|
|
hct.Timestamp = ts
|
|
|
|
}
|
|
|
|
|
|
|
|
func (hct *HasCollectionTask) PreExecute() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (hct *HasCollectionTask) Execute() error {
|
|
|
|
resp, err := hct.masterClient.HasCollection(hct.ctx, &hct.HasCollectionRequest)
|
|
|
|
if err != nil {
|
|
|
|
log.Printf("has collection failed, error= %v", err)
|
2020-11-14 11:24:49 +08:00
|
|
|
hct.result = &servicepb.BoolResponse{
|
2020-11-09 17:25:53 +08:00
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
|
|
|
|
Reason: "internal error",
|
|
|
|
},
|
|
|
|
Value: false,
|
|
|
|
}
|
|
|
|
} else {
|
2020-11-14 11:24:49 +08:00
|
|
|
hct.result = resp
|
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
|
2020-11-09 17:25:53 +08:00
|
|
|
internalpb.DescribeCollectionRequest
|
|
|
|
masterClient masterpb.MasterClient
|
2020-11-14 11:24:49 +08:00
|
|
|
result *servicepb.CollectionDescription
|
2020-11-09 17:25:53 +08:00
|
|
|
ctx context.Context
|
|
|
|
}
|
|
|
|
|
2020-11-12 12:04:12 +08:00
|
|
|
func (dct *DescribeCollectionTask) ID() UniqueID {
|
2020-11-13 15:17:18 +08:00
|
|
|
return dct.ReqID
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
2020-11-23 16:52:17 +08:00
|
|
|
func (dct *DescribeCollectionTask) SetID(uid UniqueID) {
|
|
|
|
dct.ReqID = uid
|
|
|
|
}
|
|
|
|
|
2020-11-09 17:25:53 +08:00
|
|
|
func (dct *DescribeCollectionTask) Type() internalpb.MsgType {
|
|
|
|
return dct.MsgType
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dct *DescribeCollectionTask) BeginTs() Timestamp {
|
|
|
|
return dct.Timestamp
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dct *DescribeCollectionTask) EndTs() Timestamp {
|
|
|
|
return dct.Timestamp
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dct *DescribeCollectionTask) SetTs(ts Timestamp) {
|
|
|
|
dct.Timestamp = ts
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dct *DescribeCollectionTask) PreExecute() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dct *DescribeCollectionTask) Execute() error {
|
2020-11-20 17:53:31 +08:00
|
|
|
if !globalMetaCache.Hit(dct.CollectionName.CollectionName) {
|
|
|
|
err := globalMetaCache.Update(dct.CollectionName.CollectionName)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
}
|
2020-11-20 17:53:31 +08:00
|
|
|
var err error
|
|
|
|
dct.result, err = globalMetaCache.Get(dct.CollectionName.CollectionName)
|
2020-11-09 17:25:53 +08:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dct *DescribeCollectionTask) PostExecute() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type ShowCollectionsTask struct {
|
2020-11-17 20:00:23 +08:00
|
|
|
Condition
|
2020-11-09 17:25:53 +08:00
|
|
|
internalpb.ShowCollectionRequest
|
|
|
|
masterClient masterpb.MasterClient
|
2020-11-14 11:24:49 +08:00
|
|
|
result *servicepb.StringListResponse
|
2020-11-09 17:25:53 +08:00
|
|
|
ctx context.Context
|
|
|
|
}
|
|
|
|
|
2020-11-12 12:04:12 +08:00
|
|
|
func (sct *ShowCollectionsTask) ID() UniqueID {
|
2020-11-13 15:17:18 +08:00
|
|
|
return sct.ReqID
|
2020-11-09 17:25:53 +08:00
|
|
|
}
|
|
|
|
|
2020-11-23 16:52:17 +08:00
|
|
|
func (sct *ShowCollectionsTask) SetID(uid UniqueID) {
|
|
|
|
sct.ReqID = uid
|
|
|
|
}
|
|
|
|
|
2020-11-09 17:25:53 +08:00
|
|
|
func (sct *ShowCollectionsTask) Type() internalpb.MsgType {
|
|
|
|
return sct.MsgType
|
|
|
|
}
|
|
|
|
|
|
|
|
func (sct *ShowCollectionsTask) BeginTs() Timestamp {
|
|
|
|
return sct.Timestamp
|
|
|
|
}
|
|
|
|
|
|
|
|
func (sct *ShowCollectionsTask) EndTs() Timestamp {
|
|
|
|
return sct.Timestamp
|
|
|
|
}
|
|
|
|
|
|
|
|
func (sct *ShowCollectionsTask) SetTs(ts Timestamp) {
|
|
|
|
sct.Timestamp = ts
|
|
|
|
}
|
|
|
|
|
|
|
|
func (sct *ShowCollectionsTask) PreExecute() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (sct *ShowCollectionsTask) Execute() error {
|
|
|
|
resp, err := sct.masterClient.ShowCollections(sct.ctx, &sct.ShowCollectionRequest)
|
|
|
|
if err != nil {
|
|
|
|
log.Printf("show collections failed, error= %v", err)
|
2020-11-14 11:24:49 +08:00
|
|
|
sct.result = &servicepb.StringListResponse{
|
2020-11-09 17:25:53 +08:00
|
|
|
Status: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_UNEXPECTED_ERROR,
|
|
|
|
Reason: "internal error",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
} else {
|
2020-11-14 11:24:49 +08:00
|
|
|
sct.result = resp
|
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
|
|
|
|
internalpb.CreatePartitionRequest
|
|
|
|
masterClient masterpb.MasterClient
|
|
|
|
result *commonpb.Status
|
|
|
|
ctx context.Context
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cpt *CreatePartitionTask) ID() UniqueID {
|
|
|
|
return cpt.ReqID
|
|
|
|
}
|
|
|
|
|
2020-11-23 16:52:17 +08:00
|
|
|
func (cpt *CreatePartitionTask) SetID(uid UniqueID) {
|
|
|
|
cpt.ReqID = uid
|
|
|
|
}
|
|
|
|
|
2020-11-19 17:09:22 +08:00
|
|
|
func (cpt *CreatePartitionTask) Type() internalpb.MsgType {
|
|
|
|
return cpt.MsgType
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cpt *CreatePartitionTask) BeginTs() Timestamp {
|
|
|
|
return cpt.Timestamp
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cpt *CreatePartitionTask) EndTs() Timestamp {
|
|
|
|
return cpt.Timestamp
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cpt *CreatePartitionTask) SetTs(ts Timestamp) {
|
|
|
|
cpt.Timestamp = ts
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cpt *CreatePartitionTask) PreExecute() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cpt *CreatePartitionTask) Execute() (err error) {
|
|
|
|
cpt.result, err = cpt.masterClient.CreatePartition(cpt.ctx, &cpt.CreatePartitionRequest)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cpt *CreatePartitionTask) PostExecute() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type DropPartitionTask struct {
|
|
|
|
Condition
|
|
|
|
internalpb.DropPartitionRequest
|
|
|
|
masterClient masterpb.MasterClient
|
|
|
|
result *commonpb.Status
|
|
|
|
ctx context.Context
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dpt *DropPartitionTask) ID() UniqueID {
|
|
|
|
return dpt.ReqID
|
|
|
|
}
|
|
|
|
|
2020-11-23 16:52:17 +08:00
|
|
|
func (dpt *DropPartitionTask) SetID(uid UniqueID) {
|
|
|
|
dpt.ReqID = uid
|
|
|
|
}
|
|
|
|
|
2020-11-19 17:09:22 +08:00
|
|
|
func (dpt *DropPartitionTask) Type() internalpb.MsgType {
|
|
|
|
return dpt.MsgType
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dpt *DropPartitionTask) BeginTs() Timestamp {
|
|
|
|
return dpt.Timestamp
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dpt *DropPartitionTask) EndTs() Timestamp {
|
|
|
|
return dpt.Timestamp
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dpt *DropPartitionTask) SetTs(ts Timestamp) {
|
|
|
|
dpt.Timestamp = ts
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dpt *DropPartitionTask) PreExecute() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dpt *DropPartitionTask) Execute() (err error) {
|
|
|
|
dpt.result, err = dpt.masterClient.DropPartition(dpt.ctx, &dpt.DropPartitionRequest)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dpt *DropPartitionTask) PostExecute() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type HasPartitionTask struct {
|
|
|
|
Condition
|
|
|
|
internalpb.HasPartitionRequest
|
|
|
|
masterClient masterpb.MasterClient
|
|
|
|
result *servicepb.BoolResponse
|
|
|
|
ctx context.Context
|
|
|
|
}
|
|
|
|
|
|
|
|
func (hpt *HasPartitionTask) ID() UniqueID {
|
|
|
|
return hpt.ReqID
|
|
|
|
}
|
|
|
|
|
2020-11-23 16:52:17 +08:00
|
|
|
func (hpt *HasPartitionTask) SetID(uid UniqueID) {
|
|
|
|
hpt.ReqID = uid
|
|
|
|
}
|
|
|
|
|
2020-11-19 17:09:22 +08:00
|
|
|
func (hpt *HasPartitionTask) Type() internalpb.MsgType {
|
|
|
|
return hpt.MsgType
|
|
|
|
}
|
|
|
|
|
|
|
|
func (hpt *HasPartitionTask) BeginTs() Timestamp {
|
|
|
|
return hpt.Timestamp
|
|
|
|
}
|
|
|
|
|
|
|
|
func (hpt *HasPartitionTask) EndTs() Timestamp {
|
|
|
|
return hpt.Timestamp
|
|
|
|
}
|
|
|
|
|
|
|
|
func (hpt *HasPartitionTask) SetTs(ts Timestamp) {
|
|
|
|
hpt.Timestamp = ts
|
|
|
|
}
|
|
|
|
|
|
|
|
func (hpt *HasPartitionTask) PreExecute() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (hpt *HasPartitionTask) Execute() (err error) {
|
|
|
|
hpt.result, err = hpt.masterClient.HasPartition(hpt.ctx, &hpt.HasPartitionRequest)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (hpt *HasPartitionTask) PostExecute() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type DescribePartitionTask struct {
|
|
|
|
Condition
|
|
|
|
internalpb.DescribePartitionRequest
|
|
|
|
masterClient masterpb.MasterClient
|
|
|
|
result *servicepb.PartitionDescription
|
|
|
|
ctx context.Context
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dpt *DescribePartitionTask) ID() UniqueID {
|
|
|
|
return dpt.ReqID
|
|
|
|
}
|
|
|
|
|
2020-11-23 16:52:17 +08:00
|
|
|
func (dpt *DescribePartitionTask) SetID(uid UniqueID) {
|
|
|
|
dpt.ReqID = uid
|
|
|
|
}
|
|
|
|
|
2020-11-19 17:09:22 +08:00
|
|
|
func (dpt *DescribePartitionTask) Type() internalpb.MsgType {
|
|
|
|
return dpt.MsgType
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dpt *DescribePartitionTask) BeginTs() Timestamp {
|
|
|
|
return dpt.Timestamp
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dpt *DescribePartitionTask) EndTs() Timestamp {
|
|
|
|
return dpt.Timestamp
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dpt *DescribePartitionTask) SetTs(ts Timestamp) {
|
|
|
|
dpt.Timestamp = ts
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dpt *DescribePartitionTask) PreExecute() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dpt *DescribePartitionTask) Execute() (err error) {
|
|
|
|
dpt.result, err = dpt.masterClient.DescribePartition(dpt.ctx, &dpt.DescribePartitionRequest)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (dpt *DescribePartitionTask) PostExecute() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type ShowPartitionsTask struct {
|
|
|
|
Condition
|
|
|
|
internalpb.ShowPartitionRequest
|
|
|
|
masterClient masterpb.MasterClient
|
|
|
|
result *servicepb.StringListResponse
|
|
|
|
ctx context.Context
|
|
|
|
}
|
|
|
|
|
|
|
|
func (spt *ShowPartitionsTask) ID() UniqueID {
|
|
|
|
return spt.ReqID
|
|
|
|
}
|
|
|
|
|
2020-11-23 16:52:17 +08:00
|
|
|
func (spt *ShowPartitionsTask) SetID(uid UniqueID) {
|
|
|
|
spt.ReqID = uid
|
|
|
|
}
|
|
|
|
|
2020-11-19 17:09:22 +08:00
|
|
|
func (spt *ShowPartitionsTask) Type() internalpb.MsgType {
|
|
|
|
return spt.MsgType
|
|
|
|
}
|
|
|
|
|
|
|
|
func (spt *ShowPartitionsTask) BeginTs() Timestamp {
|
|
|
|
return spt.Timestamp
|
|
|
|
}
|
|
|
|
|
|
|
|
func (spt *ShowPartitionsTask) EndTs() Timestamp {
|
|
|
|
return spt.Timestamp
|
|
|
|
}
|
|
|
|
|
|
|
|
func (spt *ShowPartitionsTask) SetTs(ts Timestamp) {
|
|
|
|
spt.Timestamp = ts
|
|
|
|
}
|
|
|
|
|
|
|
|
func (spt *ShowPartitionsTask) PreExecute() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (spt *ShowPartitionsTask) Execute() (err error) {
|
|
|
|
spt.result, err = spt.masterClient.ShowPartitions(spt.ctx, &spt.ShowPartitionRequest)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (spt *ShowPartitionsTask) PostExecute() error {
|
|
|
|
return nil
|
|
|
|
}
|