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

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

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

Query.rowKey介绍

[英]Adds a key to looked up
[中]为“查找”添加一个键

代码示例

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

  1. /** Adds a key to looked up */
  2. public Query rowKey(String key) {
  3. Preconditions.checkNotNull(key, "Key can't be null.");
  4. return rowKey(ByteString.copyFromUtf8(key));
  5. }

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

  1. Query query = Query.create(tableId).rowKey(rowKey);
  2. if (filter != null) {
  3. query = query.filter(filter);

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

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

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

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

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

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

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

  1. @Test
  2. public void proxyReadRowStrAsyncTest() {
  3. bigtableDataClient.readRowAsync("fake-table", "fake-row-key");
  4. Mockito.verify(mockReadRowCallable)
  5. .futureCall(Query.create("fake-table").rowKey("fake-row-key"));
  6. }

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

  1. @Test
  2. public void rowKeysTest() {
  3. Query query =
  4. Query.create(TABLE_ID)
  5. .rowKey("simple-string")
  6. .rowKey(ByteString.copyFromUtf8("byte-string"));
  7. ReadRowsRequest.Builder expectedProto = expectedProtoBuilder();
  8. expectedProto
  9. .getRowsBuilder()
  10. .addRowKeys(ByteString.copyFromUtf8("simple-string"))
  11. .addRowKeys(ByteString.copyFromUtf8("byte-string"));
  12. ReadRowsRequest actualProto = query.toProto(requestContext);
  13. assertThat(actualProto).isEqualTo(expectedProto.build());
  14. }

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

  1. @Test
  2. public void pointTest() {
  3. service.expectations.add(
  4. RpcExpectation.create()
  5. .expectRequest("r1", "r2")
  6. .respondWith("r1")
  7. .respondWithStatus(Code.UNAVAILABLE));
  8. service.expectations.add(RpcExpectation.create().expectRequest("r2").respondWith("r2"));
  9. List<String> actualResults = getResults(Query.create(TABLE_ID).rowKey("r1").rowKey("r2"));
  10. Truth.assertThat(actualResults).containsExactly("r1", "r2").inOrder();
  11. }

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

  1. @Test
  2. public void readRowFilterTest() {
  3. // Build the filter expression
  4. Filter filter =
  5. FILTERS
  6. .chain()
  7. .filter(FILTERS.qualifier().regex("prefix.*"))
  8. .filter(FILTERS.limit().cellsPerRow(10));
  9. Row expectedRow =
  10. Row.create(ByteString.copyFromUtf8("fake-row-key"), ImmutableList.<RowCell>of());
  11. Mockito.when(
  12. mockReadRowCallable.futureCall(
  13. Query.create("fake-table").rowKey("fake-row-key").filter(filter)))
  14. .thenReturn(ApiFutures.immediateFuture(expectedRow));
  15. Row actualRow =
  16. bigtableDataClient.readRow("fake-table", ByteString.copyFromUtf8("fake-row-key"), filter);
  17. assertThat(actualRow).isEqualTo(expectedRow);
  18. }

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

  1. @Test
  2. public void readRowStrFilterTest() {
  3. // Build the filter expression
  4. Filter filter =
  5. FILTERS
  6. .chain()
  7. .filter(FILTERS.qualifier().regex("prefix.*"))
  8. .filter(FILTERS.limit().cellsPerRow(10));
  9. Row expectedRow =
  10. Row.create(ByteString.copyFromUtf8("fake-row-key"), ImmutableList.<RowCell>of());
  11. Mockito.when(
  12. mockReadRowCallable.futureCall(
  13. Query.create("fake-table").rowKey("fake-row-key").filter(filter)))
  14. .thenReturn(ApiFutures.immediateFuture(expectedRow));
  15. Row actualRow = bigtableDataClient.readRow("fake-table", "fake-row-key", filter);
  16. assertThat(actualRow).isEqualTo(expectedRow);
  17. }

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

  1. @Test
  2. public void happyPathTest() {
  3. service.expectations.add(
  4. RpcExpectation.create()
  5. .expectRequest("k1")
  6. .expectRequest(Range.closedOpen("r1", "r3"))
  7. .respondWith("k1", "r1", "r2"));
  8. List<String> actualResults = getResults(Query.create(TABLE_ID).rowKey("k1").range("r1", "r3"));
  9. Truth.assertThat(actualResults).containsExactly("k1", "r1", "r2").inOrder();
  10. }

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

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

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

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

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

  1. @Test
  2. public void readEmpty() throws Throwable {
  3. String uniqueKey = prefix + "-readEmpty";
  4. Query query = Query.create(testEnvRule.env().getTableId()).rowKey(uniqueKey);
  5. // Sync
  6. ArrayList<Row> rows = Lists.newArrayList(testEnvRule.env().getDataClient().readRows(query));
  7. assertThat(rows).isEmpty();
  8. // Async
  9. AccumulatingObserver observer = new AccumulatingObserver();
  10. testEnvRule.env().getDataClient().readRowsAsync(query, observer);
  11. observer.awaitCompletion();
  12. assertThat(observer.responses).isEmpty();
  13. }

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

  1. @Test
  2. public void readRowFilterStrAsyncTest() {
  3. // Build the filter expression
  4. Filter filter =
  5. FILTERS
  6. .chain()
  7. .filter(FILTERS.qualifier().regex("prefix.*"))
  8. .filter(FILTERS.limit().cellsPerRow(10));
  9. bigtableDataClient.readRowAsync("fake-table", "fake-row-key", filter);
  10. Mockito.verify(mockReadRowCallable)
  11. .futureCall(Query.create("fake-table").rowKey("fake-row-key").filter(filter));
  12. }

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

  1. @Test
  2. public void immediateRetryTest() {
  3. service.expectations.add(
  4. RpcExpectation.create()
  5. .expectRequest("k1")
  6. .expectRequest(Range.closedOpen("r1", "r3"))
  7. .respondWithStatus(Code.UNAVAILABLE));
  8. service.expectations.add(
  9. RpcExpectation.create()
  10. .expectRequest("k1")
  11. .expectRequest(Range.closedOpen("r1", "r3"))
  12. .respondWith("k1", "r1", "r2"));
  13. List<String> actualResults = getResults(Query.create(TABLE_ID).rowKey("k1").range("r1", "r3"));
  14. Truth.assertThat(actualResults).containsExactly("k1", "r1", "r2").inOrder();
  15. }

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

  1. .readRowsCallable()
  2. .first()
  3. .call(Query.create(testEnvRule.env().getTableId()).rowKey(rowKey));

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

  1. .readRowsCallable()
  2. .first()
  3. .call(Query.create(tableId).rowKey(rowKey));

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

  1. /** Adds a key to looked up */
  2. public Query rowKey(String key) {
  3. Preconditions.checkNotNull(key, "Key can't be null.");
  4. return rowKey(ByteString.copyFromUtf8(key));
  5. }

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

  1. /** {@inheritDoc} */
  2. @Override
  3. public void adapt(Get operation, ReadHooks readHooks, Query query) {
  4. Scan operationAsScan = new Scan(addKeyOnlyFilter(operation));
  5. scanAdapter.throwIfUnsupportedScan(operationAsScan);
  6. query.filter(scanAdapter.buildFilter(operationAsScan, readHooks))
  7. .rowKey(ByteString.copyFrom(operation.getRow()));
  8. }

相关文章