Search in sources :

Example 46 with ReadRowsRequest

use of com.google.bigtable.repackaged.com.google.bigtable.v2.ReadRowsRequest in project java-bigtable by googleapis.

the class QueryTest method limitTest.

@Test
public void limitTest() {
    Query query = Query.create(TABLE_ID).limit(10);
    Builder expectedProto = expectedProtoBuilder().setRowsLimit(10);
    ReadRowsRequest actualProto = query.toProto(requestContext);
    assertThat(actualProto).isEqualTo(expectedProto.build());
}
Also used : Builder(com.google.bigtable.v2.ReadRowsRequest.Builder) ReadRowsRequest(com.google.bigtable.v2.ReadRowsRequest) Test(org.junit.Test)

Example 47 with ReadRowsRequest

use of com.google.bigtable.repackaged.com.google.bigtable.v2.ReadRowsRequest in project java-bigtable by googleapis.

the class QueryTest method filterTest.

@Test
public void filterTest() {
    Query query = Query.create(TABLE_ID).filter(FILTERS.key().regex(".*"));
    Builder expectedProto = expectedProtoBuilder().setFilter(RowFilter.newBuilder().setRowKeyRegexFilter(ByteString.copyFromUtf8(".*")));
    ReadRowsRequest actualProto = query.toProto(requestContext);
    assertThat(actualProto).isEqualTo(expectedProto.build());
}
Also used : Builder(com.google.bigtable.v2.ReadRowsRequest.Builder) ReadRowsRequest(com.google.bigtable.v2.ReadRowsRequest) Test(org.junit.Test)

Example 48 with ReadRowsRequest

use of com.google.bigtable.repackaged.com.google.bigtable.v2.ReadRowsRequest in project java-bigtable by googleapis.

the class QueryTest method rowRangeTest.

@Test
public void rowRangeTest() {
    Query query = Query.create(TABLE_ID).range("simple-begin", "simple-end").range(ByteString.copyFromUtf8("byte-begin"), ByteString.copyFromUtf8("byte-end")).range(ByteStringRange.create("range-begin", "range-end"));
    Builder expectedProto = expectedProtoBuilder();
    expectedProto.getRowsBuilder().addRowRanges(RowRange.newBuilder().setStartKeyClosed(ByteString.copyFromUtf8("simple-begin")).setEndKeyOpen(ByteString.copyFromUtf8("simple-end"))).addRowRanges(RowRange.newBuilder().setStartKeyClosed(ByteString.copyFromUtf8("byte-begin")).setEndKeyOpen(ByteString.copyFromUtf8("byte-end"))).addRowRanges(RowRange.newBuilder().setStartKeyClosed(ByteString.copyFromUtf8("range-begin")).setEndKeyOpen(ByteString.copyFromUtf8("range-end")));
    ReadRowsRequest actualProto = query.toProto(requestContext);
    assertThat(actualProto).isEqualTo(expectedProto.build());
}
Also used : Builder(com.google.bigtable.v2.ReadRowsRequest.Builder) ReadRowsRequest(com.google.bigtable.v2.ReadRowsRequest) Test(org.junit.Test)

Example 49 with ReadRowsRequest

use of com.google.bigtable.repackaged.com.google.bigtable.v2.ReadRowsRequest in project java-bigtable by googleapis.

the class ReadRowsBatchingDescriptorTest method requestBuilderTest.

@Test
public void requestBuilderTest() {
    BatchingRequestBuilder<ByteString, Query> requestBuilder = underTest.newRequestBuilder(Query.create("table-Id"));
    requestBuilder.add(ByteString.copyFromUtf8("row-key-1"));
    requestBuilder.add(ByteString.copyFromUtf8("row-key-2"));
    Query request = requestBuilder.build();
    ReadRowsRequest readRowsRequest = request.toProto(RequestContext.create("project", "instance", "appProfile"));
    assertThat(readRowsRequest.getTableName()).contains("table-Id");
    assertThat(readRowsRequest.getRows().getRowKeysList()).isEqualTo(ImmutableList.of(ByteString.copyFromUtf8("row-key-1"), ByteString.copyFromUtf8("row-key-2")));
}
Also used : Query(com.google.cloud.bigtable.data.v2.models.Query) ByteString(com.google.protobuf.ByteString) ReadRowsRequest(com.google.bigtable.v2.ReadRowsRequest) Test(org.junit.Test)

Example 50 with ReadRowsRequest

use of com.google.bigtable.repackaged.com.google.bigtable.v2.ReadRowsRequest in project java-bigtable by googleapis.

the class ReadRowsUserCallableTest method testFirstIsLimited.

@Test
public void testFirstIsLimited() {
    ServerStreamingStashCallable<ReadRowsRequest, Row> innerCallable = new ServerStreamingStashCallable<>();
    ReadRowsUserCallable<Row> callable = new ReadRowsUserCallable<>(innerCallable, REQUEST_CONTEXT);
    Query query = Query.create("fake-table");
    callable.first().call(query);
    Truth.assertThat(innerCallable.getActualRequest()).isEqualTo(query.limit(1).toProto(REQUEST_CONTEXT));
}
Also used : Query(com.google.cloud.bigtable.data.v2.models.Query) ServerStreamingStashCallable(com.google.cloud.bigtable.gaxx.testing.FakeStreamingApi.ServerStreamingStashCallable) ReadRowsRequest(com.google.bigtable.v2.ReadRowsRequest) Row(com.google.cloud.bigtable.data.v2.models.Row) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)59 ReadRowsRequest (com.google.cloud.bigquery.storage.v1.ReadRowsRequest)31 ReadRowsRequest (com.google.bigtable.v2.ReadRowsRequest)28 ReadRowsResponse (com.google.cloud.bigquery.storage.v1.ReadRowsResponse)24 ReadSession (com.google.cloud.bigquery.storage.v1.ReadSession)17 ReadRowsRequest (com.google.cloud.bigquery.storage.v1beta2.ReadRowsRequest)16 ReadRowsResponse (com.google.cloud.bigquery.storage.v1beta2.ReadRowsResponse)10 StorageClient (org.apache.beam.sdk.io.gcp.bigquery.BigQueryServices.StorageClient)10 FakeBigQueryServices (org.apache.beam.sdk.io.gcp.testing.FakeBigQueryServices)10 ReadRowsResponse (com.google.bigtable.v2.ReadRowsResponse)9 Row (com.google.cloud.bigtable.data.v2.models.Row)9 CreateReadSessionRequest (com.google.cloud.bigquery.storage.v1.CreateReadSessionRequest)8 TableRow (com.google.api.services.bigquery.model.TableRow)7 Query (com.google.cloud.bigtable.data.v2.models.Query)7 ServerStreamingStashCallable (com.google.cloud.bigtable.gaxx.testing.FakeStreamingApi.ServerStreamingStashCallable)7 ByteString (com.google.protobuf.ByteString)7 GenericRecord (org.apache.avro.generic.GenericRecord)6 TableRowParser (org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO.TableRowParser)6 ReadSession (com.google.cloud.bigquery.storage.v1beta2.ReadSession)5 DefaultRowAdapter (com.google.cloud.bigtable.data.v2.models.DefaultRowAdapter)5