TimeUUID 与 Cassandra 和 Lazyboy

发布于 2024-09-13 21:21:40 字数 1180 浏览 0 评论 0原文

我尝试插入带有 UUID1 键的列,以便能够按日期对它们进行排序。我总是收到错误“cassandra.ttypes.InvalidRequestException:InvalidRequestException(为什么='UUIDs必须恰好是16字节')”,我不知道为什么。

这是生成此错误的代码:

from lazyboy import *
from lazyboy.key import Key
import uuid

class TestItemKey(Key):
    def __init__(self, key=None):
        Key.__init__(self, 'MXstore', 'TestCF', key)

class TestItem(record.Record):
    def __init__(self, *args, **kwargs):
        record.Record.__init__(self, *args, **kwargs)
        self.key = TestItemKey(uuid.uuid1().bytes)

connection.add_pool('MXstore', ['localhost:9160'])

tmp = {'foo' : 'bar'}
tmps = TestItem(tmp).save()

我做错了什么?我将lazyboy 0.705 与Cassandra 0.6.4 一起使用。 存储配置是:

<Keyspaces>
    <Keyspace Name="MXstore">
        <ColumnFamily Name="TestCF" CompareWith="TimeUUIDType" />

        <ReplicaPlacementStrategy>org.apache.cassandra.locator.RackUnawareStrategy</ReplicaPlacementStrategy>
        <ReplicationFactor>3</ReplicationFactor>
        <EndPointSnitch>org.apache.cassandra.locator.EndPointSnitch</EndPointSnitch>
    </Keyspace>
</Keyspaces>

I try to insert column with UUID1 keys to be able to sort them by date. I always get the error "cassandra.ttypes.InvalidRequestException: InvalidRequestException(why='UUIDs must be exactly 16 bytes')", and I don't know why.

Here is the code generating this error :

from lazyboy import *
from lazyboy.key import Key
import uuid

class TestItemKey(Key):
    def __init__(self, key=None):
        Key.__init__(self, 'MXstore', 'TestCF', key)

class TestItem(record.Record):
    def __init__(self, *args, **kwargs):
        record.Record.__init__(self, *args, **kwargs)
        self.key = TestItemKey(uuid.uuid1().bytes)

connection.add_pool('MXstore', ['localhost:9160'])

tmp = {'foo' : 'bar'}
tmps = TestItem(tmp).save()

What did I do wrong ? I use lazyboy 0.705 with Cassandra 0.6.4.
The storage configuration is :

<Keyspaces>
    <Keyspace Name="MXstore">
        <ColumnFamily Name="TestCF" CompareWith="TimeUUIDType" />

        <ReplicaPlacementStrategy>org.apache.cassandra.locator.RackUnawareStrategy</ReplicaPlacementStrategy>
        <ReplicationFactor>3</ReplicationFactor>
        <EndPointSnitch>org.apache.cassandra.locator.EndPointSnitch</EndPointSnitch>
    </Keyspace>
</Keyspaces>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

隔岸观火 2024-09-20 21:21:40

列名必须是 uuid 版本 1。看起来您的密钥是 uuid 版本 1

The column name must be of uuid version 1. Looks like your key is a uuid version 1

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