7

I'm doing some tests with Cassandra and its Node.JS Driver, Helenus. Is there any way to change the Consistency Level of a query, using CQL?

Helenus documentation only shows an example of doing this using the Helenus Thrift connector, but I want to use the CQL connector.

I tried to query Cassandra like this

conn.cql(cqlRead, vals, {ConsistencyLevel:ANY, gzip:true}, cb);

but node threw this error

ReferenceError: ANY is not defined

Then, I changed 'ANY' to '1' and node ran the code, but I didn't noticed any difference.

Elisiário Couto
  • 139
  • 1
  • 12

2 Answers2

3

The problem is you can't use CL.ANY for reads, only for writes. ANY means count a commit log write as success, even if none of the replicas are available. Since commit logs aren't readable by queries it doesn't make sense to use CL.ANY for reads so Cassandra won't let you.

Richard
  • 11,050
  • 2
  • 46
  • 33
  • 1
    That's correct. I saw the Cassandra Documentation and it's not possible to read using Consistency Level set to ANY. But, besides this, Helenus CQL connector doesn't use the 'ConsistencyLevel' JSON option key. If I want to modify the ConsistencyLevel query option, I should modify the query string, and not the options object. My cqlRead var is "SELECT * FROM DUMMY" and I should use "SELECT * FROM DUMMY USING CONSISTENCY ALL" instead. Thanks for the help! – Elisiário Couto Mar 22 '13 at 15:05
1

I have seen the Helenus documentation and they set the consistency that way

cf.get('foo', {consistency:helenus.ConsistencyLevel.ONE}, function(err, row){
     // Your code here
})

Have you tried with consistency:helenus.ConsistencyLevel.ANY. I think that you probably get another different than ReferenceError

Luis González
  • 3,199
  • 26
  • 43