com.datastax.driver.core.querybuilder.Select.perPartitionLimit()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(11.8k)|赞(0)|评价(0)|浏览(288)

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

Select.perPartitionLimit介绍

[英]Adds a PER PARTITION LIMIT clause to this statement.

Note: support for PER PARTITION LIMIT clause is only available from Cassandra 3.6 onwards.
[中]将每个分区的限制子句添加到此语句中。
注:对每个分区限制条款的支持仅在Cassandra 3.6之后提供。

代码示例

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

  1. /**
  2. * Adds a bind marker for the {@code PER PARTITION LIMIT} clause to the {@code SELECT} statement
  3. * this {@code WHERE} clause is part of.
  4. *
  5. * <p>Note: support for {@code PER PARTITION LIMIT} clause is only available from Cassandra 3.6
  6. * onwards.
  7. *
  8. * @param limit the bind marker to use as limit per partition.
  9. * @return the {@code SELECT} statement this {@code WHERE} clause is part of.
  10. * @throws IllegalStateException if a {@code PER PARTITION LIMIT} clause has already been
  11. * provided.
  12. * @throws IllegalStateException if this statement is a {@code SELECT DISTINCT} statement.
  13. */
  14. public Select perPartitionLimit(BindMarker limit) {
  15. return statement.perPartitionLimit(limit);
  16. }

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

  1. /**
  2. * Adds a {@code PER PARTITION LIMIT} clause to the {@code SELECT} statement this {@code WHERE}
  3. * clause is part of.
  4. *
  5. * <p>Note: support for {@code PER PARTITION LIMIT} clause is only available from Cassandra 3.6
  6. * onwards.
  7. *
  8. * @param perPartitionLimit the limit to set per partition.
  9. * @return the {@code SELECT} statement this {@code WHERE} clause is part of.
  10. * @throws IllegalArgumentException if {@code perPartitionLimit <= 0}.
  11. * @throws IllegalStateException if a {@code PER PARTITION LIMIT} clause has already been
  12. * provided.
  13. * @throws IllegalStateException if this statement is a {@code SELECT DISTINCT} statement.
  14. */
  15. public Select perPartitionLimit(int perPartitionLimit) {
  16. return statement.perPartitionLimit(perPartitionLimit);
  17. }

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver

  1. /**
  2. * Adds a bind marker for the {@code PER PARTITION LIMIT} clause to the {@code SELECT} statement this
  3. * {@code WHERE} clause if part of.
  4. * <p>
  5. * Note: support for {@code PER PARTITION LIMIT} clause is only available from
  6. * Cassandra 3.6 onwards.
  7. *
  8. * @param limit the bind marker to use as limit per partition.
  9. * @return the {@code SELECT} statement this {@code WHERE} clause if part of.
  10. * @throws IllegalStateException if a {@code PER PARTITION LIMIT} clause has already been
  11. * provided.
  12. * @throws IllegalStateException if this statement is a {@code SELECT DISTINCT} statement.
  13. */
  14. public Select perPartitionLimit(BindMarker limit) {
  15. return statement.perPartitionLimit(limit);
  16. }

代码示例来源:origin: io.prestosql.cassandra/cassandra-driver

  1. /**
  2. * Adds a bind marker for the {@code PER PARTITION LIMIT} clause to the {@code SELECT} statement this
  3. * {@code WHERE} clause if part of.
  4. * <p>
  5. * Note: support for {@code PER PARTITION LIMIT} clause is only available from
  6. * Cassandra 3.6 onwards.
  7. *
  8. * @param limit the bind marker to use as limit per partition.
  9. * @return the {@code SELECT} statement this {@code WHERE} clause if part of.
  10. * @throws IllegalStateException if a {@code PER PARTITION LIMIT} clause has already been
  11. * provided.
  12. * @throws IllegalStateException if this statement is a {@code SELECT DISTINCT} statement.
  13. */
  14. public Select perPartitionLimit(BindMarker limit) {
  15. return statement.perPartitionLimit(limit);
  16. }

