[
https://issues.apache.org/jira/browse/CASSANDRA-7529?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Michael Shuler resolved CASSANDRA-7529.
---------------------------------------
Resolution: Invalid
For an issue with the Java driver, could you please open a ticket in that
project's Jira? https://datastax-oss.atlassian.net/browse/JAVA/
Thanks!
> IN clause does not work correctly outside the QueryBuilder
> ----------------------------------------------------------
>
> Key: CASSANDRA-7529
> URL: https://issues.apache.org/jira/browse/CASSANDRA-7529
> Project: Cassandra
> Issue Type: Bug
> Components: Drivers (now out of tree)
> Reporter: Carlo Bertuccini
> Priority: Critical
> Labels: In, PreparedStatement, QueryBuilder
>
> There is a strange behaviour of the IN clause with lots of keys when used
> outside a QueryBuilder. Here is the test I did using the Java Driver 2.0.3
> and Cassandra 2.0.7
> {code}
> CREATE TABLE inlimit (
> key int,
> value text,
> PRIMARY KEY (key)
> )
> {code}
> I've populated the table with 105000 entries (key from 0 to 104999).
> {code}
> cqlsh:test> select count(*) from inlimit limit 200000;
> count
> --------
> 105000
> {code}
> Here the test:
> {code}
> String query = "SELECT * FROM inlimit WHERE key IN :key";
> PreparedStatement ps = Cassandra.DB.getSession().prepare(query);
> BoundStatement bs = new BoundStatement(ps);
> List<Integer> l = new ArrayList<>();
> for (int i = 0; i < 100000; i++) {
> l.add(i);
> }
> bs.setList("key", l);
> ResultSet rs = Cassandra.DB.getSession().execute(bs);
> System.out.println("counted rows: " + rs.all().size());
> {code}
> Here the output:
> {panel}
> counted rows: 34464
> {panel}
> While with QueryBuilder everything changes:
> {code}
> List<Integer> l = new ArrayList<>();
> for (int i = 0; i < 100000; i++) {
> l.add(i);
> }
> BuiltStatement bs =
> QueryBuilder.select().all().from("inlimit").where(in("key", l.toArray()));
> ResultSet rs = Cassandra.DB.getSession().execute(bs);
> System.out.println("counted rows: " + rs.all().size());
> {code}
> The new output
> {panel}
> counted rows: 100000
> {panel}
> BTW: I'd suggest to write somewhere if the IN clause has some limitations
> cause I found this question without answer in many forums.
> Cheers,
> Carlo
--
This message was sent by Atlassian JIRA
(v6.2#6252)