Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

ReversedType Marshalling Exception #67

ncperng opened this Issue Aug 24, 2012 · 8 comments


None yet
3 participants

ncperng commented Aug 24, 2012

I have a CF and its column type is 'UTF8(reversed=true)'. The schema is as follows
create column family CF
with column_type = 'Standard'
and comparator = 'UTF8Type(reversed=true)'
and default_validation_class = 'UTF8Type'
and key_validation_class = 'UTF8Type';

While I'm using the Helenus cql() function such as 'select * from CF', an exception 'TypeError: Cannot read property 'ser' of undefined' occurs. The error stack is as follows:

throw e;
TypeError: Cannot read property 'ser' of undefined
at getSerializer (/node_modules/helenus/lib/marshal/index.js:179:23)
at new Marshal (/node_modules/helenus/lib/marshal/index.js:223:20)
at new Row (/node_modules/helenus/lib/row.js:15:32)
at onReturn (/node_modules/helenus/lib/connection.js:433:19)
at onReturn (/node_modules/helenus/lib/connection.js:370:7)
at exports.Connection.connection.addListener.self.transport.receiver.client._reqs.(anonymous function) (/node_modules/helenus/node_modules/helenus-thrift/lib/thrift/connection.js:80:11)
at Object.CassandraClient.recv_execute_cql_query (/node_modules/helenus/lib/cassandra/Cassandra.js:6968:12)
at exports.Connection (/Users/neil/Documents/work/java/HinewsNode/node_modules/helenus/node_modules/helenus-thrift/lib/thrift/connection.js:83:37)
at Socket.TFramedTransport.receiver (/node_modules/helenus/node_modules/helenus-thrift/lib/thrift/transport.js:70:9)

at Socket.EventEmitter.emit (events.js:88:17)

I tried to trace the source, and found the problem is the string passed to parseTypeString() in '/lib/marshal/index.js' is only 'ReversedType', instead of 'ReversedType(org.apache.cassandra.db.marshal.UTF8Type)' where I can see it with cassandra-cli. As a result, the parseTypeString() function parsed my type from 'ReversedType' to 'ReversedTyp' due to the condition Line 94 in '/lib/marshal/index.js'.

I could only trace to here and have no idea to go further.

gian788 commented Aug 24, 2012

Probably the bug is in the getInnerType function which returns the comparator type in a form like 'org.apache.cassandra.db.marshal.UTF8Type' and not 'UTF8Type'.

gian788 commented Aug 24, 2012

I have changed getInnerType (index.js file) function to:
function getInnerType(str){
var index = str.indexOf('(');
return index > 0 ? getType(str.substring(index + 1, str.length - 1)) : getType(str);
and it works.

ncperng commented Aug 25, 2012

Dear Gian,

Thanks for the help. However, it didn't work at my side. I think the problem is not the text parsing issue, since the string at my side passed to getInnerType() is 'ReversedType' not the 'ReversedType(org.apache.cassandra.db.marshal.UTF8Type)' as expected.

So that the Marshal object can only get 'ReversedType' and cannot identify it. My question now is why the res.schema at Line 433 in /lib/connection.js didn't pass the full type string? It should be 'ReversedType(org.apache.cassandra.db.marshal.UTF8Type)' instead of 'ReversedType' only.


devdazed commented Aug 25, 2012

What version of C* are you using? and what version of CQL?

ncperng commented Aug 26, 2012

The version of C is: gcc version 4.2.1 (Based on Apple Inc. build 5658).
Cassandra and CQL versions:
Cassandra 1.1.0 (I also tried Cassandra 1.1.3)
CQL spec 2.0.0
Thrift protocol 19.30.0

By the way, I'm working on MacOSX version 10.7.4, and the Nodejs is 0.8.5 binary download from http://www.nodejs.org.

I guess the problem comes from column family schema parsing. Where can I find this part from Helenus source?


devdazed commented Aug 26, 2012

So it seems the CQL query, as you have stated, is returning ReversedType rather than ReversedType(UTF8Type). This poses a problem as the marshaller doesn't know how to deserialize it. I'll put in a result of IDENTITY that should fix this. Expect to see an update soon,

@devdazed devdazed closed this in face5a9 Aug 26, 2012


devdazed commented Aug 26, 2012

This fix is published in npm under version 0.5.7

ncperng commented Aug 27, 2012

It now works fine here. Many thanks for the efforts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment