diff --git a/bigtable/bigtable_test.go b/bigtable/bigtable_test.go index cfc63d6bf2a0..054697d22646 100644 --- a/bigtable/bigtable_test.go +++ b/bigtable/bigtable_test.go @@ -460,6 +460,7 @@ func TestClientIntegration(t *testing.T) { // Timestamps are used in thousands because the server // only permits that granularity. mut.Set("ts", "col", Timestamp(i*1000), []byte(fmt.Sprintf("val-%d", i))) + mut.Set("ts", "col2", Timestamp(i*1000), []byte(fmt.Sprintf("val-%d", i))) } if err := tbl.Apply(ctx, "testrow", mut); err != nil { t.Fatalf("Mutating row: %v", err) @@ -474,6 +475,10 @@ func TestClientIntegration(t *testing.T) { {Row: "testrow", Column: "ts:col", Timestamp: 2000, Value: []byte("val-2")}, {Row: "testrow", Column: "ts:col", Timestamp: 1000, Value: []byte("val-1")}, {Row: "testrow", Column: "ts:col", Timestamp: 0, Value: []byte("val-0")}, + {Row: "testrow", Column: "ts:col2", Timestamp: 3000, Value: []byte("val-3")}, + {Row: "testrow", Column: "ts:col2", Timestamp: 2000, Value: []byte("val-2")}, + {Row: "testrow", Column: "ts:col2", Timestamp: 1000, Value: []byte("val-1")}, + {Row: "testrow", Column: "ts:col2", Timestamp: 0, Value: []byte("val-0")}, }} if !reflect.DeepEqual(r, wantRow) { t.Errorf("Cell with multiple versions,\n got %v\nwant %v", r, wantRow) @@ -486,6 +491,8 @@ func TestClientIntegration(t *testing.T) { wantRow = Row{"ts": []ReadItem{ {Row: "testrow", Column: "ts:col", Timestamp: 3000, Value: []byte("val-3")}, {Row: "testrow", Column: "ts:col", Timestamp: 2000, Value: []byte("val-2")}, + {Row: "testrow", Column: "ts:col2", Timestamp: 3000, Value: []byte("val-3")}, + {Row: "testrow", Column: "ts:col2", Timestamp: 2000, Value: []byte("val-2")}, }} if !reflect.DeepEqual(r, wantRow) { t.Errorf("Cell with multiple versions and LatestNFilter(2),\n got %v\nwant %v", r, wantRow) @@ -509,6 +516,10 @@ func TestClientIntegration(t *testing.T) { } wantRow = Row{"ts": []ReadItem{ {Row: "testrow", Column: "ts:col", Timestamp: 0, Value: []byte("val-0")}, + {Row: "testrow", Column: "ts:col2", Timestamp: 3000, Value: []byte("val-3")}, + {Row: "testrow", Column: "ts:col2", Timestamp: 2000, Value: []byte("val-2")}, + {Row: "testrow", Column: "ts:col2", Timestamp: 1000, Value: []byte("val-1")}, + {Row: "testrow", Column: "ts:col2", Timestamp: 0, Value: []byte("val-0")}, }} if !reflect.DeepEqual(r, wantRow) { t.Errorf("Cell with multiple versions and CellsPerRowOffsetFilter(3),\n got %v\nwant %v", r, wantRow) @@ -521,6 +532,8 @@ func TestClientIntegration(t *testing.T) { wantRow = Row{"ts": []ReadItem{ {Row: "testrow", Column: "ts:col", Timestamp: 2000, Value: []byte("val-2")}, {Row: "testrow", Column: "ts:col", Timestamp: 1000, Value: []byte("val-1")}, + {Row: "testrow", Column: "ts:col2", Timestamp: 2000, Value: []byte("val-2")}, + {Row: "testrow", Column: "ts:col2", Timestamp: 1000, Value: []byte("val-1")}, }} if !reflect.DeepEqual(r, wantRow) { t.Errorf("Cell with multiple versions and TimestampRangeFilter(1000, 3000),\n got %v\nwant %v", r, wantRow) @@ -533,6 +546,9 @@ func TestClientIntegration(t *testing.T) { {Row: "testrow", Column: "ts:col", Timestamp: 3000, Value: []byte("val-3")}, {Row: "testrow", Column: "ts:col", Timestamp: 2000, Value: []byte("val-2")}, {Row: "testrow", Column: "ts:col", Timestamp: 1000, Value: []byte("val-1")}, + {Row: "testrow", Column: "ts:col2", Timestamp: 3000, Value: []byte("val-3")}, + {Row: "testrow", Column: "ts:col2", Timestamp: 2000, Value: []byte("val-2")}, + {Row: "testrow", Column: "ts:col2", Timestamp: 1000, Value: []byte("val-1")}, }} if !reflect.DeepEqual(r, wantRow) { t.Errorf("Cell with multiple versions and TimestampRangeFilter(1000, 0),\n got %v\nwant %v", r, wantRow) @@ -582,6 +598,8 @@ func TestClientIntegration(t *testing.T) { wantRow = Row{"ts": []ReadItem{ {Row: "testrow", Column: "ts:col", Timestamp: 3000, Value: []byte("val-3")}, {Row: "testrow", Column: "ts:col", Timestamp: 1000, Value: []byte("val-1")}, + {Row: "testrow", Column: "ts:col2", Timestamp: 3000, Value: []byte("val-3")}, + {Row: "testrow", Column: "ts:col2", Timestamp: 2000, Value: []byte("val-2")}, }} if !reflect.DeepEqual(r, wantRow) { t.Errorf("Cell with multiple versions and LatestNFilter(2), after deleting timestamp 2000,\n got %v\nwant %v", r, wantRow) diff --git a/bigtable/bttest/inmem.go b/bigtable/bttest/inmem.go index ac129e90bc21..31d8c556983e 100644 --- a/bigtable/bttest/inmem.go +++ b/bigtable/bttest/inmem.go @@ -463,12 +463,14 @@ func filterRow(f *btpb.RowFilter, r *row) bool { // Grab the first n cells in the row. lim := int(f.CellsPerRowLimitFilter) for _, fam := range r.families { - for col, cs := range fam.cells { + for _, col := range fam.colNames { + cs := fam.cells[col] if len(cs) > lim { fam.cells[col] = cs[:lim] - return true + lim = 0 + } else { + lim -= len(cs) } - lim -= len(cs) } } return true @@ -476,11 +478,14 @@ func filterRow(f *btpb.RowFilter, r *row) bool { // Skip the first n cells in the row. offset := int(f.CellsPerRowOffsetFilter) for _, fam := range r.families { - for col, cs := range fam.cells { - if offset > 0 && offset < len(cs) { + for _, col := range fam.colNames { + cs := fam.cells[col] + if len(cs) > offset { fam.cells[col] = cs[offset:] offset = 0 + return true } else { + fam.cells[col] = cs[:0] offset -= len(cs) } }