[jira] [Comment Edited] (CASSANDRA-4532) NPE when trying to select a slice from a composite table
[ https://issues.apache.org/jira/browse/CASSANDRA-4532?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13449764#comment-13449764 ] basanth gowda edited comment on CASSANDRA-4532 at 9/7/12 3:00 AM: -- Sylvian, Thanks for the fix, May be I should have opened the ticket differently. My main issue is not that the connection on cqlsh was getting closed (because of NPE) or exception being thrown in thrift client. To adopt CQL3 mainstream slice with paging is need, I saw some other ticket, where this proposal was there. Main reason I opened the ticket was for not being able to slice (rather no syntax support for that, to continue where the last query left off). This is a piece of code that was written using Hector and my assumption is the filtering was done on server side. We are using this in production. I modified attributes (to get rid of proprietary stuff, so may be broken, but should give an idea of what I was trying to do with CQL3) long cStartTime = 0L; long startTime = System.nanoTime(); boolean fetchNextBatch = true; int totalKeysFetched = 0; String lastKeyFetched = null; long cEndTime = Some Time in Millis; while(fetchNextBatch) { fetchNextBatch = false; int pageSize = 3; //Just for demonstration SliceQueryObject,DynamicComposite,String sliceQuery = HFactory.createSliceQuery(keyspace,KEY SERIALIZER,DynamicCompositeSerializer.get(),StringSerializer.get()); sliceQuery.setKey(C); sliceQuery.setColumnFamily(SOME CF NAME); DynamicComposite startRange = new DynamicComposite(); startRange.addComponent(cStartTime,LongSerializer.get()); //For the first fetch - this will be 0L startRange.addComponent(lastKeyFetched,StringSerializer.get()); // this will be null for first fetch DynamicComposite endRange = new DynamicComposite(); endRange.addComponent(new Long(cEndTime), LongSerializer.get(), LongType, AbstractComposite.ComponentEquality.LESS_THAN_EQUAL); //Add another config if we need columnPageSize sliceQuery.setRange(startRange,endRange,false,pageSize); long start = System.nanoTime(); QueryResultColumnSliceDynamicComposite, String result = sliceQuery.execute(); float t = (float)((System.nanoTime() - start)/100); System.out.println(TIME FOR QUERY : + t + MILLI SECONDS); ColumnSliceDynamicComposite, String cs = result.get(); ListHColumnDynamicComposite,String compositeList = cs.getColumns(); for(int i =0;icompositeList.size();i++) { HColumnDynamicComposite, String col = compositeList.get(i); cStartTime = col.getName().get(0,LongSerializer.get()); //This will be the cTime for the start range of the next query lastKeyFetched = col.getName().get(1,StringSerializer.get()); //In the start range for the next query, this key will be used. keyTimeMap.put(lastKeyFetched,scheduleStartTime); totalKeysFetched ++; } //Process Fetched Data fetchNextBatch = compositeList.size() == pageSize; // If the number of records retrieved is equal to the page size, then there are probably more records left } was (Author: basu76): Sylvian, Thanks for the fix, May be I should have opened the ticket differently. My main issue is not that the connection on cqlsh was getting closed (because of NPE) or exception being thrown in thrift client. To adopt CQL3 mainstream slice with paging is need, I saw some other ticket, where this proposal was there. Main reason I opened the ticket was for not being able to slice (rather no syntax support for that, to continue where the last query left off). This is a piece of code that was written using Hector and my assumption is the filtering was done on server side. We are using this in production. I modified attributes (to get rid of proprietary stuff, so may be broken, but should give an idea of what I was trying to do with CQL3) long cStartTime = 0L; long startTime = System.nanoTime(); boolean fetchNextBatch = true; int totalKeysFetched = 0; String lastKeyFetched = null; long cEndTime = Some Time in Millis; while(fetchNextBatch) { fetchNextBatch = false; int pageSize = 3; //Just for demonstration SliceQueryObject,DynamicComposite,String sliceQuery =
[jira] [Comment Edited] (CASSANDRA-4532) NPE when trying to select a slice from a composite table
[ https://issues.apache.org/jira/browse/CASSANDRA-4532?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13449764#comment-13449764 ] basanth gowda edited comment on CASSANDRA-4532 at 9/7/12 3:01 AM: -- Sylvain, Thanks for the fix, May be I should have opened the ticket differently. My main issue is not that the connection on cqlsh was getting closed (because of NPE) or exception being thrown in thrift client. To adopt CQL3 mainstream slice with paging is need, I saw some other ticket, where this proposal was there. Main reason I opened the ticket was for not being able to slice (rather no syntax support for that, to continue where the last query left off). This is a piece of code that was written using Hector and my assumption is the filtering was done on server side. We are using this in production. I modified attributes (to get rid of proprietary stuff, so may be broken, but should give an idea of what I was trying to do with CQL3) long cStartTime = 0L; long startTime = System.nanoTime(); boolean fetchNextBatch = true; int totalKeysFetched = 0; String lastKeyFetched = null; long cEndTime = Some Time in Millis; while(fetchNextBatch) { fetchNextBatch = false; int pageSize = 3; //Just for demonstration SliceQueryObject,DynamicComposite,String sliceQuery = HFactory.createSliceQuery(keyspace,KEY SERIALIZER,DynamicCompositeSerializer.get(),StringSerializer.get()); sliceQuery.setKey(C); sliceQuery.setColumnFamily(SOME CF NAME); DynamicComposite startRange = new DynamicComposite(); startRange.addComponent(cStartTime,LongSerializer.get()); //For the first fetch - this will be 0L startRange.addComponent(lastKeyFetched,StringSerializer.get()); // this will be null for first fetch DynamicComposite endRange = new DynamicComposite(); endRange.addComponent(new Long(cEndTime), LongSerializer.get(), LongType, AbstractComposite.ComponentEquality.LESS_THAN_EQUAL); //Add another config if we need columnPageSize sliceQuery.setRange(startRange,endRange,false,pageSize); long start = System.nanoTime(); QueryResultColumnSliceDynamicComposite, String result = sliceQuery.execute(); float t = (float)((System.nanoTime() - start)/100); System.out.println(TIME FOR QUERY : + t + MILLI SECONDS); ColumnSliceDynamicComposite, String cs = result.get(); ListHColumnDynamicComposite,String compositeList = cs.getColumns(); for(int i =0;icompositeList.size();i++) { HColumnDynamicComposite, String col = compositeList.get(i); cStartTime = col.getName().get(0,LongSerializer.get()); //This will be the cTime for the start range of the next query lastKeyFetched = col.getName().get(1,StringSerializer.get()); //In the start range for the next query, this key will be used. keyTimeMap.put(lastKeyFetched,scheduleStartTime); totalKeysFetched ++; } //Process Fetched Data fetchNextBatch = compositeList.size() == pageSize; // If the number of records retrieved is equal to the page size, then there are probably more records left } was (Author: basu76): Sylvian, Thanks for the fix, May be I should have opened the ticket differently. My main issue is not that the connection on cqlsh was getting closed (because of NPE) or exception being thrown in thrift client. To adopt CQL3 mainstream slice with paging is need, I saw some other ticket, where this proposal was there. Main reason I opened the ticket was for not being able to slice (rather no syntax support for that, to continue where the last query left off). This is a piece of code that was written using Hector and my assumption is the filtering was done on server side. We are using this in production. I modified attributes (to get rid of proprietary stuff, so may be broken, but should give an idea of what I was trying to do with CQL3) long cStartTime = 0L; long startTime = System.nanoTime(); boolean fetchNextBatch = true; int totalKeysFetched = 0; String lastKeyFetched = null; long cEndTime = Some Time in Millis; while(fetchNextBatch) { fetchNextBatch = false; int pageSize = 3; //Just for demonstration SliceQueryObject,DynamicComposite,String sliceQuery = HFactory.createSliceQuery(keyspace,KEY
[jira] [Comment Edited] (CASSANDRA-4532) NPE when trying to select a slice from a composite table
[ https://issues.apache.org/jira/browse/CASSANDRA-4532?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=13444099#comment-13444099 ] basanth gowda edited comment on CASSANDRA-4532 at 8/30/12 1:21 AM: --- No luck. See the last query closed the socket. I took the latest from git and compiled Here are the steps to reproduce : cqlsh:testkeyspace1 create table compositetest(status ascii,ctime bigint,key ascii,nil ascii,PRIMARY KEY(status,ctime,key)); cqlsh:testkeyspace1 insert into compositetest(status,ctime,key,nil) VALUES ('C',12345678,'key1',''); cqlsh:testkeyspace1 insert into compositetest(status,ctime,key,nil) VALUES ('C',12345678,'key2',''); cqlsh:testkeyspace1 insert into compositetest(status,ctime,key,nil) VALUES ('C',12345679,'key3',''); cqlsh:testkeyspace1 insert into compositetest(status,ctime,key,nil) VALUES ('C',12345679,'key4',''); cqlsh:testkeyspace1 insert into compositetest(status,ctime,key,nil) VALUES ('C',12345679,'key5',''); cqlsh:testkeyspace1 insert into compositetest(status,ctime,key,nil) VALUES ('C',12345680,'key6',''); cqlsh:testkeyspace1 select * from compositetest; status | ctime| key | nil +--+--+- C | 12345678 | key1 | C | 12345678 | key2 | C | 12345679 | key3 | C | 12345679 | key4 | C | 12345679 | key5 | C | 12345680 | key6 | 1st query of slice : cqlsh:testkeyspace1 select * from compositetest where ctime=12345680 limit 3; status | ctime| key | nil +--+--+-- C | 12345678 | key1 | C | 12345678 | key2 | C | 12345679 | key3 | null Second Query : I want to get values where first one left off (Yes you could do this with hector) [Try 1] cqlsh:testkeyspace1 select * from compositetest where ctime=12345679 and key='key3' and ctime=12345680 limit 3; Bad Request: PRIMARY KEY part key cannot be restricted (preceding part ctime is either not restricted or by a non-EQ relation) [Try 2] cqlsh:testkeyspace1 select * from compositetest where ctime=12345679 and key='key3' and ctime=12345680 limit 3; TSocket read 0 bytes cqlsh:testkeyspace1 was (Author: basu76): No luck. See the last query closed the socket. Here are the steps to reproduce : cqlsh:testkeyspace1 create table compositetest(status ascii,ctime bigint,key ascii,nil ascii,PRIMARY KEY(status,ctime,key)); cqlsh:testkeyspace1 insert into compositetest(status,ctime,key,nil) VALUES ('C',12345678,'key1',''); cqlsh:testkeyspace1 insert into compositetest(status,ctime,key,nil) VALUES ('C',12345678,'key2',''); cqlsh:testkeyspace1 insert into compositetest(status,ctime,key,nil) VALUES ('C',12345679,'key3',''); cqlsh:testkeyspace1 insert into compositetest(status,ctime,key,nil) VALUES ('C',12345679,'key4',''); cqlsh:testkeyspace1 insert into compositetest(status,ctime,key,nil) VALUES ('C',12345679,'key5',''); cqlsh:testkeyspace1 insert into compositetest(status,ctime,key,nil) VALUES ('C',12345680,'key6',''); cqlsh:testkeyspace1 select * from compositetest; status | ctime| key | nil +--+--+- C | 12345678 | key1 | C | 12345678 | key2 | C | 12345679 | key3 | C | 12345679 | key4 | C | 12345679 | key5 | C | 12345680 | key6 | 1st query of slice : cqlsh:testkeyspace1 select * from compositetest where ctime=12345680 limit 3; status | ctime| key | nil +--+--+-- C | 12345678 | key1 | C | 12345678 | key2 | C | 12345679 | key3 | null Second Query : I want to get values where first one left off (Yes you could do this with hector) [Try 1] cqlsh:testkeyspace1 select * from compositetest where ctime=12345679 and key='key3' and ctime=12345680 limit 3; Bad Request: PRIMARY KEY part key cannot be restricted (preceding part ctime is either not restricted or by a non-EQ relation) [Try 2] cqlsh:testkeyspace1 select * from compositetest where ctime=12345679 and key='key3' and ctime=12345680 limit 3; TSocket read 0 bytes cqlsh:testkeyspace1 NPE when trying to select a slice from a composite table Key: CASSANDRA-4532 URL: https://issues.apache.org/jira/browse/CASSANDRA-4532 Project: Cassandra Issue Type: Bug Components: API, Core Affects Versions: 1.1.3 Environment: Cassandra 1.1.3 (2 nodes) on a single host - mac osx Reporter: basanth gowda Priority: Minor Labels: Slice, cql, cql3 I posted this question on StackOverflow, because i need a solution. Created a table with : {noformat} create table compositetest(m_id ascii,i_id int,l_id ascii,body ascii, PRIMARY KEY(m_id,i_id,l_id)); {noformat} wanted to slice