use of com.google.bigtable.v2.ReadRowsResponse in project java-bigtable by googleapis.
the class BigtableChannelPrimerTest method testErrorsAreLogged.
@Test
public void testErrorsAreLogged() {
fakeService.readRowsCallback = new ApiFunction<ReadRowsRequest, ReadRowsResponse>() {
@Override
public ReadRowsResponse apply(ReadRowsRequest req) {
throw new StatusRuntimeException(Status.FAILED_PRECONDITION);
}
};
primer.primeChannel(channel);
assertThat(logHandler.logs).hasSize(2);
for (LogRecord log : logHandler.logs) {
assertThat(log.getMessage()).contains("FAILED_PRECONDITION");
}
}
use of com.google.bigtable.v2.ReadRowsResponse in project java-bigtable by googleapis.
the class BigtableEmulatorRuleTest method testDataClient.
@Test
public void testDataClient() throws Exception {
tableAdminStub.createTable(CreateTableRequest.newBuilder().setParent("projects/fake-project/instances/fake-instance").setTableId("fake-table").setTable(Table.newBuilder().putColumnFamilies("cf", ColumnFamily.getDefaultInstance())).build());
dataStub.mutateRow(MutateRowRequest.newBuilder().setTableName("projects/fake-project/instances/fake-instance/tables/fake-table").setRowKey(ByteString.copyFromUtf8("fake-key")).addMutations(Mutation.newBuilder().setSetCell(SetCell.newBuilder().setFamilyName("cf").setColumnQualifier(ByteString.EMPTY).setValue(ByteString.copyFromUtf8("value")))).build());
Iterator<ReadRowsResponse> results = dataStub.readRows(ReadRowsRequest.newBuilder().setTableName("projects/fake-project/instances/fake-instance/tables/fake-table").build());
ReadRowsResponse row = results.next();
assertThat(row.getChunks(0).getValue()).isEqualTo(ByteString.copyFromUtf8("value"));
}
use of com.google.bigtable.v2.ReadRowsResponse in project trino by trinodb.
the class BigQueryResultPageSource method getNextPage.
@Override
public Page getNextPage() {
checkState(pageBuilder.isEmpty(), "PageBuilder is not empty at the beginning of a new page");
ReadRowsResponse response = responses.next();
Iterable<GenericRecord> records = parse(response);
for (GenericRecord record : records) {
pageBuilder.declarePosition();
for (int column = 0; column < columnTypes.size(); column++) {
BlockBuilder output = pageBuilder.getBlockBuilder(column);
appendTo(columnTypes.get(column), record.get(columnNames.get(column)), output);
}
}
Page page = pageBuilder.build();
pageBuilder.reset();
return page;
}
use of com.google.bigtable.v2.ReadRowsResponse in project trino by trinodb.
the class TestReadRowsHelper method testRetryOfSingleFailure.
@Test
public void testRetryOfSingleFailure() {
BigQueryReadClient client = mock(BigQueryReadClient.class);
MockResponsesBatch batch1 = new MockResponsesBatch();
batch1.addResponse(ReadRowsResponse.newBuilder().setRowCount(10).build());
batch1.addException(new StatusRuntimeException(Status.INTERNAL.withDescription("Received unexpected EOS on DATA frame from server.")));
MockResponsesBatch batch2 = new MockResponsesBatch();
batch2.addResponse(ReadRowsResponse.newBuilder().setRowCount(11).build());
List<ReadRowsResponse> responses = ImmutableList.copyOf(new MockReadRowsHelper(client, "test", 3, ImmutableList.of(batch1, batch2)).readRows());
assertThat(responses.size()).isEqualTo(2);
assertThat(responses.stream().mapToLong(ReadRowsResponse::getRowCount).sum()).isEqualTo(21);
}
Aggregations