2010-08-10 54 views
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> 
+0

什么uuid.uuid1()的'长度bytes'? – 2010-08-10 15:25:08

+0

len(uuid.uuid1()。bytes)= 16,type(uuid.uuid1()。bytes)= 。 16字节,正如预期的,我猜。 – Pierre 2010-08-10 15:28:38

回答

1

列名必须是UUID版本1.看起来像你的关键是一个UUID版本1

+0

非常感谢你:) – Pierre 2010-08-10 23:54:06