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

fix(bigtable): Track number of readrows to set rowsLimit in subsequent requests #10213

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
21 changes: 17 additions & 4 deletions bigtable/internal/testproxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,20 +570,33 @@ func (s *goTestProxyServer) ReadRows(ctx context.Context, req *pb.ReadRowsReques
ctx, cancel := btc.timeout(ctx)
defer cancel()

var c int32
var rowsReadTillNow int64
var rowsPb []*btpb.Row
lim := req.GetCancelAfterRows()

limitRowsRead := false
rowsToRead := int64(0)
if rrq.RowsLimit != 0 {
limitRowsRead = true
rowsToRead = rrq.RowsLimit
}
if req.GetCancelAfterRows() != 0 {
limitRowsRead = true
rowsToRead = int64(req.GetCancelAfterRows())
}

// Client libray does not have a built-in way to limit the number of rows read in a call to Table.ReadRows().
bhshkh marked this conversation as resolved.
Show resolved Hide resolved
// The caller needs to keep track of any kind of limit externally and from within the callback function passed to ReadRows()
err = t.ReadRows(ctx, rs, func(r bigtable.Row) bool {

c++
if c == lim {
if limitRowsRead && rowsReadTillNow == rowsToRead {
return false
}
rpb, err := rowToProto(r)
if err != nil {
return false
}
rowsPb = append(rowsPb, rpb)
rowsReadTillNow++
return true
})

Expand Down
Loading