You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Benjamin Lerer (JIRA)" <ji...@apache.org> on 2016/05/02 15:55:13 UTC

[jira] [Comment Edited] (CASSANDRA-11679) Cassandra Driver returns different number of results depending on fetchsize

    [ https://issues.apache.org/jira/browse/CASSANDRA-11679?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15266641#comment-15266641 ] 

Benjamin Lerer edited comment on CASSANDRA-11679 at 5/2/16 1:55 PM:
--------------------------------------------------------------------

I could not reproduce the problem that you described.
Could you run the following code using your java driver and tell me if you get more than 490 rows?
{code}
        session = cluster.connect();
        session.execute("CREATE KEYSPACE IF NOT EXISTS test WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : '1'}");
        session.execute("USE test");
        session.execute("DROP TABLE IF EXISTS test");
        session.execute("CREATE TABLE IF NOT EXISTS test (a int, b int, c int, PRIMARY KEY((a, b), c))");

        PreparedStatement prepare = session.prepare("INSERT INTO test (a, b, c) VALUES (?, ?, ?);");
        for (int i = 0; i < 10; i++)
            for (int j = 0; j < 49; j++)
                session.execute(prepare.bind(i, j, i + j));

        ResultSet rs = session.execute(new SimpleStatement("SELECT DISTINCT a, b FROM test")
                                              .setFetchSize(100));
        int count = 0;
        for (Row row : rs)
        {
            count++;
        }
        System.out.println(count);
{code}


was (Author: blerer):
I could not reproduce the problem that you describe.
Could you run the following code using your java driver and tell me if you get more than 490 rows?
{code}
        session = cluster.connect();
        session.execute("CREATE KEYSPACE IF NOT EXISTS test WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor' : '1'}");
        session.execute("USE test");
        session.execute("DROP TABLE IF EXISTS test");
        session.execute("CREATE TABLE IF NOT EXISTS test (a int, b int, c int, PRIMARY KEY((a, b), c))");

        PreparedStatement prepare = session.prepare("INSERT INTO test (a, b, c) VALUES (?, ?, ?);");
        for (int i = 0; i < 10; i++)
            for (int j = 0; j < 49; j++)
                session.execute(prepare.bind(i, j, i + j));

        ResultSet rs = session.execute(new SimpleStatement("SELECT DISTINCT a, b FROM test")
                                              .setFetchSize(100));
        int count = 0;
        for (Row row : rs)
        {
            count++;
        }
        System.out.println(count);
{code}

> Cassandra Driver returns different number of results depending on fetchsize
> ---------------------------------------------------------------------------
>
>                 Key: CASSANDRA-11679
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-11679
>             Project: Cassandra
>          Issue Type: Bug
>          Components: CQL
>            Reporter: Varun Barala
>            Assignee: Benjamin Lerer
>
> I'm trying to fetch all distinct keys from a CF using cassandra-driver (2.1.7.1) and I observed some strange behavior :-
> The total distinct rows are 498 so If I perform a query get All distinctKeys It return 503 instead of 498(five keys twice).
> But If I define the fetch size in select statement more than 498 then it returns exact 498 rows. 
> And If I execute same statement on Dev-center it returns 498 rows.
> Some Additional and useful information :- 
> -------------------------------------------------------
> Cassandra-2.1.13  (C)* version
> Consistency level: ONE 
> local machine(ubuntu 14.04)
> Table Schema:-
> ----------------------
> {code:xml}
> CREATE TABLE sample (
>      pk1 text,
>      pk2 text,
>     row_id uuid,
>     value blob,
>     PRIMARY KEY (( pk1,  pk2))
> ) WITH bloom_filter_fp_chance = 0.01
>     AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'
>     AND comment = ''
>     AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'}
>     AND compression = {'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'}
>     AND dclocal_read_repair_chance = 0.1
>     AND default_time_to_live = 0
>     AND gc_grace_seconds = 864000
>     AND max_index_interval = 2048
>     AND memtable_flush_period_in_ms = 0
>     AND min_index_interval = 128
>     AND read_repair_chance = 0.0
>     AND speculative_retry = '99.0PERCENTILE';
> {code}
> query :-
> ------------
> {code:xml}
> SELECT DISTINCT  pk2, pk1 FROM sample LIMIT 2147483647;
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)