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

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

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

Query.create介绍

[英]Constructs a new Query object for the specified table id. The table id will be combined with the instance name specified in the com.google.cloud.bigtable.data.v2.BigtableDataSettings.
[中]为指定的表id构造新的查询对象。该表id将与com中指定的实例名称组合。谷歌。云大桌子。数据v2。BigtableDataSettings。

代码示例

代码示例来源: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 proxyReadRowsAsyncTest() {
 Query query = Query.create("fake-table");
 @SuppressWarnings("unchecked")
 ResponseObserver<Row> mockObserver = Mockito.mock(ResponseObserver.class);
 bigtableDataClient.readRowsAsync(query, mockObserver);
 Mockito.verify(mockReadRowsCallable).call(query, mockObserver);
}

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

@Test
public void proxyReadRowsSyncTest() {
 Query query = Query.create("fake-table");
 bigtableDataClient.readRows(query);
 Mockito.verify(mockReadRowsCallable).call(query);
}

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

@Test
public void readRowTest() {
 Row expectedRow =
   Row.create(ByteString.copyFromUtf8("fake-row-key"), ImmutableList.<RowCell>of());
 Mockito.when(mockReadRowCallable.futureCall(Query.create("fake-table").rowKey("fake-row-key")))
   .thenReturn(ApiFutures.immediateFuture(expectedRow));
 Row actualRow =
   bigtableDataClient.readRow("fake-table", ByteString.copyFromUtf8("fake-row-key"));
 assertThat(actualRow).isEqualTo(expectedRow);
}

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

@Test
public void proxyReadRowAsyncTest() {
 bigtableDataClient.readRowAsync("fake-table", ByteString.copyFromUtf8("fake-row-key"));
 Mockito.verify(mockReadRowCallable)
   .futureCall(Query.create("fake-table").rowKey("fake-row-key"));
}

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

@Test
public void readRowStrTest() {
 Row expectedRow =
   Row.create(ByteString.copyFromUtf8("fake-row-key"), ImmutableList.<RowCell>of());
 Mockito.when(mockReadRowCallable.futureCall(Query.create("fake-table").rowKey("fake-row-key")))
   .thenReturn(ApiFutures.immediateFuture(expectedRow));
 Row actualRow = bigtableDataClient.readRow("fake-table", "fake-row-key");
 assertThat(actualRow).isEqualTo(expectedRow);
}

代码示例来源: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 readRowsTest() {
 client.readRows(Query.create(TABLE_ID));
 verifyHeaderSent();
}

代码示例来源: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

private void deleteRows() throws InterruptedException, ExecutionException, TimeoutException {
 Query query = Query.create(tableId).prefix(rowPrefix);
 List<ApiFuture<Void>> futures = Lists.newArrayList();
 ServerStream<Row> rows = dataClient.readRows(query);
 for (Row row : rows) {
  ApiFuture<Void> future =
    dataClient.mutateRowAsync(RowMutation.create(tableId, row.getKey()).deleteRow());
  futures.add(future);
 }
 ApiFutures.allAsList(futures).get(10, TimeUnit.MINUTES);
}

代码示例来源: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 fullTableScanTest() {
 service.expectations.add(
   RpcExpectation.create().respondWith("r1").respondWithStatus(Code.UNAVAILABLE));
 service.expectations.add(
   RpcExpectation.create().expectRequest(Range.greaterThan("r1")).respondWith("r2"));
 List<String> actualResults = getResults(Query.create(TABLE_ID));
 Truth.assertThat(actualResults).containsExactly("r1", "r2").inOrder();
}

代码示例来源: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 pointTest() {
 service.expectations.add(
   RpcExpectation.create()
     .expectRequest("r1", "r2")
     .respondWith("r1")
     .respondWithStatus(Code.UNAVAILABLE));
 service.expectations.add(RpcExpectation.create().expectRequest("r2").respondWith("r2"));
 List<String> actualResults = getResults(Query.create(TABLE_ID).rowKey("r1").rowKey("r2"));
 Truth.assertThat(actualResults).containsExactly("r1", "r2").inOrder();
}

代码示例来源: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 happyPathTest() {
 service.expectations.add(
   RpcExpectation.create()
     .expectRequest("k1")
     .expectRequest(Range.closedOpen("r1", "r3"))
     .respondWith("k1", "r1", "r2"));
 List<String> actualResults = getResults(Query.create(TABLE_ID).rowKey("k1").range("r1", "r3"));
 Truth.assertThat(actualResults).containsExactly("k1", "r1", "r2").inOrder();
}

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

@Test
public void errorAfterRequestCompleteTest() {
 service.expectations.add(
   RpcExpectation.create()
     .expectRequest(Range.closedOpen("r1", "r3"))
     .expectRequest("r4")
     .respondWith("r2", "r4")
     .respondWithStatus(Code.UNAVAILABLE));
 // Second retry request is handled locally in ReadRowsRetryCompletedCallable
 List<String> actualResults = getResults(Query.create(TABLE_ID).range("r1", "r3").rowKey("r4"));
 Truth.assertThat(actualResults).containsExactly("r2", "r4");
}

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

@Test
public void readRowFilterAsyncTest() {
 // Build the filter expression
 Filter filter =
   FILTERS
     .chain()
     .filter(FILTERS.qualifier().regex("prefix.*"))
     .filter(FILTERS.limit().cellsPerRow(10));
 bigtableDataClient.readRowAsync("fake-table", ByteString.copyFromUtf8("fake-row-key"), filter);
 Mockito.verify(mockReadRowCallable)
   .futureCall(Query.create("fake-table").rowKey("fake-row-key").filter(filter));
}

代码示例来源: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 readRowFilterStrAsyncTest() {
 // Build the filter expression
 Filter filter =
   FILTERS
     .chain()
     .filter(FILTERS.qualifier().regex("prefix.*"))
     .filter(FILTERS.limit().cellsPerRow(10));
 bigtableDataClient.readRowAsync("fake-table", "fake-row-key", filter);
 Mockito.verify(mockReadRowCallable)
   .futureCall(Query.create("fake-table").rowKey("fake-row-key").filter(filter));
}

相关文章