Skip to content

Commit

Permalink
update large top-K ratio handling logic
Browse files Browse the repository at this point in the history
Signed-off-by: Kosuke Morimoto <ksk@vdaas.org>
  • Loading branch information
kmrmt committed May 31, 2024
1 parent 70c933c commit 99b3333
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 {

Check warning on line 455 in pkg/gateway/lb/handler/grpc/handler.go

View check run for this annotation

Codecov / codecov/patch

pkg/gateway/lb/handler/grpc/handler.go#L455

Added line #L455 was not covered by tests
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 99b3333

Please sign in to comment.