Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static <RowT> RowT buildRowFromProto(RowAdapter<RowT> adapter, Row protoRow) {
column.getQualifier(),
cell.getTimestampMicros(),
cell.getLabelsList(),
0);
cell.getValue().size());
builder.cellValue(cell.getValue());
builder.finishCell();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ interface RowBuilder<RowT> {
/** Called to start a new row. This will be called once per row. */
void startRow(ByteString key);

/** Called to start a new cell in a row. */
/**
* Called to start a new cell in a row.
*
* <p>Note: Unlike {@link com.google.bigtable.v2.ReadRowsResponse.CellChunk#getValueSize()},
* which is {@code 0} when a cell is not split across chunks, {@code size} is always the total
* byte size of the cell value.
*/
void startCell(
String family, ByteString qualifier, long timestamp, List<String> labels, long size);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,35 @@ void buildRowFromProto_multipleFamiliesAndCells_roundTrips() {
RowCell.create("f1", col, 1_000, ImmutableList.of("lbl"), val1),
RowCell.create("f2", col, 2_000, ImmutableList.of("lbl"), val2))));
}

@Test
void buildRowFromProto_passesCellValueSizeToStartCell() {
ByteString key = ByteString.copyFromUtf8("key");
ByteString col = ByteString.copyFromUtf8("col");
ByteString val = ByteString.copyFromUtf8("hello-world");

Row proto =
Row.newBuilder()
.setKey(key)
.addFamilies(
com.google.bigtable.v2.Family.newBuilder()
.setName("f1")
.addColumns(
com.google.bigtable.v2.Column.newBuilder()
.setQualifier(col)
.addCells(
com.google.bigtable.v2.Cell.newBuilder()
.setTimestampMicros(1_000)
.setValue(val)
.addLabels("lbl"))))
.build();

RowBuilderShim.buildRowFromProto(adapter, proto);

verify(rowBuilder).startRow(key);
verify(rowBuilder).startCell("f1", col, 1_000L, ImmutableList.of("lbl"), val.size());
verify(rowBuilder).cellValue(val);
verify(rowBuilder).finishCell();
verify(rowBuilder).finishRow();
}
}
Loading