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

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

本文整理了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

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

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

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

代码示例来源: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 proxyReadRowStrAsyncTest() {
 bigtableDataClient.readRowAsync("fake-table", "fake-row-key");
 Mockito.verify(mockReadRowCallable)
   .futureCall(Query.create("fake-table").rowKey("fake-row-key"));
}

代码示例来源: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 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 readRowFilterTest() {
 // Build the filter expression
 Filter filter =
   FILTERS
     .chain()
     .filter(FILTERS.qualifier().regex("prefix.*"))
     .filter(FILTERS.limit().cellsPerRow(10));
 Row expectedRow =
   Row.create(ByteString.copyFromUtf8("fake-row-key"), ImmutableList.<RowCell>of());
 Mockito.when(
     mockReadRowCallable.futureCall(
       Query.create("fake-table").rowKey("fake-row-key").filter(filter)))
   .thenReturn(ApiFutures.immediateFuture(expectedRow));
 Row actualRow =
   bigtableDataClient.readRow("fake-table", ByteString.copyFromUtf8("fake-row-key"), filter);
 assertThat(actualRow).isEqualTo(expectedRow);
}

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

@Test
public void readRowStrFilterTest() {
 // Build the filter expression
 Filter filter =
   FILTERS
     .chain()
     .filter(FILTERS.qualifier().regex("prefix.*"))
     .filter(FILTERS.limit().cellsPerRow(10));
 Row expectedRow =
   Row.create(ByteString.copyFromUtf8("fake-row-key"), ImmutableList.<RowCell>of());
 Mockito.when(
     mockReadRowCallable.futureCall(
       Query.create("fake-table").rowKey("fake-row-key").filter(filter)))
   .thenReturn(ApiFutures.immediateFuture(expectedRow));
 Row actualRow = bigtableDataClient.readRow("fake-table", "fake-row-key", filter);
 assertThat(actualRow).isEqualTo(expectedRow);
}

代码示例来源: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 readEmpty() throws Throwable {
 String uniqueKey = prefix + "-readEmpty";
 Query query = Query.create(testEnvRule.env().getTableId()).rowKey(uniqueKey);
 // Sync
 ArrayList<Row> rows = Lists.newArrayList(testEnvRule.env().getDataClient().readRows(query));
 assertThat(rows).isEmpty();
 // Async
 AccumulatingObserver observer = new AccumulatingObserver();
 testEnvRule.env().getDataClient().readRowsAsync(query, observer);
 observer.awaitCompletion();
 assertThat(observer.responses).isEmpty();
}

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

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

@Test
public void immediateRetryTest() {
 service.expectations.add(
   RpcExpectation.create()
     .expectRequest("k1")
     .expectRequest(Range.closedOpen("r1", "r3"))
     .respondWithStatus(Code.UNAVAILABLE));
 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

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

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

.readRowsCallable()
.first()
.call(Query.create(tableId).rowKey(rowKey));

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

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

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

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

相关文章