PHPCassa - 使用 uuid 时间戳作为键时无法插入
我正在尝试将数据存储到 cassandra 中,并按时间排序。使用 TimeUUIDType 作为密钥时遇到问题。
我在 phpcassa 中遇到以下错误...
Fatal error: Uncaught exception 'cassandra_InvalidRequestException'
with message 'TimeUUID should be 16 or 0 bytes (6)'
调用插入方法时会发生这种情况...
$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;
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;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
comparator
适用于列名,而不是行键。如果您希望行键为 TimeUUID,则应设置key_validation_class
。您收到此异常是因为 Cassandra 需要 TimeUUID 作为列名,但您传递的是普通字符串。
comparator
applies to column names, not row keys. If you want the row keys to be TimeUUIDs, you should setkey_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.