Question

I have a very strange and simple problem, but I cannot understand what is happening. I have a column family with the following structure:

Comparator: DecimalType Validator: CompositeType(DecimalType, DecimalType, DecimalType, DecimalType) Row key: CompositeType(BytesType, BytesType, IntegerType, IntegerType, IntegerType, DateType, IntegerType, DateType)

I think the problem is the comparator. When I try to insert a new data it doesn't work and I get this message: Error performing batch_mutate on localhost: exception 'TTransportException' with message 'TSocket: timed out reading 4 bytes from localhost:9160'. If I change the comparator to AsciiType it works without problems. What I'm trying to insert in the column name is something like: 2.97. I think it is a real numeric type because it comes from PHP math operations and to ensure it is a number I have done a cast to the final result to convert it to float. It doesn't work with or without casting if the comparator is a DecimalType, but it always work if the comparator is AsciiType. And the most strange thing: it only fails when the number is a small one. For example, it fails for 2.97 but it works for 561.21.

I have the same problem in a counter column family and I assumed I cannot use a DecimalType for the column name of a counter, but why?

Can anyone help me? Am I using a wrong type? I don't think that AsciiType is the right type for this.

Thank you!

Was it helpful?

Solution

How did you create the column family/table? Via cql3 or thrift? If it is not a case of mixing Thrift and CQL3 it should work.

OTHER TIPS

I think I have found what was happening. As you suspected, vivek mishra, the problem is PHPCassa. I had used the DecimalType for values and it didn't give any problem, so I thought that type was defined in PHPCassa. But the problem is that DecimalType is not defined. It is incredible for me but the documentation is clear:

http://thobbs.github.io/phpcassa/api/class-phpcassa.Schema.DataType.html

When it is used for a column value, I guess the process is different and, despite the type doesn't exists, the number is stored. But when it is used in the comparator, for the column name, I guess the actions done by phpcassa to deal with the sort and other things makes the insertion to fail.

Then, if I want to use PHPCassa (and I want because I cannot change now when almost all the project is developed) I guess I must use a different type to store money amounts in the column name.

Thanks for helping me.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top