milvus/internal/querynode/default_limit_reducer.go
Jiquan Long 8139106b51
Feat: count entities by expression (#22765)
Signed-off-by: longjiquan <jiquan.long@zilliz.com>
2023-03-16 19:31:55 +08:00

47 lines
1.5 KiB
Go

package querynode
import (
"context"
"github.com/milvus-io/milvus-proto/go-api/schemapb"
"github.com/milvus-io/milvus/internal/proto/internalpb"
"github.com/milvus-io/milvus/internal/proto/querypb"
"github.com/milvus-io/milvus/internal/proto/segcorepb"
)
type defaultLimitReducer struct {
ctx context.Context
req *querypb.QueryRequest
schema *schemapb.CollectionSchema
}
func (r *defaultLimitReducer) Reduce(results []*internalpb.RetrieveResults) (*internalpb.RetrieveResults, error) {
return mergeInternalRetrieveResultsAndFillIfEmpty(r.ctx, results, r.req.GetReq().GetLimit(), r.req.GetReq().GetOutputFieldsId(), r.schema)
}
func newDefaultLimitReducer(ctx context.Context, req *querypb.QueryRequest, schema *schemapb.CollectionSchema) *defaultLimitReducer {
return &defaultLimitReducer{
ctx: ctx,
req: req,
schema: schema,
}
}
type defaultLimitReducerSegcore struct {
ctx context.Context
req *querypb.QueryRequest
schema *schemapb.CollectionSchema
}
func (r *defaultLimitReducerSegcore) Reduce(results []*segcorepb.RetrieveResults) (*segcorepb.RetrieveResults, error) {
return mergeSegcoreRetrieveResultsAndFillIfEmpty(r.ctx, results, r.req.GetReq().GetLimit(), r.req.GetReq().GetOutputFieldsId(), r.schema)
}
func newDefaultLimitReducerSegcore(ctx context.Context, req *querypb.QueryRequest, schema *schemapb.CollectionSchema) *defaultLimitReducerSegcore {
return &defaultLimitReducerSegcore{
ctx: ctx,
req: req,
schema: schema,
}
}