Question

I'm trying to store data into cassandra with it being ordered by time. Having trouble using the TimeUUIDType as the key.

I get the following error with phpcassa...

Fatal error: Uncaught exception 'cassandra_InvalidRequestException' 
with message 'TimeUUID   should be 16 or 0 bytes (6)'

This occurs when calling the insert method...

$pool = new ConnectionPool("Keyspace1", array("localhost:9160"));
$column_family = new ColumnFamily($pool, 'users');
$column_family->insert(CassandraUtil::uuid1(), array('name' => 'value'));

I created a test table using cassandra-cli with the following command...

CREATE COLUMN FAMILY users WITH comparator = TimeUUIDType;
Was it helpful?

Solution

comparator applies to column names, not row keys. If you want the row keys to be TimeUUIDs, you should set key_validation_class instead.

You're getting this exception because Cassandra is expecting a TimeUUID for the column name, but you're passing a normal string.

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