You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Shuge Lee <sh...@gmail.com> on 2010/05/05 11:34:52 UTC
UUIDs must be exactly 16 bytes ?
Hi all:
in storage-conf.xml
...
<Keyspace Name="t">
<ColumnFamily CompareWith="UTF8Type" Name="tt" />
<ReplicaPlacementStrategy>org.apache.cassandra.locator.RackUnawareStrategy</ReplicaPlacementStrategy>
<ReplicationFactor>1</ReplicationFactor>
<EndPointSnitch>org.apache.cassandra.locator.EndPointSnitch</EndPointSnitch>
<ColumnFamily Name="tt"
CompareWith="TimeUUIDType" />
</Keyspace>
...
Python code
#!/usr/bin/env python
import uuid
from pprint import pprint as pp
import pycassa
from cassandra.ttypes import ConsistencyLevel
keyspace = 't'
column_family = 'tt'
write_consistency_level = ConsistencyLevel.ONE
cli = pycassa.connect()
cf = pycassa.ColumnFamily(cli, keyspace, column_family)
key = uuid.uuid4().bytes_le
columns = {'subject': 'a'}
cf.insert(key, columns, write_consistency_level)
Traceback
Traceback (most recent call last):
File "/backup/code/luna/t.py", line 19, in <module>
cf.insert(key, columns, write_consistency_level)
File "/usr/lib/python2.6/site-packages/pycassa/columnfamily.py", line 338,
in insert
self._wcl(write_consistency_level))
File "/usr/lib/python2.6/site-packages/pycassa/connection.py", line 135,
in client_call
return getattr(self._client, attr)(*args, **kwargs)
File "/usr/lib/python2.6/site-packages/cassandra/Cassandra.py", line 781,
in batch_mutate
self.recv_batch_mutate()
File "/usr/lib/python2.6/site-packages/cassandra/Cassandra.py", line 804,
in recv_batch_mutate
raise result.ire
cassandra.ttypes.InvalidRequestException: InvalidRequestException(why='UUIDs
must be exactly 16 bytes')
What's going on ?
--
Shuge Lee | Lee Li | 李蠡
Re: UUIDs must be exactly 16 bytes ?
Posted by Jonathan Ellis <jb...@gmail.com>.
to elaborate, your row key is a uuid, but not your column name
On Wed, May 5, 2010 at 4:46 AM, roger schildmeijer
<sc...@gmail.com> wrote:
> "'CompareWith' tells Cassandra how to sort the columns for slicing
> operations". It looks like your column name isn't using the correct type
> (TimeUUIDType).
>
> // Roger Schildmeijer
>
> On Wed, May 5, 2010 at 11:34 AM, Shuge Lee <sh...@gmail.com> wrote:
>>
>> Hi all:
>>
>> in storage-conf.xml
>> ...
>>
>> <Keyspace Name="t">
>> <ColumnFamily CompareWith="UTF8Type" Name="tt" />
>>
>> <ReplicaPlacementStrategy>org.apache.cassandra.locator.RackUnawareStrategy</ReplicaPlacementStrategy>
>> <ReplicationFactor>1</ReplicationFactor>
>>
>> <EndPointSnitch>org.apache.cassandra.locator.EndPointSnitch</EndPointSnitch>
>>
>> <ColumnFamily Name="tt"
>> CompareWith="TimeUUIDType" />
>> </Keyspace>
>> ...
>>
>> Python code
>> #!/usr/bin/env python
>>
>> import uuid
>> from pprint import pprint as pp
>>
>> import pycassa
>> from cassandra.ttypes import ConsistencyLevel
>>
>> keyspace = 't'
>> column_family = 'tt'
>> write_consistency_level = ConsistencyLevel.ONE
>>
>> cli = pycassa.connect()
>> cf = pycassa.ColumnFamily(cli, keyspace, column_family)
>>
>> key = uuid.uuid4().bytes_le
>> columns = {'subject': 'a'}
>> cf.insert(key, columns, write_consistency_level)
>>
>> Traceback
>>
>> Traceback (most recent call last):
>> File "/backup/code/luna/t.py", line 19, in <module>
>> cf.insert(key, columns, write_consistency_level)
>> File "/usr/lib/python2.6/site-packages/pycassa/columnfamily.py", line
>> 338, in insert
>> self._wcl(write_consistency_level))
>> File "/usr/lib/python2.6/site-packages/pycassa/connection.py", line 135,
>> in client_call
>> return getattr(self._client, attr)(*args, **kwargs)
>> File "/usr/lib/python2.6/site-packages/cassandra/Cassandra.py", line
>> 781, in batch_mutate
>> self.recv_batch_mutate()
>> File "/usr/lib/python2.6/site-packages/cassandra/Cassandra.py", line
>> 804, in recv_batch_mutate
>> raise result.ire
>> cassandra.ttypes.InvalidRequestException:
>> InvalidRequestException(why='UUIDs must be exactly 16 bytes')
>>
>>
>> What's going on ?
>>
>>
>> --
>> Shuge Lee | Lee Li | 李蠡
>
>
--
Jonathan Ellis
Project Chair, Apache Cassandra
co-founder of Riptano, the source for professional Cassandra support
http://riptano.com
Re: UUIDs must be exactly 16 bytes ?
Posted by roger schildmeijer <sc...@gmail.com>.
"'CompareWith' tells Cassandra how to sort the *columns* for slicing
operations". It looks like your column name isn't using the correct type
(TimeUUIDType).
// Roger Schildmeijer
On Wed, May 5, 2010 at 11:34 AM, Shuge Lee <sh...@gmail.com> wrote:
> Hi all:
>
> in storage-conf.xml
> ...
>
> <Keyspace Name="t">
> <ColumnFamily CompareWith="UTF8Type" Name="tt" />
>
> <ReplicaPlacementStrategy>org.apache.cassandra.locator.RackUnawareStrategy</ReplicaPlacementStrategy>
> <ReplicationFactor>1</ReplicationFactor>
>
> <EndPointSnitch>org.apache.cassandra.locator.EndPointSnitch</EndPointSnitch>
>
> <ColumnFamily Name="tt"
> CompareWith="TimeUUIDType" />
> </Keyspace>
> ...
>
> Python code
> #!/usr/bin/env python
>
> import uuid
> from pprint import pprint as pp
>
> import pycassa
> from cassandra.ttypes import ConsistencyLevel
>
> keyspace = 't'
> column_family = 'tt'
> write_consistency_level = ConsistencyLevel.ONE
>
> cli = pycassa.connect()
> cf = pycassa.ColumnFamily(cli, keyspace, column_family)
>
> key = uuid.uuid4().bytes_le
> columns = {'subject': 'a'}
> cf.insert(key, columns, write_consistency_level)
>
> Traceback
>
> Traceback (most recent call last):
> File "/backup/code/luna/t.py", line 19, in <module>
> cf.insert(key, columns, write_consistency_level)
> File "/usr/lib/python2.6/site-packages/pycassa/columnfamily.py", line
> 338, in insert
> self._wcl(write_consistency_level))
> File "/usr/lib/python2.6/site-packages/pycassa/connection.py", line 135,
> in client_call
> return getattr(self._client, attr)(*args, **kwargs)
> File "/usr/lib/python2.6/site-packages/cassandra/Cassandra.py", line 781,
> in batch_mutate
> self.recv_batch_mutate()
> File "/usr/lib/python2.6/site-packages/cassandra/Cassandra.py", line 804,
> in recv_batch_mutate
> raise result.ire
> cassandra.ttypes.InvalidRequestException:
> InvalidRequestException(why='UUIDs must be exactly 16 bytes')
>
>
> What's going on ?
>
>
> --
> Shuge Lee | Lee Li | 李蠡
>