com.google.cloud.bigtable.data.v2.models.Query.toProto()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(200)

本文整理了Java中com.google.cloud.bigtable.data.v2.models.Query.toProto方法的一些代码示例,展示了Query.toProto的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.toProto方法的具体详情如下:
包路径:com.google.cloud.bigtable.data.v2.models.Query
类名称:Query
方法名:toProto

Query.toProto介绍

[英]Creates the request protobuf. This method is considered an internal implementation detail and not meant to be used by applications.
[中]创建请求protobuf。此方法被视为内部实现细节,不适用于应用程序。

代码示例

代码示例来源:origin: googleapis/google-cloud-java

@Override
public void call(Query request, ResponseObserver<RowT> responseObserver, ApiCallContext context) {
 ReadRowsRequest innerRequest = request.toProto(requestContext);
 inner.call(innerRequest, responseObserver, context);
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void serializationTest() throws IOException, ClassNotFoundException {
 Query expected = Query.create(TABLE_ID).filter(FILTERS.key().regex(".*"));
 ByteArrayOutputStream bos = new ByteArrayOutputStream();
 ObjectOutputStream oos = new ObjectOutputStream(bos);
 oos.writeObject(expected);
 oos.close();
 ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray()));
 Query actual = (Query) ois.readObject();
 assertThat(actual.toProto(requestContext)).isEqualTo(expected.toProto(requestContext));
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testLimitAdded() {
 ReadRowsFirstCallable<Row> callable = new ReadRowsFirstCallable<>(innerCallable);
 innerResult.set(null);
 callable.call(Query.create("fake-table"));
 Truth.assertThat(innerQuery.getValue().toProto(REQUEST_CONTEXT))
   .isEqualTo(Query.create("fake-table").limit(1).toProto(REQUEST_CONTEXT));
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void requestContextTest() {
 Query query = Query.create(TABLE_ID);
 ReadRowsRequest proto = query.toProto(requestContext);
 assertThat(proto).isEqualTo(expectedProtoBuilder().build());
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void rowKeysTest() {
 Query query =
   Query.create(TABLE_ID)
     .rowKey("simple-string")
     .rowKey(ByteString.copyFromUtf8("byte-string"));
 ReadRowsRequest.Builder expectedProto = expectedProtoBuilder();
 expectedProto
   .getRowsBuilder()
   .addRowKeys(ByteString.copyFromUtf8("simple-string"))
   .addRowKeys(ByteString.copyFromUtf8("byte-string"));
 ReadRowsRequest actualProto = query.toProto(requestContext);
 assertThat(actualProto).isEqualTo(expectedProto.build());
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testRequestConverted() {
 ServerStreamingStashCallable<ReadRowsRequest, Row> innerCallable =
   new ServerStreamingStashCallable<>();
 ReadRowsUserCallable<Row> callable = new ReadRowsUserCallable<>(innerCallable, REQUEST_CONTEXT);
 Query query = Query.create("fake-table");
 callable.call(query);
 Truth.assertThat(innerCallable.getActualRequest()).isEqualTo(query.toProto(REQUEST_CONTEXT));
}

代码示例来源:origin: googleapis/google-cloud-java

@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());
}

代码示例来源:origin: googleapis/google-cloud-java

@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());
}

代码示例来源:origin: googleapis/google-cloud-java

@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));
 }
}

代码示例来源:origin: googleapis/google-cloud-java

@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());
}

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testFromProto() {
 ReadRowsRequest request =
   ReadRowsRequest.newBuilder()
     .setTableName(NameUtil.formatTableName(PROJECT_ID, INSTANCE_ID, TABLE_ID))
     .setAppProfileId(APP_PROFILE_ID)
     .setFilter(RowFilter.newBuilder().setRowKeyRegexFilter(ByteString.copyFromUtf8(".*")))
     .setRows(
       RowSet.newBuilder()
         .addRowKeys(ByteString.copyFromUtf8("row-key"))
         .addRowRanges(
           RowRange.newBuilder()
             .setStartKeyClosed(ByteString.copyFromUtf8("j"))
             .setEndKeyClosed(ByteString.copyFromUtf8("z"))))
     .build();
 Query query = Query.fromProto(request);
 assertThat(query.toProto(requestContext)).isEqualTo(request);
}

代码示例来源:origin: googleapis/google-cloud-java

assertThat(subQueries.get(0).toProto(requestContext))
  .isEqualTo(
    ReadRowsRequest.newBuilder()
              .setEndKeyClosed(ByteString.copyFromUtf8("j"))))
      .build());
assertThat(subQueries.get(1).toProto(requestContext))
  .isEqualTo(
    ReadRowsRequest.newBuilder()

代码示例来源:origin: googleapis/google-cloud-java

assertThat(subQueries.get(0).toProto(requestContext))
  .isEqualTo(
    ReadRowsRequest.newBuilder()
              .setEndKeyClosed(ByteString.copyFromUtf8("j"))))
      .build());
assertThat(subQueries.get(1).toProto(requestContext))
  .isEqualTo(
    ReadRowsRequest.newBuilder()

代码示例来源:origin: com.google.cloud/google-cloud-bigtable

@Override
public void call(Query request, ResponseObserver<RowT> responseObserver, ApiCallContext context) {
 ReadRowsRequest innerRequest = request.toProto(requestContext);
 inner.call(innerRequest, responseObserver, context);
}

代码示例来源:origin: GoogleCloudPlatform/cloud-bigtable-client

/** {@inheritDoc} */
@Override
public List<FlatRow> readFlatRowsList(Query request) {
 return delegate.readFlatRowsList(request.toProto(requestContext));
}

代码示例来源:origin: GoogleCloudPlatform/cloud-bigtable-client

/** {@inheritDoc} */
@Override
public ResultScanner<FlatRow> readFlatRows(Query request) {
 return delegate.readFlatRows(request.toProto(requestContext));
}

代码示例来源:origin: GoogleCloudPlatform/cloud-bigtable-client

/** {@inheritDoc} */
@Override
public ListenableFuture<List<FlatRow>> readFlatRowsAsync(Query request) {
 return delegate.readFlatRowsAsync(request.toProto(requestContext));
}

代码示例来源:origin: GoogleCloudPlatform/cloud-bigtable-client

/**
 * <p>adapt.</p>
 *
 * @param scan a {@link Scan} object.
 * @return a {@link ReadRowsRequest} object.
 */
public ReadRowsRequest adapt(Scan scan) {
 ReadHooks readHooks = new DefaultReadHooks();
 Query query = Query.create(bigtableTableName.getTableId());
 Adapters.SCAN_ADAPTER.adapt(scan, readHooks, query);
 readHooks.applyPreSendHook(query);
 return query.toProto(requestContext);
}

代码示例来源:origin: GoogleCloudPlatform/cloud-bigtable-client

/**
 * <p>adapt.</p>
 *
 * @param get a {@link Get} object.
 * @return a {@link ReadRowsRequest} object.
 */
public ReadRowsRequest adapt(Get get) {
 ReadHooks readHooks = new DefaultReadHooks();
 Query query = Query.create(bigtableTableName.getTableId());
 Adapters.GET_ADAPTER.adapt(get, readHooks, query);
 readHooks.applyPreSendHook(query);
 return query.toProto(requestContext);
}

相关文章