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

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

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

Query.range介绍

[英]Adds a range to be looked up.
[中]添加要查找的范围。

代码示例

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

public Query prefix(String prefix) {
 return range(ByteStringRange.prefix(prefix));
}

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

public Query prefix(ByteString prefix) {
 return range(ByteStringRange.prefix(prefix));
}

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

/**
 * Adds a range to be looked up.
 *
 * @param start The beginning of the range (inclusive). Can be null to represent negative
 *     infinity.
 * @param end The end of the range (exclusive). Can be null to represent positive infinity.
 */
public Query range(String start, String end) {
 return range(wrapKey(start), wrapKey(end));
}

代码示例来源: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 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 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 errorAfterRowLimitMetTest() {
 service.expectations.add(
   RpcExpectation.create()
     .expectRequest(Range.closedOpen("r1", "r3"))
     .expectRowLimit(2)
     .respondWith("r1", "r2")
     .respondWithStatus(Code.UNAVAILABLE));
 // Second retry request is handled locally in ReadRowsRetryCompletedCallable
 List<String> actualResults = getResults(Query.create(TABLE_ID).range("r1", "r3").limit(2));
 Truth.assertThat(actualResults).containsExactly("r1", "r2");
}

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

@Test
public void retryWithLastScannedKeyTest() {
 service.expectations.add(
   RpcExpectation.create()
     .expectRequest(Range.closedOpen("r1", "r9"))
     .respondWithLastScannedKey("r5")
     .respondWithStatus(Code.UNAVAILABLE));
 service.expectations.add(
   RpcExpectation.create().expectRequest(Range.open("r5", "r9")).respondWith("r7"));
 List<String> actualResults =
   getResults(Query.create(TABLE_ID).range(ByteStringRange.create("r1", "r9")));
 Truth.assertThat(actualResults).containsExactly("r7").inOrder();
}

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

@Test
public void retryUnboundedStartTest() {
 service.expectations.add(
   RpcExpectation.create()
     .expectRequest(Range.lessThan("r9"))
     .respondWith("r1")
     .respondWithStatus(Code.UNAVAILABLE));
 service.expectations.add(
   RpcExpectation.create().expectRequest(Range.open("r1", "r9")).respondWith("r2"));
 List<String> actualResults =
   getResults(Query.create(TABLE_ID).range(ByteStringRange.unbounded().endOpen("r9")));
 Truth.assertThat(actualResults).containsExactly("r1", "r2").inOrder();
}

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

@Test
public void retryUnboundedEndTest() {
 service.expectations.add(
   RpcExpectation.create()
     .expectRequest(Range.atLeast("r1"))
     .respondWith("r1")
     .respondWithStatus(Code.UNAVAILABLE));
 service.expectations.add(
   RpcExpectation.create().expectRequest(Range.greaterThan("r1")).respondWith("r2"));
 List<String> actualResults =
   getResults(Query.create(TABLE_ID).range(ByteStringRange.unbounded().startClosed("r1")));
 Truth.assertThat(actualResults).containsExactly("r1", "r2").inOrder();
}

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

@Test
public void rowLimitTest() {
 service.expectations.add(
   RpcExpectation.create()
     .expectRequest(Range.closedOpen("r1", "r3"))
     .expectRowLimit(2)
     .respondWith("r1")
     .respondWithStatus(Code.UNAVAILABLE));
 service.expectations.add(
   RpcExpectation.create()
     .expectRequest(Range.open("r1", "r3"))
     .expectRowLimit(1)
     .respondWith("r2"));
 List<String> actualResults = getResults(Query.create(TABLE_ID).range("r1", "r3").limit(2));
 Truth.assertThat(actualResults).containsExactly("r1", "r2").inOrder();
}

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

@Test
public void shardTestKeyOffsets() {
 Query query = Query.create(TABLE_ID).range("a", "z");

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

@Test
public void multipleRetryTest() {
 service.expectations.add(
   RpcExpectation.create()
     .expectRequest(Range.closedOpen("r1", "r9"))
     .respondWith("r1", "r2", "r3", "r4")
     .respondWithStatus(Code.UNAVAILABLE));
 service.expectations.add(
   RpcExpectation.create()
     .expectRequest(Range.open("r4", "r9"))
     .respondWithStatus(Code.UNAVAILABLE));
 service.expectations.add(
   RpcExpectation.create()
     .expectRequest(Range.open("r4", "r9"))
     .respondWith("r5", "r6", "r7")
     .respondWithStatus(Code.UNAVAILABLE));
 service.expectations.add(
   RpcExpectation.create().expectRequest(Range.open("r7", "r9")).respondWith("r8"));
 List<String> actualResults = getResults(Query.create(TABLE_ID).range("r1", "r9"));
 Truth.assertThat(actualResults)
   .containsExactly("r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8")
   .inOrder();
}

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

@Test
public void shardTestSplitPoints() {
 Query query = Query.create(TABLE_ID).range("a", "z");

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

public Query prefix(ByteString prefix) {
 return range(ByteStringRange.prefix(prefix));
}

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

public Query prefix(String prefix) {
 return range(ByteStringRange.prefix(prefix));
}

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

/**
 * Adds a range to be looked up.
 *
 * @param start The beginning of the range (inclusive). Can be null to represent negative
 *     infinity.
 * @param end The end of the range (exclusive). Can be null to represent positive infinity.
 */
public Query range(String start, String end) {
 return range(wrapKey(start), wrapKey(end));
}

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

query.range(byteRange);

相关文章