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

x33g5p2x  于2021-06-29 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(292)

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

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

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

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

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

  1. /**
  2. * Adds a range to be looked up.
  3. *
  4. * @param start The beginning of the range (inclusive). Can be null to represent negative
  5. * infinity.
  6. * @param end The end of the range (exclusive). Can be null to represent positive infinity.
  7. */
  8. public Query range(String start, String end) {
  9. return range(wrapKey(start), wrapKey(end));
  10. }

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

  1. @Test
  2. public void rowRangeTest() {
  3. Query query =
  4. Query.create(TABLE_ID)
  5. .range("simple-begin", "simple-end")
  6. .range(ByteString.copyFromUtf8("byte-begin"), ByteString.copyFromUtf8("byte-end"))
  7. .range(ByteStringRange.create("range-begin", "range-end"));
  8. Builder expectedProto = expectedProtoBuilder();
  9. expectedProto
  10. .getRowsBuilder()
  11. .addRowRanges(
  12. RowRange.newBuilder()
  13. .setStartKeyClosed(ByteString.copyFromUtf8("simple-begin"))
  14. .setEndKeyOpen(ByteString.copyFromUtf8("simple-end")))
  15. .addRowRanges(
  16. RowRange.newBuilder()
  17. .setStartKeyClosed(ByteString.copyFromUtf8("byte-begin"))
  18. .setEndKeyOpen(ByteString.copyFromUtf8("byte-end")))
  19. .addRowRanges(
  20. RowRange.newBuilder()
  21. .setStartKeyClosed(ByteString.copyFromUtf8("range-begin"))
  22. .setEndKeyOpen(ByteString.copyFromUtf8("range-end")));
  23. ReadRowsRequest actualProto = query.toProto(requestContext);
  24. assertThat(actualProto).isEqualTo(expectedProto.build());
  25. }

代码示例来源: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 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 errorAfterRowLimitMetTest() {
  3. service.expectations.add(
  4. RpcExpectation.create()
  5. .expectRequest(Range.closedOpen("r1", "r3"))
  6. .expectRowLimit(2)
  7. .respondWith("r1", "r2")
  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").limit(2));
  11. Truth.assertThat(actualResults).containsExactly("r1", "r2");
  12. }

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

  1. @Test
  2. public void retryWithLastScannedKeyTest() {
  3. service.expectations.add(
  4. RpcExpectation.create()
  5. .expectRequest(Range.closedOpen("r1", "r9"))
  6. .respondWithLastScannedKey("r5")
  7. .respondWithStatus(Code.UNAVAILABLE));
  8. service.expectations.add(
  9. RpcExpectation.create().expectRequest(Range.open("r5", "r9")).respondWith("r7"));
  10. List<String> actualResults =
  11. getResults(Query.create(TABLE_ID).range(ByteStringRange.create("r1", "r9")));
  12. Truth.assertThat(actualResults).containsExactly("r7").inOrder();
  13. }

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

  1. @Test
  2. public void retryUnboundedStartTest() {
  3. service.expectations.add(
  4. RpcExpectation.create()
  5. .expectRequest(Range.lessThan("r9"))
  6. .respondWith("r1")
  7. .respondWithStatus(Code.UNAVAILABLE));
  8. service.expectations.add(
  9. RpcExpectation.create().expectRequest(Range.open("r1", "r9")).respondWith("r2"));
  10. List<String> actualResults =
  11. getResults(Query.create(TABLE_ID).range(ByteStringRange.unbounded().endOpen("r9")));
  12. Truth.assertThat(actualResults).containsExactly("r1", "r2").inOrder();
  13. }

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

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

代码示例来源: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. @Test
  2. public void rowLimitTest() {
  3. service.expectations.add(
  4. RpcExpectation.create()
  5. .expectRequest(Range.closedOpen("r1", "r3"))
  6. .expectRowLimit(2)
  7. .respondWith("r1")
  8. .respondWithStatus(Code.UNAVAILABLE));
  9. service.expectations.add(
  10. RpcExpectation.create()
  11. .expectRequest(Range.open("r1", "r3"))
  12. .expectRowLimit(1)
  13. .respondWith("r2"));
  14. List<String> actualResults = getResults(Query.create(TABLE_ID).range("r1", "r3").limit(2));
  15. Truth.assertThat(actualResults).containsExactly("r1", "r2").inOrder();
  16. }

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

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

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

  1. @Test
  2. public void multipleRetryTest() {
  3. service.expectations.add(
  4. RpcExpectation.create()
  5. .expectRequest(Range.closedOpen("r1", "r9"))
  6. .respondWith("r1", "r2", "r3", "r4")
  7. .respondWithStatus(Code.UNAVAILABLE));
  8. service.expectations.add(
  9. RpcExpectation.create()
  10. .expectRequest(Range.open("r4", "r9"))
  11. .respondWithStatus(Code.UNAVAILABLE));
  12. service.expectations.add(
  13. RpcExpectation.create()
  14. .expectRequest(Range.open("r4", "r9"))
  15. .respondWith("r5", "r6", "r7")
  16. .respondWithStatus(Code.UNAVAILABLE));
  17. service.expectations.add(
  18. RpcExpectation.create().expectRequest(Range.open("r7", "r9")).respondWith("r8"));
  19. List<String> actualResults = getResults(Query.create(TABLE_ID).range("r1", "r9"));
  20. Truth.assertThat(actualResults)
  21. .containsExactly("r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8")
  22. .inOrder();
  23. }

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

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

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

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

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

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

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

  1. /**
  2. * Adds a range to be looked up.
  3. *
  4. * @param start The beginning of the range (inclusive). Can be null to represent negative
  5. * infinity.
  6. * @param end The end of the range (exclusive). Can be null to represent positive infinity.
  7. */
  8. public Query range(String start, String end) {
  9. return range(wrapKey(start), wrapKey(end));
  10. }

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

  1. query.range(byteRange);

相关文章