Thrift - CQL

2014-03-26 Thread rubbish me
Hi all,
 
We have been using Cassandra for more than 3 years and now we have a cluster in 
production still running on 1.1.x contains dynamic-columned column-families - 
with hector as client. 

We are trying to update to the latest 1.2.x and considering to use datastax 
client in order to utilise some of its round robin / failover goodness.
 
We bumped on to a few walls however when converting our thrift based client 
code to CQL.  We read through the docs + datastax dev blog entires like: this 
and this.  However they are mostly focus on reading from an existing dynamic 
cf, run some alter table statements, and reading it again.
Very little about how to insert / update.
 
So there comes my questions:
-  Is there any way to do insert / update at all on a good old wide cf using 
CQL?   Based on what we read back out, we have tried:

INSERT INTO cf_name(key, column1, value) VALUES (‘key1’, 
‘columnName1’,’columnValue2’)

But we ended up with “Unknown identifier column1”
 
-  About read -  One of our cf is defined with a secondary index.  So the 
schema looks something like:
 
create column family cf_with_index
  with column_type = 'Standard'
  and comparator = 'UTF8Type'
  and default_validation_class = 'UTF8Type'
  and key_validation_class = 'UTF8Type'
  and column_metadata = [
{column_name : 'indexed_column',
validation_class : UTF8Type,
index_name : 'column_idx',
index_type : 0}];
 
When reading from cli, we will see all columns, data as you expected:
--
---
RowKey: rowkey1
= (name=c1, value=v1, timestamp=xxx, ttl=604800)
= (name=c2, value=v2, timestamp=xxx, ttl=604800)
= (name=c3, value=v3, timestamp=xxx, ttl=604800)
= (name=indexed_column, value=value1, timestamp=xxx, ttl=604800)
---
 
However when we Query via CQL, we only get the indexed column:
SELECT * FROM cf_with_index WHERE key = ‘rowkey1’;
 
key   | indexed_column
---+
rowkey1   | value1
 
Any way to get the rest?
 
-  Obtaining TTL and writetime on these wide rows  - we tried:
SELECT key, column1, value, writetime(value), ttl(value) FROM cf LIMIT 1;
It works, but a bit clumsy.  Is there a better way?
 
-  We can live with thrift.  Is there any way / plan to let us to execute 
thrift with datastax driver?  Hector seems not active anymore.
 
Many thanks in advanced,
 
A



Re: Thrift - CQL

2014-03-26 Thread Peter Lin
Hector has round robin and failover. Is there a particular kind of failover
you're looking for?

by default Hector will try another node if the first node it connects to is
down. It's been that way since the 1.x client if I'm not mistaken.


On Wed, Mar 26, 2014 at 9:41 AM, rubbish me rubbish...@googlemail.comwrote:

 Hi all,



 We have been using Cassandra for more than 3 years and now we have a
 cluster in production still running on 1.1.x contains dynamic-columned
 column-families - with hector as client.


 We are trying to update to the latest 1.2.x and considering to use
 datastax client in order to utilise some of its round robin / failover
 goodness.



 We bumped on to a few walls however when converting our thrift based
 client code to CQL.  We read through the docs + datastax dev blog entires
 like: this http://www.datastax.com/dev/blog/thrift-to-cql3 and 
 thishttp://www.datastax.com/dev/blog/cql3-for-cassandra-experts.
 However they are mostly focus on reading from an existing dynamic cf, run
 some alter table statements, and reading it again.

 Very little about how to insert / update.



 So there comes my questions:

 -  *Is there any way to do insert / update at all on a good old wide cf
 using CQL?   Based on what we read back out, we have tried:*


 INSERT INTO cf_name(key, column1, value) VALUES ('key1',
 'columnName1','columnValue2')


 But we ended up with Unknown identifier column1



 -  *About read -  One of our cf is defined with a secondary index.  So
 the schema looks something like:*



 create column family cf_with_index

   with column_type = 'Standard'

   and comparator = 'UTF8Type'

   and default_validation_class = 'UTF8Type'

   and key_validation_class = 'UTF8Type'

   and column_metadata = [

 {column_name : 'indexed_column',

 validation_class : UTF8Type,

 index_name : 'column_idx',

 index_type : 0}];



 When reading from cli, we will see all columns, data as you expected:

 --

 ---

 RowKey: rowkey1

 = (name=c1, value=v1, timestamp=xxx, ttl=604800)

 = (name=c2, value=v2, timestamp=xxx, ttl=604800)

 = (name=c3, value=v3, timestamp=xxx, ttl=604800)

 = (name=indexed_column, value=value1, timestamp=xxx, ttl=604800)

 ---



 However when we Query via CQL, we only get the indexed column:

 SELECT * FROM cf_with_index WHERE key = 'rowkey1';



 key   | indexed_column

 ---+

 rowkey1   | value1



 Any way to get the rest?



 -  *Obtaining TTL and writetime on these wide rows  - we tried:*

 *SELECT key, column1, value, writetime(value), ttl(value) FROM cf LIMIT 1;*

 *It works, but a bit clumsy.  Is there a better way?*



 -  *We can live with thrift.  Is there any way / plan to let us to
 execute thrift with datastax driver?  Hector seems not active anymore.*



 Many thanks in advanced,



 A




Re: Thrift - CQL

2014-03-26 Thread Sylvain Lebresne

 -  *Is there any way to do insert / update at all on a good old wide cf
 using CQL?   Based on what we read back out, we have tried:*


 INSERT INTO cf_name(key, column1, value) VALUES ('key1',
 'columnName1','columnValue2')


 But we ended up with Unknown identifier column1


What does cqlsh give you if you try to do 'DESC cf_name'?





 -  *About read -  One of our cf is defined with a secondary index.  So
 the schema looks something like:*



 create column family cf_with_index

   with column_type = 'Standard'

   and comparator = 'UTF8Type'

   and default_validation_class = 'UTF8Type'

   and key_validation_class = 'UTF8Type'

   and column_metadata = [

 {column_name : 'indexed_column',

 validation_class : UTF8Type,

 index_name : 'column_idx',

 index_type : 0}];



 When reading from cli, we will see all columns, data as you expected:

 --

 ---

 RowKey: rowkey1

 = (name=c1, value=v1, timestamp=xxx, ttl=604800)

 = (name=c2, value=v2, timestamp=xxx, ttl=604800)

 = (name=c3, value=v3, timestamp=xxx, ttl=604800)

 = (name=indexed_column, value=value1, timestamp=xxx, ttl=604800)

 ---



 However when we Query via CQL, we only get the indexed column:

 SELECT * FROM cf_with_index WHERE key = 'rowkey1';



 key   | indexed_column

 ---+

 rowkey1   | value1



 Any way to get the rest?


You would have to declare the other columns (c1, c2 and c3) in the metadata
(you don't have to index them though).





 -  *Obtaining TTL and writetime on these wide rows  - we tried:*

 *SELECT key, column1, value, writetime(value), ttl(value) FROM cf LIMIT 1;*

 *It works, but a bit clumsy.  Is there a better way?*


No, it's the CQL way (not that I particularly agree with the clumsy
qualification, but I suppose we all have different opinion on what is
clumsy and what is not).




 -  *We can live with thrift.  Is there any way / plan to let us to
 execute thrift with datastax driver?*


No (and it's not like it's a minor change to allow that, the DataStax Java
driver uses the native protocol which is CQL only by nature).

--
Sylvain