mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-29 06:55:27 +08:00
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package reader
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
msgPb "github.com/czs007/suvlim/pkg/master/grpc/message"
|
|
"strconv"
|
|
)
|
|
|
|
type ResultEntityIds []int64
|
|
|
|
type SearchResult struct {
|
|
ResultIds []int64
|
|
ResultDistances []float32
|
|
}
|
|
|
|
func getResultTopicByClientId(clientId int64) string {
|
|
// TODO: Result topic?
|
|
return "result-topic/partition-" + strconv.FormatInt(clientId, 10)
|
|
}
|
|
|
|
func (node *QueryNode) PublishSearchResult(results *msgPb.QueryResult, clientId int64) msgPb.Status {
|
|
var ctx = context.Background()
|
|
|
|
var resultTopic = getResultTopicByClientId(clientId)
|
|
node.messageClient.Send(ctx, *results)
|
|
fmt.Println(resultTopic)
|
|
return msgPb.Status{ErrorCode: msgPb.ErrorCode_SUCCESS}
|
|
}
|
|
|
|
func (node *QueryNode) PublishFailedSearchResult() msgPb.Status {
|
|
var results = msgPb.QueryResult{
|
|
Status: &msgPb.Status{
|
|
ErrorCode: 1,
|
|
Reason: "Search Failed",
|
|
},
|
|
}
|
|
|
|
var ctx = context.Background()
|
|
|
|
node.messageClient.Send(ctx, results)
|
|
return msgPb.Status{ErrorCode: msgPb.ErrorCode_SUCCESS}
|
|
}
|
|
|
|
func (node *QueryNode) PublicStatistic(statisticTopic string) msgPb.Status {
|
|
// TODO: get statistic info
|
|
// getStatisticInfo()
|
|
// var info = getStatisticInfo()
|
|
// TODO: Pulsar publish
|
|
return msgPb.Status{ErrorCode: msgPb.ErrorCode_SUCCESS}
|
|
}
|