【问题标题】:PHPCassa - Can't insert when using uuid timestamp as keyPHPCassa - 使用 uuid 时间戳作为键时无法插入
【发布时间】:2011-12-18 12:03:26
【问题描述】:

我正在尝试将数据存储到 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;

【问题讨论】:

    标签: php cassandra uuid phpcassa


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2020-08-17
      • 1970-01-01
      • 2019-02-22
      • 2017-05-31
      • 1970-01-01
      • 1970-01-01
      • 2011-11-21
      • 1970-01-01
      • 2015-02-26
      相关资源
      最近更新 更多