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

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

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

Select.limit介绍

[英]Adds a LIMIT clause to this statement.
[中]在此语句中添加限制子句。

代码示例

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

/**
 * Adds a bind marker for the {@code LIMIT} clause to the {@code SELECT} statement this {@code
 * WHERE} clause is part of.
 *
 * @param limit the bind marker to use as limit.
 * @return the {@code SELECT} statement this {@code WHERE} clause is part of.
 * @throws IllegalStateException if a {@code LIMIT} clause has already been provided.
 */
public Select limit(BindMarker limit) {
 return statement.limit(limit);
}

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

/**
 * Adds a {@code LIMIT} clause to the {@code SELECT} statement this {@code WHERE} clause is part
 * of.
 *
 * @param limit the limit to set.
 * @return the {@code SELECT} statement this {@code WHERE} clause is part of.
 * @throws IllegalArgumentException if {@code limit <= 0}.
 * @throws IllegalStateException if a {@code LIMIT} clause has already been provided.
 */
public Select limit(int limit) {
 return statement.limit(limit);
}

代码示例来源:origin: hugegraph/hugegraph

String page = query.page();
if (page == null) {
  select.limit((int) total);
} else {
  select.setFetchSize((int) total);

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

/**
 * Adds a bind marker for the {@code LIMIT} clause to the {@code SELECT} statement this
 * {@code WHERE} clause if part of.
 *
 * @param limit the bind marker to use as limit.
 * @return the {@code SELECT} statement this {@code WHERE} clause if part of.
 * @throws IllegalStateException if a {@code LIMIT} clause has already been
 *                               provided.
 */
public Select limit(BindMarker limit) {
  return statement.limit(limit);
}

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

/**
 * Adds a bind marker for the {@code LIMIT} clause to the {@code SELECT} statement this
 * {@code WHERE} clause if part of.
 *
 * @param limit the bind marker to use as limit.
 * @return the {@code SELECT} statement this {@code WHERE} clause if part of.
 * @throws IllegalStateException if a {@code LIMIT} clause has already been
 *                               provided.
 */
public Select limit(BindMarker limit) {
  return statement.limit(limit);
}

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

/**
 * Adds a bind marker for the {@code LIMIT} clause to the {@code SELECT} statement this
 * {@code WHERE} clause if part of.
 *
 * @param limit the bind marker to use as limit.
 * @return the {@code SELECT} statement this {@code WHERE} clause if part of.
 * @throws IllegalStateException if a {@code LIMIT} clause has already been
 *                               provided.
 */
public Select limit(BindMarker limit) {
  return statement.limit(limit);
}

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

assertThat(select().all().from("foo").perPartitionLimit(bindMarker("limit")).toString())
  .isEqualTo("SELECT * FROM foo PER PARTITION LIMIT :limit;");
assertThat(select().all().from("foo").perPartitionLimit(2).limit(bindMarker()).toString())
  .isEqualTo("SELECT * FROM foo PER PARTITION LIMIT 2 LIMIT ?;");
assertThat(
      .where(in("a", 2, 4))
      .perPartitionLimit(2)
      .limit(3)
      .toString())
  .isEqualTo("SELECT * FROM foo WHERE a IN (2,4) PER PARTITION LIMIT 2 LIMIT 3;");
      .where(eq("a", bindMarker()))
      .perPartitionLimit(bindMarker())
      .limit(3)
      .toString())
  .isEqualTo("SELECT * FROM foo WHERE a=? PER PARTITION LIMIT ? LIMIT 3;");
      .orderBy(desc("b"))
      .perPartitionLimit(2)
      .limit(3)
      .toString())
  .isEqualTo("SELECT * FROM foo WHERE a=? ORDER BY b DESC PER PARTITION LIMIT 2 LIMIT 3;");
      .orderBy(desc("b"))
      .perPartitionLimit(bindMarker())
      .limit(3)
      .allowFiltering()
      .toString())

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

.and(eq(quote("C"), "foo"))
    .orderBy(asc("a"), desc("b"))
    .limit(42);
assertEquals(select.toString(), query);
    .as("ttla")
    .from("foo")
    .limit(bindMarker("limit"));
assertEquals(select.toString(), query);
    .cast(fcall("writetime", column("country")), DataType.text())
    .from("artists")
    .limit(2);
assertEquals(select.toString(), query);
select = select().raw("CAST(writetime(country) AS text)").from("artists").limit(2);
assertEquals(select.toString(), query);
 select().all().from("foo").limit(-42);
 fail("Expected an IllegalArgumentException");
} catch (IllegalArgumentException e) {
 select().all().from("foo").limit(42).limit(42);
 fail("Expected an IllegalStateException");
} catch (IllegalStateException e) {

代码示例来源:origin: io.zipkin.zipkin2/zipkin-storage-cassandra-v1

@Override
public CheckResult check() {
 if (closeCalled) throw new IllegalStateException("closed");
 CassandraSpanConsumer maybeConsumer = spanConsumer;
 if (maybeConsumer != null) maybeConsumer.clear();
 try {
  session.get().execute(QueryBuilder.select("trace_id").from("traces").limit(1));
 } catch (RuntimeException e) {
  return CheckResult.failed(e);
 }
 return CheckResult.OK;
}

代码示例来源:origin: io.zipkin.java/zipkin-storage-cassandra

@Override public CheckResult check() {
 try {
  session.get().execute(QueryBuilder.select("trace_id").from("traces").limit(1));
 } catch (RuntimeException e) {
  return CheckResult.failed(e);
 }
 return CheckResult.OK;
}

代码示例来源:origin: scalar-labs/scalardb

private Select prepare(Scan scan) {
 Select select = getSelect(scan);
 createStatement(select.where(), scan);
 List<Ordering> orderings = getOrderings(scan.getOrderings());
 if (!orderings.isEmpty()) {
  select.orderBy(orderings.toArray(new Ordering[orderings.size()]));
 }
 if (scan.getLimit() > 0) {
  select.limit(scan.getLimit());
 }
 return select;
}

代码示例来源:origin: tech.aroma.banana/banana-data-operations

private Statement createQueryForRecentlyCreatedApps()
{
  return queryBuilder
    .select()
    .all()
    .from(TABLE_NAME_RECENTLY_CREATED)
    .limit(200)
    .allowFiltering();
}

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

.from(table)
        .groupBy("a", "b")
        .limit(2)))
