Skip to content

Commit

Permalink
update large top-K ratio handling logic (#2509) (#2511)
Browse files Browse the repository at this point in the history
Signed-off-by: Kosuke Morimoto <ksk@vdaas.org>
Co-authored-by: Kosuke Morimoto <ksk@vdaas.org>
  • Loading branch information
vdaas-ci and kmrmt authored Jun 12, 2024
1 parent e14f1e1 commit 4522363
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions pkg/gateway/lb/handler/grpc/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 4522363

Please sign in to comment.