1
我尝试使用UUID1键插入列以便能够按日期对它们进行排序。我总是得到错误“cassandra.ttypes.InvalidRequestException:InvalidRequestException(为什么='UUID必须是正好16个字节')”,我不知道为什么。TimeUUID与Cassandra和Lazyboy
这里是代码生成此错误:
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()
我做了什么错?我用Cassandra 0.6.4使用lazyboy 0.705。 存储配置:
<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>
什么uuid.uuid1()的'长度bytes'? – 2010-08-10 15:25:08
len(uuid.uuid1()。bytes)= 16,type(uuid.uuid1()。bytes)=。 16字节,正如预期的,我猜。 –
Pierre
2010-08-10 15:28:38