PHPCassa - 使用uuid时间戳作为密钥时无法插入

时间:2011-12-18 12:03:27

标签: php cassandra uuid phpcassa

我正在尝试将数据存储到cassandra中,并按时间排序。无法使用TimeUUIDType作为密钥。

我在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'));

我使用cassandra-cli使用以下命令创建了一个测试表...

CREATE COLUMN FAMILY users WITH comparator = TimeUUIDType;

1 个答案:

答案 0 :(得分:1)

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

您收到此异常是因为Cassandra期望列名称为TimeUUID,但您传递的是普通字符串。

相关问题