Fill output fields for count request (#27967)

Signed-off-by: longjiquan <jiquan.long@zilliz.com>
This commit is contained in:
Jiquan Long 2023-10-30 10:00:12 +08:00 committed by GitHub
parent 98e2aad752
commit 6913283716
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 3 deletions

View File

@ -6,7 +6,9 @@ import (
"github.com/milvus-io/milvus/internal/util/funcutil"
)
type cntReducer struct{}
type cntReducer struct {
collectionName string
}
func (r *cntReducer) Reduce(results []*internalpb.RetrieveResults) (*milvuspb.QueryResults, error) {
cnt := int64(0)
@ -17,5 +19,7 @@ func (r *cntReducer) Reduce(results []*internalpb.RetrieveResults) (*milvuspb.Qu
}
cnt += c
}
return funcutil.WrapCntToQueryResults(cnt), nil
res := funcutil.WrapCntToQueryResults(cnt)
res.CollectionName = r.collectionName
return res, nil
}

View File

@ -15,7 +15,9 @@ type milvusReducer interface {
func createMilvusReducer(ctx context.Context, params *queryParams, req *internalpb.RetrieveRequest, schema *schemapb.CollectionSchema, plan *planpb.PlanNode, collectionName string) milvusReducer {
if plan.GetQuery().GetIsCount() {
return &cntReducer{}
return &cntReducer{
collectionName: collectionName,
}
}
return newDefaultLimitReducer(ctx, params, req, schema, collectionName)
}

View File

@ -207,6 +207,7 @@ func (t *queryTask) createPlan(ctx context.Context) error {
if cntMatch {
var err error
t.plan, err = createCntPlan(t.request.GetExpr(), schema)
t.userOutputFields = []string{"count(*)"}
return err
}