TimeUUID 与 Cassandra 和 Lazyboy
我尝试插入带有 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
列名必须是 uuid 版本 1。看起来您的密钥是 uuid 版本 1
The column name must be of uuid version 1. Looks like your key is a uuid version 1