2023-03-16 19:31:55 +08:00
|
|
|
package proxy
|
|
|
|
|
|
|
|
import (
|
2023-06-09 01:28:37 +08:00
|
|
|
"github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
|
2023-03-16 19:31:55 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/proto/internalpb"
|
|
|
|
"github.com/milvus-io/milvus/internal/util/funcutil"
|
2024-03-28 06:33:11 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/util/merr"
|
2023-03-16 19:31:55 +08:00
|
|
|
)
|
|
|
|
|
2023-10-30 10:00:12 +08:00
|
|
|
type cntReducer struct {
|
|
|
|
collectionName string
|
|
|
|
}
|
2023-03-16 19:31:55 +08:00
|
|
|
|
|
|
|
func (r *cntReducer) Reduce(results []*internalpb.RetrieveResults) (*milvuspb.QueryResults, error) {
|
|
|
|
cnt := int64(0)
|
|
|
|
for _, res := range results {
|
|
|
|
c, err := funcutil.CntOfInternalResult(res)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
cnt += c
|
|
|
|
}
|
2023-10-30 10:00:12 +08:00
|
|
|
res := funcutil.WrapCntToQueryResults(cnt)
|
2024-03-28 06:33:11 +08:00
|
|
|
res.Status = merr.Success()
|
2023-10-30 10:00:12 +08:00
|
|
|
res.CollectionName = r.collectionName
|
|
|
|
return res, nil
|
2023-03-16 19:31:55 +08:00
|
|
|
}
|