milvus/internal/proxy/count_reducer.go
SimFG b1a1cca10b
feat: add more operation detail info for better allocation (#30438)
issue: #30436

---------

Signed-off-by: SimFG <bang.fu@zilliz.com>
2024-03-28 06:33:11 +08:00

28 lines
671 B
Go

package proxy
import (
"github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
"github.com/milvus-io/milvus/internal/proto/internalpb"
"github.com/milvus-io/milvus/internal/util/funcutil"
"github.com/milvus-io/milvus/pkg/util/merr"
)
type cntReducer struct {
collectionName string
}
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
}
res := funcutil.WrapCntToQueryResults(cnt)
res.Status = merr.Success()
res.CollectionName = r.collectionName
return res, nil
}