2010-08-10 41 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

相關問題