Skip to content

Commit

Permalink
bigtable/bttest: allow no Rows to be specified in ReadRows
Browse files Browse the repository at this point in the history
This results in all rows being read. It is supported by the protocol but
not by the Go client.

Change-Id: I7e5f1bef78906151664afadea0ab4bc3637b8e0b
Reviewed-on: https://code-review.googlesource.com/7411
Reviewed-by: Jonathan Amsterdam <jba@google.com>
  • Loading branch information
garye committed Sep 6, 2016
1 parent eb1bf1a commit a47b182
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions bigtable/bttest/inmem.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,29 +228,34 @@ func (s *server) ReadRows(req *btpb.ReadRowsRequest, stream btpb.Bigtable_ReadRo
tbl.mu.RLock()

rowSet := make(map[string]*row)
// Add the explicitly given keys
for _, key := range req.Rows.RowKeys {
start := string(key)
addRows(start, start+"\x00", tbl, rowSet)
}
if req.Rows != nil {
// Add the explicitly given keys
for _, key := range req.Rows.RowKeys {
start := string(key)
addRows(start, start + "\x00", tbl, rowSet)
}

// Add keys from row ranges
for _, rr := range req.Rows.RowRanges {
var start, end string
switch sk := rr.StartKey.(type) {
case *btpb.RowRange_StartKeyClosed:
start = string(sk.StartKeyClosed)
case *btpb.RowRange_StartKeyOpen:
start = string(sk.StartKeyOpen) + "\x00"
}
switch ek := rr.EndKey.(type) {
case *btpb.RowRange_EndKeyClosed:
end = string(ek.EndKeyClosed) + "\x00"
case *btpb.RowRange_EndKeyOpen:
end = string(ek.EndKeyOpen)
}

// Add keys from row ranges
for _, rr := range req.Rows.RowRanges {
var start, end string
switch sk := rr.StartKey.(type) {
case *btpb.RowRange_StartKeyClosed:
start = string(sk.StartKeyClosed)
case *btpb.RowRange_StartKeyOpen:
start = string(sk.StartKeyOpen) + "\x00"
addRows(start, end, tbl, rowSet)
}
switch ek := rr.EndKey.(type) {
case *btpb.RowRange_EndKeyClosed:
end = string(ek.EndKeyClosed) + "\x00"
case *btpb.RowRange_EndKeyOpen:
end = string(ek.EndKeyOpen)
}

addRows(start, end, tbl, rowSet)
} else {
// Read all rows
addRows("", "", tbl, rowSet)
}
tbl.mu.RUnlock()

Expand Down

0 comments on commit a47b182

Please sign in to comment.