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

发布于 2024-12-21 22:02:28 字数 622 浏览 3 评论 0原文

我正在尝试将数据存储到 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

滥情哥ㄟ 2024-12-28 22:02:28

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 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文