mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-05 05:18:52 +08:00
ad7f3d4c3e
Signed-off-by: longjiquan <jiquan.long@zilliz.com>
40 lines
934 B
Go
40 lines
934 B
Go
package segments
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/milvus-io/milvus/internal/proto/internalpb"
|
|
"github.com/milvus-io/milvus/internal/proto/segcorepb"
|
|
"github.com/milvus-io/milvus/internal/util/funcutil"
|
|
)
|
|
|
|
type cntReducer struct {
|
|
}
|
|
|
|
func (r *cntReducer) Reduce(ctx context.Context, results []*internalpb.RetrieveResults) (*internalpb.RetrieveResults, error) {
|
|
cnt := int64(0)
|
|
for _, res := range results {
|
|
c, err := funcutil.CntOfInternalResult(res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
cnt += c
|
|
}
|
|
return funcutil.WrapCntToInternalResult(cnt), nil
|
|
}
|
|
|
|
type cntReducerSegCore struct {
|
|
}
|
|
|
|
func (r *cntReducerSegCore) Reduce(ctx context.Context, results []*segcorepb.RetrieveResults) (*segcorepb.RetrieveResults, error) {
|
|
cnt := int64(0)
|
|
for _, res := range results {
|
|
c, err := funcutil.CntOfSegCoreResult(res)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
cnt += c
|
|
}
|
|
return funcutil.WrapCntToSegCoreResult(cnt), nil
|
|
}
|