简体   繁体   English

Cassandra:在Java中关闭分页

[英]Cassandra: turn the paging off in Java

say i have the following CQL3 query: 说我有以下CQL3查询:

QueryString = "SELECT id1, id2, link_type, visibility, data, time, version from keyspace.table where id1 = id1 and link_type = link_type and id2 **IN id2s** and time>= minTime and time<= maxTime ORDER BY time desc limit= rowLimit;"
  1. If i implement it as a Statement = new Statement (QueryString) i get this error (because of the brackets in the id2s: a List): 如果我将其实现为Statement = new Statement (QueryString) ,则会出现此错误(由于id2s中的方括号:一个列表):

no viable alternative at input '[' (...and link_type = 123456789 and [id2] IN...) 输入'['没有可行的选择(...和link_type = 123456789和[id2] IN ...)

---> how should i convert the List<Long> id2s to a List without brackets but with parentheses : (item1, item2, item3) --->如何将List<Long> id2s转换为不带括号但带有括号的列表:(item1,item2,item3)

  1. If i implement the query as a PreparedStatement: 如果我将查询实现为PreparedStatement:

PreparedStatement prepared = session.prepare(query);

the first Error was resolved but i get another: 第一个错误已解决,但我得到了另一个:

Cannot page queries with both ORDER BY and a IN restriction on the partition key; 无法对分区键同时具有ORDER BY和IN限制的页面查询; you must either remove the ORDER BY or the IN and sort client side, or disable paging for this query 您必须删除ORDER BY或IN并在客户端进行排序,或者为此查询禁用分页

----> how should i turn the paging off with a Prepared Statement (i found only solutions with the simple statement : statement.setfetchSize() but not with Prepared Solution) ---->我应该如何使用Prepared语句关闭分页(我仅使用简单的语句找到了解决方案:statement.setfetchSize(),而使用Prepared Solution找不到)

If i use a simple statement i get a problem with the Brackets/parentheses and if i use a prepared statement to solve the last, i get a problem with the paging. 如果我使用简单的语句,则括号/括号会出现问题,如果我使用准备好的语句来解决最后一个问题,则分页会出现问题。

Any idea ? 任何想法 ?

In Java you can turn off cassandra paging by following code 在Java中,您可以通过以下代码关闭cassandra分页

Statement statement = new SimpleStatement(query);
statement.setFetchSize(Integer.MAX_VALUE);

And execute the statement. 并执行该语句。

session.execute(statement);

It should work fine 应该很好

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM