cbt: add cells per column limit for row read
@@ -356,12 +356,13 @@ var commands = []struct {
Desc: "Read rows",
do: doRead,
Usage: "cbt read <table> [start=<row>] [end=<row>] [prefix=<prefix>]" +
- " [regex=<regex>] [count=<n>] [app-profile=<app profile id>]\n" +
+ " [regex=<regex>] [count=<n>] [cells-per-column=<n>] [app-profile=<app profile id>]\n" +
" start=<row> Start reading at this row\n" +
" end=<row> Stop reading before this row\n" +
" prefix=<prefix> Read rows with this prefix\n" +
" regex=<regex> Read rows with keys matching this regex\n" +
" count=<n> Read only this many rows\n" +
+ " cells-per-column=<n> Read only this many cells per column\n" +
" app-profile=<app profile id> The app profile id to use for the request (replication alpha)\n",
Required: cbtconfig.ProjectAndInstanceRequired,
},
@@ -995,7 +996,7 @@ func doRead(ctx context.Context, args ...string) {
case "limit":
// Be nicer; we used to support this, but renamed it to "end".
log.Fatalf("Unknown arg key %q; did you mean %q?", key, "end")
- case "start", "end", "prefix", "count", "regex", "app-profile":
+ case "start", "end", "prefix", "count", "cells-per-column", "regex", "app-profile":
parsed[key] = val
}
}
@@ -1021,6 +1022,13 @@ func doRead(ctx context.Context, args ...string) {
}
opts = append(opts, bigtable.LimitRows(n))
}
+ if cellsPerColumn := parsed["cells-per-column"]; cellsPerColumn != "" {
+ n, err := strconv.Atoi(cellsPerColumn)
+ if err != nil {
+ log.Fatalf("Bad number of cells per column %q: %v", cellsPerColumn, err)
+ }
+ opts = append(opts, bigtable.RowFilter(bigtable.LatestNFilter(n)))
+ }
if regex := parsed["regex"]; regex != "" {
opts = append(opts, bigtable.RowFilter(bigtable.RowKeyFilter(regex)))
}
