use of com.google.bigtable.repackaged.com.google.bigtable.v2.ReadRowsRequest in project java-bigtable by googleapis.
the class ReadRowsUserCallable method call.
@Override
public void call(Query request, ResponseObserver<RowT> responseObserver, ApiCallContext context) {
ReadRowsRequest innerRequest = request.toProto(requestContext);
inner.call(innerRequest, responseObserver, context);
}
use of com.google.bigtable.repackaged.com.google.bigtable.v2.ReadRowsRequest in project java-bigtable-hbase by googleapis.
the class CloudBigtableScanConfigurationTest method testRegularAndRuntimeParametersAreEqualWithRequest.
/**
* This ensures that the config built from regular parameters with a request are the same as the
* config built from runtime parameters, so that we don't have to use runtime parameters to repeat
* the same tests.
*/
@Test
public void testRegularAndRuntimeParametersAreEqualWithRequest() {
ReadRowsRequest request = ReadRowsRequest.newBuilder().setRowsLimit(10).build();
CloudBigtableScanConfiguration withRegularParameters = config.toBuilder().withRequest(request).withKeys(START_ROW, STOP_ROW).withConfiguration("somekey", "somevalue").build();
CloudBigtableScanConfiguration withRuntimeParameters = new CloudBigtableScanConfiguration.Builder().withTableId(StaticValueProvider.of(TABLE)).withProjectId(StaticValueProvider.of(PROJECT)).withInstanceId(StaticValueProvider.of(INSTANCE)).withRequest(StaticValueProvider.of(request)).withKeys(START_ROW, STOP_ROW).withConfiguration("somekey", StaticValueProvider.of("somevalue")).build();
Assert.assertEquals(withRegularParameters, withRuntimeParameters);
// Verify with requests.
ReadRowsRequest updatedRequest = withRegularParameters.getRequest();
withRegularParameters = withRegularParameters.toBuilder().withRequest(updatedRequest).build();
withRuntimeParameters = withRuntimeParameters.toBuilder().withRequest(StaticValueProvider.of(updatedRequest)).build();
Assert.assertEquals(withRegularParameters, withRuntimeParameters);
}
use of com.google.bigtable.repackaged.com.google.bigtable.v2.ReadRowsRequest in project java-bigtable-hbase by googleapis.
the class CloudBigtableScanConfigurationTest method testRegularAndRuntimeParametersAreEqualWithScan.
/**
* This ensures that the config built from regular parameters with a scan are the same as the
* config built from runtime parameters, so that we don't have to use runtime parameters to repeat
* the same tests.
*/
@Test
public void testRegularAndRuntimeParametersAreEqualWithScan() {
CloudBigtableScanConfiguration withRegularParameters = config.toBuilder().withConfiguration("somekey", "somevalue").build();
CloudBigtableScanConfiguration withRuntimeParameters = new CloudBigtableScanConfiguration.Builder().withTableId(StaticValueProvider.of(TABLE)).withProjectId(StaticValueProvider.of(PROJECT)).withInstanceId(StaticValueProvider.of(INSTANCE)).withScan(new Scan(START_ROW, STOP_ROW)).withConfiguration("somekey", StaticValueProvider.of("somevalue")).build();
Assert.assertEquals(withRegularParameters, withRuntimeParameters);
// Verify with requests.
ReadRowsRequest request = withRegularParameters.getRequest();
withRegularParameters = withRegularParameters.toBuilder().withRequest(request).build();
withRuntimeParameters = withRuntimeParameters.toBuilder().withRequest(StaticValueProvider.of(request)).build();
Assert.assertEquals(withRegularParameters, withRuntimeParameters);
}
use of com.google.bigtable.repackaged.com.google.bigtable.v2.ReadRowsRequest in project java-bigtable-hbase by googleapis.
the class CloudBigtableScanConfigurationTest method testQuery.
@Test
public void testQuery() {
Filters.Filter filter = Filters.FILTERS.family().exactMatch("someFamily");
ReadRowsRequest request = config.toBuilder().withQuery(Query.create("SomeTable").filter(filter)).build().getRequest();
Assert.assertEquals(request.getTableName(), config.getRequest().getTableName());
Assert.assertEquals(request.getFilter(), filter.toProto());
}
use of com.google.bigtable.repackaged.com.google.bigtable.v2.ReadRowsRequest in project beam by apache.
the class BigQueryIOStorageQueryTest method doReadFromBigQueryIO.
private void doReadFromBigQueryIO(boolean templateCompatibility) throws Exception {
TableReference sourceTableRef = BigQueryHelpers.parseTableSpec("project:dataset.table");
fakeDatasetService.createDataset(sourceTableRef.getProjectId(), sourceTableRef.getDatasetId(), "asia-northeast1", "Fake plastic tree^H^H^H^Htables", null);
fakeDatasetService.createTable(new Table().setTableReference(sourceTableRef).setLocation("asia-northeast1"));
Table queryResultTable = new Table().setSchema(TABLE_SCHEMA).setNumBytes(0L);
String encodedQuery = FakeBigQueryServices.encodeQueryResult(queryResultTable);
fakeJobService.expectDryRunQuery(options.getProject(), encodedQuery, new JobStatistics().setQuery(new JobStatistics2().setTotalBytesProcessed(1024L * 1024L).setReferencedTables(ImmutableList.of(sourceTableRef))));
ReadSession readSession = ReadSession.newBuilder().setName("readSessionName").setAvroSchema(AvroSchema.newBuilder().setSchema(AVRO_SCHEMA_STRING)).addStreams(ReadStream.newBuilder().setName("streamName")).setDataFormat(DataFormat.AVRO).build();
ReadRowsRequest expectedReadRowsRequest = ReadRowsRequest.newBuilder().setReadStream("streamName").build();
List<GenericRecord> records = Lists.newArrayList(createRecord("A", 1, AVRO_SCHEMA), createRecord("B", 2, AVRO_SCHEMA), createRecord("C", 3, AVRO_SCHEMA), createRecord("D", 4, AVRO_SCHEMA));
List<ReadRowsResponse> readRowsResponses = Lists.newArrayList(createResponse(AVRO_SCHEMA, records.subList(0, 2), 0.0, 0.500), createResponse(AVRO_SCHEMA, records.subList(2, 4), 0.5, 0.875));
//
// Note that since the temporary table name is generated by the pipeline, we can't match the
// expected create read session request exactly. For now, match against any appropriately typed
// proto object.
//
StorageClient fakeStorageClient = mock(StorageClient.class, withSettings().serializable());
when(fakeStorageClient.createReadSession(any())).thenReturn(readSession);
when(fakeStorageClient.readRows(expectedReadRowsRequest, "")).thenReturn(new FakeBigQueryServerStream<>(readRowsResponses));
BigQueryIO.TypedRead<KV<String, Long>> typedRead = BigQueryIO.read(new ParseKeyValue()).fromQuery(encodedQuery).withMethod(Method.DIRECT_READ).withTestServices(new FakeBigQueryServices().withDatasetService(fakeDatasetService).withJobService(fakeJobService).withStorageClient(fakeStorageClient));
if (templateCompatibility) {
typedRead = typedRead.withTemplateCompatibility();
}
PCollection<KV<String, Long>> output = p.apply(typedRead);
PAssert.that(output).containsInAnyOrder(ImmutableList.of(KV.of("A", 1L), KV.of("B", 2L), KV.of("C", 3L), KV.of("D", 4L)));
p.run();
}
Aggregations