[
https://issues.apache.org/jira/browse/CASSANDRA-11679?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15266660#comment-15266660
]
Varun Barala commented on CASSANDRA-11679:
------------------------------------------
I'll check this one But I'm gonna share one test case with you which will
reproduce the problem :-
{code-xml}
package com.datastax.driver.core;
import static org.junit.Assert.*;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
public class LererCheckTest {
private static Cluster cluster;
private static Session session;
@BeforeClass
public static void init(){
cluster=Cluster.builder().addContactPoint("127.0.0.1").build();
session = cluster.connect();
}
@AfterClass
public static void close(){
cluster.close();
}
@Before
public void initData(){
session.execute("drop keyspace if exists junit;");
session.execute("create keyspace junit WITH REPLICATION = { 'class' :
'SimpleStrategy', 'replication_factor' : 1 };");
session.execute("CREATE TABLE junit.magic (" +
" tenant_id text," +
" str_key text," +
" row_id int," +
" value int," +
" PRIMARY KEY((tenant_id,str_key))" +
" );");
String insertQuery = "insert into junit.magic (" +
"tenant_id," +
"str_key," +
"row_id," +
"value" +
")" +
"VALUES ( " +
"'test_tenant',"+
"'%s',"+
"null,"+
"0" +
");";
for(int i=0;i<498;i++){
session.execute(String.format(insertQuery, ""+i));
}
System.out.println("498 records inserted successfully!!!");
}
@Test
public void checkDistKeysForMagic498(){
String query = "select distinct tenant_id,str_key from
product.magic498;";
Statement stsatementWithModifiedFetchSize = new
SimpleStatement(query);
Statement statementWithDefaultFetchSize= new
SimpleStatement(query);
stsatementWithModifiedFetchSize.setFetchSize(100);
// result set for default fetch size
ResultSet resultSetForDefaultFetchSize =
session.execute(statementWithDefaultFetchSize);
int totalDistinctKeysForDefaultFetchSize =
resultSetForDefaultFetchSize.all().size();
assertEquals(498, totalDistinctKeysForDefaultFetchSize);
// result set with fetch size as 100 <=498
ResultSet resultSetForModifiedDetchSize =
session.execute(stsatementWithModifiedFetchSize);
int totalDistinctKeysForModifiedFetchSize =
resultSetForModifiedDetchSize.all().size();
assertEquals(503, totalDistinctKeysForModifiedFetchSize);
}
}
{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)