2011-12-18 122 views
1

我试图将数据存储到cassandra中,并且按时间排序。使用TimeUUIDType作为关键时遇到问题。PHPCassa - 使用uuid时间戳作为密钥时无法插入

我碰到下面的错误与phpcassa ...

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

调用insert方法时,就会出现此...

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

我创建使用卡桑德拉-CLI具有以下测试表命令

CREATE COLUMN FAMILY users WITH comparator = TimeUUIDType; 

回答

1

comparator适用于列名,而不是行键。如果您希望行键为TimeUUID,则应该设置key_validation_class

你会得到这个异常,因为卡桑德拉期望列名的TimeUUID,但你传递一个普通的字符串。