.containsExactly(row(1, 2, 6, 2L, 12), row(1, 4, 12, 2L, 24));
        .groupBy("a", "b")
        .perPartitionLimit(1)
        .limit(2)))
.containsExactly(row(1, 2, 6, 2L, 12), row(2, 2, 6, 1L, 6));
  session().execute(select("a", count("a")).distinct().from(table).groupBy("a").limit(2)))
.containsExactly(row(1, 1L), row(2, 1L));
        .where(eq("a", 1))
        .groupBy("a", "b", "c")
        .limit(2)))
.containsExactly(row(1, 2, 6, 1L, 6), row(1, 2, 12, 1L, 12));
        .groupBy("a", "b", "c")
        .orderBy(desc("b"), desc("c"))
        .limit(2)))
.containsExactly(row(1, 4, 24, 2L, 24), row(1, 2, 12, 1L, 12));
        .where(in("a", 1, 2, 4))
        .groupBy("a")
        .limit(2)))
.containsExactly(row(1, 1L), row(2, 1L));
        .groupBy("a", "b")

代码示例来源:origin: tech.aroma/aroma-data-operations

private Statement createQueryToFindMessagesByApplication(String applicationId)
{
  UUID appId = UUID.fromString(applicationId);
  return QueryBuilder
      .select()
      .all()
      .from(Messages.TABLE_NAME)
      .where(eq(APP_ID, appId))
      .orderBy(desc(MESSAGE_ID))
      .limit(3000);
}

代码示例来源:origin: tech.aroma.banana/banana-data-operations

private Statement createQueryToFindMessagesByApplication(String applicationId)
{
  UUID appId = UUID.fromString(applicationId);
  
  return queryBuilder
    .select()
    .all()
    .from(Messages.TABLE_NAME)
    .where(eq(APP_ID, appId))
    .orderBy(desc(MESSAGE_ID))
    .limit(3000);
}

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

row(4, 1, 1));
assertThat(session().execute(select().all().from("test_ppl").perPartitionLimit(2).limit(6)))
  .hasSize(6);
assertThat(session().execute(select().all().from("test_ppl").perPartitionLimit(2).limit(5)))
  .contains(row(0, 0, 0), row(0, 1, 1), row(1, 0, 0), row(1, 1, 1), row(2, 0, 0));
          .where(in("a", 2, 3))
          .perPartitionLimit(bindMarker())
          .limit(3)
          .getQueryString(),
        2))
          .where(in("a", 1, 2, 3))
          .perPartitionLimit(bindMarker())
          .limit(3)
          .getQueryString(),
        2))

代码示例来源:origin: org.apache.metamodel/MetaModel-cassandra

@Override
protected DataSet materializeMainSchemaTable(Table table, List<Column> columns, int maxRows) {
  final Select query = QueryBuilder.select().all().from(keySpaceName, table.getName());
  if (limitMaxRowsIsSet(maxRows)) {
    query.limit(maxRows);
  }
  final ResultSet resultSet = cassandraCluster.connect().execute(query);
  final Iterator<Row> response = resultSet.iterator();
  return new CassandraDataSet(response, columns);
}

代码示例来源:origin: apache/metamodel

@Override
protected DataSet materializeMainSchemaTable(Table table, List<Column> columns, int maxRows) {
  final Select query = QueryBuilder.select().all().from(keySpaceName, table.getName());
  if (limitMaxRowsIsSet(maxRows)) {
    query.limit(maxRows);
  }
  final ResultSet resultSet = cassandraCluster.connect().execute(query);
  final Iterator<Row> response = resultSet.iterator();
  return new CassandraDataSet(response, columns);
}

代码示例来源:origin: apache/james-project

private Mono<?> truncate(CassandraAsyncExecutor executor, String name) {
    return Mono.fromFuture(executor.execute(
        QueryBuilder.select()
            .from(name)
            .limit(1)
            .setFetchSize(1)))
        .filter(resultSet -> !resultSet.isExhausted())
        .flatMap(ignored -> Mono.fromFuture(executor.execute(QueryBuilder.truncate(name))));
  }
}

代码示例来源:origin: org.apache.james/apache-james-mailbox-cassandra

private PreparedStatement prepareReadStatement(Session session) {
  return session.prepare(select(UID)
    .from(TABLE_NAME)
    .where(eq(MAILBOX_ID, bindMarker(MAILBOX_ID)))
    .orderBy(asc(UID))
    .limit(1));
}

相关文章