mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-04 21:09:06 +08:00
b74770b636
Signed-off-by: MrPresent-Han <chun.han@zilliz.com>
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package proxy
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/milvus-io/milvus/internal/proto/internalpb"
|
|
"github.com/milvus-io/milvus/internal/proto/planpb"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func Test_createMilvusReducer(t *testing.T) {
|
|
n := &planpb.PlanNode{
|
|
Node: &planpb.PlanNode_Query{
|
|
Query: &planpb.QueryPlanNode{
|
|
IsCount: false,
|
|
},
|
|
},
|
|
}
|
|
var r milvusReducer
|
|
|
|
r = createMilvusReducer(nil, nil, nil, nil, n, "")
|
|
_, ok := r.(*defaultLimitReducer)
|
|
assert.True(t, ok)
|
|
|
|
n.Node.(*planpb.PlanNode_Query).Query.IsCount = true
|
|
r = createMilvusReducer(nil, nil, nil, nil, n, "")
|
|
_, ok = r.(*cntReducer)
|
|
assert.True(t, ok)
|
|
|
|
req := &internalpb.RetrieveRequest{
|
|
IterationExtensionReduceRate: 100,
|
|
}
|
|
params := &queryParams{
|
|
limit: 10,
|
|
}
|
|
r = createMilvusReducer(nil, params, req, nil, nil, "")
|
|
defaultReducer, typeOk := r.(*defaultLimitReducer)
|
|
assert.True(t, typeOk)
|
|
assert.Equal(t, int64(10*100), defaultReducer.params.limit)
|
|
|
|
req = &internalpb.RetrieveRequest{
|
|
IterationExtensionReduceRate: 1000,
|
|
}
|
|
params = &queryParams{
|
|
limit: 100,
|
|
}
|
|
r = createMilvusReducer(nil, params, req, nil, nil, "")
|
|
defaultReducer, typeOk = r.(*defaultLimitReducer)
|
|
assert.True(t, typeOk)
|
|
assert.Equal(t, int64(16384), defaultReducer.params.limit)
|
|
}
|