Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AdaptiveRangeLimit constant for adaptive range limits #294

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pager.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type pager struct {
}

func addLimitTokenString(w io.Writer, limit int, token string) {
if limit > 0 {
if limit == AdaptiveRangeLimit || limit > 0 {
fmt.Fprintf(w, " limit %d", limit)
}
if token != "" {
Expand Down
8 changes: 8 additions & 0 deletions range.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ import (
"github.com/pkg/errors"
)

const (
// AdaptiveRangeLimit is a sentinel value that is used to indicate an intent
// to range over data in a partition as fast as possible. The server will
// determine an appropriate limit to use to range over the partition as fast
// as possible while ensuring the server remains healthy.
AdaptiveRangeLimit = -1
)

// RangeOp is used to specify constraints to Range calls
type RangeOp struct {
pager
Expand Down
6 changes: 6 additions & 0 deletions range_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ var rangeTestCases = []struct {
stringer: "<empty> limit 10",
converted: "<empty> limit 10",
},
{
descript: "empty with adaptive limit",
rop: NewRangeOp(&AllTypes{}).Limit(AdaptiveRangeLimit),
stringer: "<empty> limit -1",
converted: "<empty> limit -1",
},
{
descript: "empty with token",
rop: NewRangeOp(&AllTypes{}).Offset("toketoketoke"),
Expand Down