代码示例来源:origin: com.yugabyte/cassandra-driver-core

  1. /**
  2. * Adds a bind marker for the {@code PER PARTITION LIMIT} clause to the {@code SELECT} statement this
  3. * {@code WHERE} clause if part of.
  4. * <p>
  5. * Note: support for {@code PER PARTITION LIMIT} clause is only available from
  6. * Cassandra 3.6 onwards.
  7. *
  8. * @param limit the bind marker to use as limit per partition.
  9. * @return the {@code SELECT} statement this {@code WHERE} clause if part of.
  10. * @throws IllegalStateException if a {@code PER PARTITION LIMIT} clause has already been
  11. * provided.
  12. * @throws IllegalStateException if this statement is a {@code SELECT DISTINCT} statement.
  13. */
  14. public Select perPartitionLimit(BindMarker limit) {
  15. return statement.perPartitionLimit(limit);
  16. }

代码示例来源:origin: com.yugabyte/cassandra-driver-core

  1. /**
  2. * Adds a {@code PER PARTITION LIMIT} clause to the {@code SELECT} statement this
  3. * {@code WHERE} clause if part of.
  4. * <p>
  5. * Note: support for {@code PER PARTITION LIMIT} clause is only available from
  6. * Cassandra 3.6 onwards.
  7. *
  8. * @param perPartitionLimit the limit to set per partition.
  9. * @return the {@code SELECT} statement this {@code WHERE} clause if part of.
  10. * @throws IllegalArgumentException if {@code perPartitionLimit <= 0}.
  11. * @throws IllegalStateException if a {@code PER PARTITION LIMIT} clause has already been
  12. * provided.
  13. * @throws IllegalStateException if this statement is a {@code SELECT DISTINCT} statement.
  14. */
  15. public Select perPartitionLimit(int perPartitionLimit) {
  16. return statement.perPartitionLimit(perPartitionLimit);
  17. }

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver

  1. /**
  2. * Adds a {@code PER PARTITION LIMIT} clause to the {@code SELECT} statement this
  3. * {@code WHERE} clause if part of.
  4. * <p>
  5. * Note: support for {@code PER PARTITION LIMIT} clause is only available from
  6. * Cassandra 3.6 onwards.
  7. *
  8. * @param perPartitionLimit the limit to set per partition.
  9. * @return the {@code SELECT} statement this {@code WHERE} clause if part of.
  10. * @throws IllegalArgumentException if {@code perPartitionLimit <= 0}.
  11. * @throws IllegalStateException if a {@code PER PARTITION LIMIT} clause has already been
  12. * provided.
  13. * @throws IllegalStateException if this statement is a {@code SELECT DISTINCT} statement.
  14. */
  15. public Select perPartitionLimit(int perPartitionLimit) {
  16. return statement.perPartitionLimit(perPartitionLimit);
  17. }

