From 99b33333a42e04a48142c729b4daf2cfdf638780 Mon Sep 17 00:00:00 2001 From: Kosuke Morimoto Date: Fri, 31 May 2024 13:15:58 +0900 Subject: [PATCH] update large top-K ratio handling logic Signed-off-by: Kosuke Morimoto --- pkg/gateway/lb/handler/grpc/handler.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/gateway/lb/handler/grpc/handler.go b/pkg/gateway/lb/handler/grpc/handler.go index 8959095f6d..b79ac366af 100644 --- a/pkg/gateway/lb/handler/grpc/handler.go +++ b/pkg/gateway/lb/handler/grpc/handler.go @@ -452,12 +452,9 @@ func (s *server) SearchByID(ctx context.Context, req *payload.Search_IDRequest) // It ensures that the number of results is not less than the minimum required and adjusts based on the provided ratio. func (s *server) calculateNum(ctx context.Context, num uint32, ratio float32) (n uint32) { min := float64(s.replica) / float64(len(s.gateway.Addrs(ctx))) - if ratio < 0.0 { + if ratio <= 0.0 { return uint32(math.Ceil(float64(num) * min)) } - if ratio == 0.0 { - return num - } n = uint32(math.Ceil(float64(num) * (min + ((1 - min) * float64(ratio))))) sn := uint32(math.Ceil(float64(num) * min)) if n-1 < sn {