You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Carlo Bertuccini (JIRA)" <ji...@apache.org> on 2014/07/09 19:59:05 UTC

[jira] [Created] (CASSANDRA-7529) IN clause does not work correctly outside the QueryBuilder

Carlo Bertuccini created CASSANDRA-7529:
-------------------------------------------

             Summary: 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


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 1 to 105000).
{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().column("key").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)