代码示例来源:origin: io.prestosql.cassandra/cassandra-driver

  1. /**
  2. * Adds a {@code PER PARTITION LIMIT} clause to the {@code SELECT} statement this
  3. * {@code WHERE} clause if part of.
  4. * <p>
  5. * Note: support for {@code PER PARTITION LIMIT} clause is only available from
  6. * Cassandra 3.6 onwards.
  7. *
  8. * @param perPartitionLimit the limit to set per partition.
  9. * @return the {@code SELECT} statement this {@code WHERE} clause if part of.
  10. * @throws IllegalArgumentException if {@code perPartitionLimit <= 0}.
  11. * @throws IllegalStateException if a {@code PER PARTITION LIMIT} clause has already been
  12. * provided.
  13. * @throws IllegalStateException if this statement is a {@code SELECT DISTINCT} statement.
  14. */
  15. public Select perPartitionLimit(int perPartitionLimit) {
  16. return statement.perPartitionLimit(perPartitionLimit);
  17. }

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

  1. @Test(groups = "unit")
  2. public void should_handle_per_partition_limit_clause() {
  3. assertThat(select().all().from("foo").perPartitionLimit(2).toString())
  4. .isEqualTo("SELECT * FROM foo PER PARTITION LIMIT 2;");
  5. assertThat(select().all().from("foo").perPartitionLimit(bindMarker()).toString())
  6. .isEqualTo("SELECT * FROM foo PER PARTITION LIMIT ?;");
  7. assertThat(select().all().from("foo").perPartitionLimit(bindMarker("limit")).toString())
  8. .isEqualTo("SELECT * FROM foo PER PARTITION LIMIT :limit;");
  9. assertThat(select().all().from("foo").perPartitionLimit(2).limit(bindMarker()).toString())
  10. .isEqualTo("SELECT * FROM foo PER PARTITION LIMIT 2 LIMIT ?;");
  11. assertThat(
  12. .where(eq("a", bindMarker()))
  13. .orderBy(desc("b"))
  14. .perPartitionLimit(2)
  15. .limit(3)
  16. .toString())
  17. .and(gt("b", bindMarker()))
  18. .orderBy(desc("b"))
  19. .perPartitionLimit(bindMarker())
  20. .limit(3)
  21. .allowFiltering()
  22. "SELECT * FROM foo WHERE a=? AND b>? ORDER BY b DESC PER PARTITION LIMIT ? LIMIT 3 ALLOW FILTERING;");
  23. try {
  24. select().distinct().all().from("foo").perPartitionLimit(3);
  25. fail("Should not allow DISTINCT + PER PARTITION LIMIT");
  26. } catch (Exception e) {

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

  1. .from(table)
  2. .groupBy("a", "b")
  3. .perPartitionLimit(1)))
  4. .containsExactly(row(1, 2, 6, 2L, 12), row(2, 2, 6, 1L, 6), row(4, 8, 24, 1L, 24));
  5. .from(table)
  6. .groupBy("a", "b")
  7. .perPartitionLimit(1)
  8. .limit(2)))
  9. .containsExactly(row(1, 2, 6, 2L, 12), row(2, 2, 6, 1L, 6));
  10. .where(eq("a", 1))
  11. .groupBy("a", "b", "c")
  12. .perPartitionLimit(2)))
  13. .containsExactly(row(1, 2, 6, 1L, 6), row(1, 2, 12, 1L, 12));
  14. .groupBy("a", "b", "c")
  15. .orderBy(desc("b"), desc("c"))
  16. .perPartitionLimit(1)))
  17. .containsExactly(row(1, 4, 24, 2L, 24));
  18. .where(in("a", 1, 2, 4))
  19. .groupBy("a", "b", "c")
  20. .perPartitionLimit(1)))
  21. .containsExactly(row(1, 2, 6, 1L, 6), row(2, 2, 6, 1L, 6), row(4, 8, 24, 1L, 24));
  22. .where(in("a", 1, 2, 4))
  23. .groupBy("a", "b", "c")
  24. .perPartitionLimit(2)))

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

  1. @Test(groups = "short")
  2. public void should_support_per_partition_limit() throws Exception {
  3. assertThat(session().execute(select().all().from("test_ppl").perPartitionLimit(2)))
  4. .contains(
  5. row(0, 0, 0),
  6. row(4, 1, 1));
  7. assertThat(session().execute(select().all().from("test_ppl").perPartitionLimit(2).limit(6)))
  8. .hasSize(6);
  9. assertThat(session().execute(select().all().from("test_ppl").perPartitionLimit(2).limit(5)))
  10. .contains(row(0, 0, 0), row(0, 1, 1), row(1, 0, 0), row(1, 1, 1), row(2, 0, 0));
  11. .where(eq("a", bindMarker()))
  12. .orderBy(desc("b"))
  13. .perPartitionLimit(bindMarker())
  14. .getQueryString(),
  15. 2,
  16. .and(gt("b", bindMarker()))
  17. .orderBy(desc("b"))
  18. .perPartitionLimit(bindMarker())
  19. .allowFiltering()
  20. .getQueryString(),

代码示例来源:origin: com.datastax.dse/dse-java-driver-core

  1. @Test(groups = "unit")
  2. public void should_handle_per_partition_limit_clause() {
  3. assertThat(select().all().from("foo").perPartitionLimit(2).toString())
  4. .isEqualTo("SELECT * FROM foo PER PARTITION LIMIT 2;");
  5. assertThat(select().all().from("foo").perPartitionLimit(bindMarker()).toString())
  6. .isEqualTo("SELECT * FROM foo PER PARTITION LIMIT ?;");
  7. assertThat(select().all().from("foo").perPartitionLimit(bindMarker("limit")).toString())
  8. .isEqualTo("SELECT * FROM foo PER PARTITION LIMIT :limit;");
  9. assertThat(select().all().from("foo").perPartitionLimit(2).limit(bindMarker()).toString())
  10. .isEqualTo("SELECT * FROM foo PER PARTITION LIMIT 2 LIMIT ?;");
  11. assertThat(
  12. .where(eq("a", bindMarker()))
  13. .orderBy(desc("b"))
  14. .perPartitionLimit(2)
  15. .limit(3)
  16. .toString())
  17. .and(gt("b", bindMarker()))
  18. .orderBy(desc("b"))
  19. .perPartitionLimit(bindMarker())
  20. .limit(3)
  21. .allowFiltering()
  22. "SELECT * FROM foo WHERE a=? AND b>? ORDER BY b DESC PER PARTITION LIMIT ? LIMIT 3 ALLOW FILTERING;");
  23. try {
  24. select().distinct().all().from("foo").perPartitionLimit(3);
  25. fail("Should not allow DISTINCT + PER PARTITION LIMIT");
  26. } catch (Exception e) {

代码示例来源:origin: com.datastax.dse/dse-java-driver-core

  1. .from(table)
  2. .groupBy("a", "b")
  3. .perPartitionLimit(1)))
  4. .containsExactly(row(1, 2, 6, 2L, 12), row(2, 2, 6, 1L, 6), row(4, 8, 24, 1L, 24));
  5. .from(table)
  6. .groupBy("a", "b")
  7. .perPartitionLimit(1)
  8. .limit(2)))
  9. .containsExactly(row(1, 2, 6, 2L, 12), row(2, 2, 6, 1L, 6));
  10. .where(eq("a", 1))
  11. .groupBy("a", "b", "c")
  12. .perPartitionLimit(2)))
  13. .containsExactly(row(1, 2, 6, 1L, 6), row(1, 2, 12, 1L, 12));
  14. .groupBy("a", "b", "c")
  15. .orderBy(desc("b"), desc("c"))
  16. .perPartitionLimit(1)))
  17. .containsExactly(row(1, 4, 24, 2L, 24));
  18. .where(in("a", 1, 2, 4))
  19. .groupBy("a", "b", "c")
  20. .perPartitionLimit(1)))
  21. .containsExactly(row(1, 2, 6, 1L, 6), row(2, 2, 6, 1L, 6), row(4, 8, 24, 1L, 24));
  22. .where(in("a", 1, 2, 4))
  23. .groupBy("a", "b", "c")
  24. .perPartitionLimit(2)))

代码示例来源:origin: com.datastax.dse/dse-java-driver-core

  1. @Test(groups = "short")
  2. public void should_support_per_partition_limit() throws Exception {
  3. assertThat(session().execute(select().all().from("test_ppl").perPartitionLimit(2)))
  4. .contains(
  5. row(0, 0, 0),
  6. row(4, 1, 1));
  7. assertThat(session().execute(select().all().from("test_ppl").perPartitionLimit(2).limit(6)))
  8. .hasSize(6);
  9. assertThat(session().execute(select().all().from("test_ppl").perPartitionLimit(2).limit(5)))
  10. .contains(row(0, 0, 0), row(0, 1, 1), row(1, 0, 0), row(1, 1, 1), row(2, 0, 0));
  11. .where(eq("a", bindMarker()))
  12. .orderBy(desc("b"))
  13. .perPartitionLimit(bindMarker())
  14. .getQueryString(),
  15. 2,
  16. .and(gt("b", bindMarker()))
  17. .orderBy(desc("b"))
  18. .perPartitionLimit(bindMarker())
  19. .allowFiltering()
  20. .getQueryString(),

相关文章