use of com.google.bigtable.repackaged.com.google.bigtable.v2.ReadRowsRequest in project java-bigquerystorage by googleapis.
the class ITBigQueryStorageTest method testFilter.
@Test
public void testFilter() throws IOException {
String table = BigQueryResource.FormatTableResource(/* projectId = */
"bigquery-public-data", /* datasetId = */
"samples", /* tableId = */
"shakespeare");
TableReadOptions options = TableReadOptions.newBuilder().setRowRestriction("word_count > 100").build();
CreateReadSessionRequest request = CreateReadSessionRequest.newBuilder().setParent(parentProjectId).setMaxStreamCount(1).setReadSession(ReadSession.newBuilder().setTable(table).setReadOptions(options).setDataFormat(DataFormat.AVRO).build()).build();
ReadSession session = client.createReadSession(request);
assertEquals(String.format("Did not receive expected number of streams for table '%s' CreateReadSession response:%n%s", table, session.toString()), 1, session.getStreamsCount());
ReadRowsRequest readRowsRequest = ReadRowsRequest.newBuilder().setReadStream(session.getStreams(0).getName()).build();
SimpleRowReader reader = new SimpleRowReader(new Schema.Parser().parse(session.getAvroSchema().getSchema()));
long rowCount = 0;
ServerStream<ReadRowsResponse> stream = client.readRowsCallable().call(readRowsRequest);
for (ReadRowsResponse response : stream) {
rowCount += response.getRowCount();
reader.processRows(response.getAvroRows(), new AvroRowConsumer() {
@Override
public void accept(GenericData.Record record) {
Long wordCount = (Long) record.get("word_count");
assertWithMessage("Row not matching expectations: %s", record.toString()).that(wordCount).isGreaterThan(100L);
}
});
}
assertEquals(1_333, rowCount);
}
use of com.google.bigtable.repackaged.com.google.bigtable.v2.ReadRowsRequest in project java-bigquerystorage by googleapis.
the class EnhancedBigQueryReadStubSettingsTest method testReadRowsSettings.
@Test
public void testReadRowsSettings() {
ServerStreamingCallSettings.Builder<ReadRowsRequest, ReadRowsResponse> builder = EnhancedBigQueryReadStubSettings.newBuilder().readRowsSettings();
assertThat(builder.getRetryableCodes()).contains(Code.UNAVAILABLE);
RetrySettings retrySettings = builder.getRetrySettings();
assertThat(retrySettings.getInitialRetryDelay()).isEqualTo(Duration.ofMillis(100L));
assertThat(retrySettings.getRetryDelayMultiplier()).isWithin(1e-6).of(1.3);
assertThat(retrySettings.getMaxRetryDelay()).isEqualTo(Duration.ofMinutes(1L));
assertThat(retrySettings.getInitialRpcTimeout()).isEqualTo(Duration.ofDays(1L));
assertThat(retrySettings.getRpcTimeoutMultiplier()).isWithin(1e-6).of(1.0);
assertThat(retrySettings.getMaxRpcTimeout()).isEqualTo(Duration.ofDays(1L));
assertThat(retrySettings.getTotalTimeout()).isEqualTo(Duration.ofDays(1L));
assertThat(builder.getIdleTimeout()).isEqualTo(Duration.ZERO);
}
use of com.google.bigtable.repackaged.com.google.bigtable.v2.ReadRowsRequest in project java-bigquerystorage by googleapis.
the class ResourceHeaderTest method readRowsTest.
@Test
public void readRowsTest() {
try {
ReadRowsRequest request = ReadRowsRequest.newBuilder().setReadStream(TEST_STREAM_NAME).setOffset(125).build();
client.readRowsCallable().call(request);
} catch (UnimplementedException e) {
// Ignore the error: none of the methods are actually implemented.
}
verifyHeaderSent(READ_STREAM_PATTERN);
}
use of com.google.bigtable.repackaged.com.google.bigtable.v2.ReadRowsRequest in project java-bigquerystorage by googleapis.
the class ReadRowsRetryTest method multipleRetryTestWithZeroInitialOffset.
@Test
public void multipleRetryTestWithZeroInitialOffset() {
ReadRowsRequest request = RpcExpectation.createRequest("fake-stream", 0);
service.expectations.add(RpcExpectation.create().expectRequest("fake-stream", 0).respondWithNumberOfRows(5).respondWithStatus(Code.UNAVAILABLE));
service.expectations.add(RpcExpectation.create().expectRequest("fake-stream", 5).respondWithNumberOfRows(10).respondWithNumberOfRows(7).respondWithStatus(Code.UNAVAILABLE));
service.expectations.add(RpcExpectation.create().expectRequest("fake-stream", 22).respondWithNumberOfRows(6));
Assert.assertEquals(28, getRowCount(request));
}
use of com.google.bigtable.repackaged.com.google.bigtable.v2.ReadRowsRequest in project java-bigquerystorage by googleapis.
the class ReadRowsRetryTest method happyPathTest.
@Test
public void happyPathTest() {
ReadRowsRequest request = RpcExpectation.createRequest("fake-stream", 0);
service.expectations.add(RpcExpectation.create().expectRequest("fake-stream", 0).respondWithNumberOfRows(10).respondWithNumberOfRows(7));
Assert.assertEquals(17, getRowCount(request));
}
Aggregations