Python: More problems with counters

Eric Redmond eredmond at basho.com
Sun Aug 17 19:51:48 EDT 2014


"Bucket type" is shared metadata across a set of buckets. That metadata needn't necessarily define a datatype. In fact, there are many cases where you might not. For example, you would use a bucket type for strong consistency, or associating a search index with many buckets.

In other words:

bucket type == higher-level bucket namespace (http://docs.basho.com/riak/2.0.0/dev/advanced/bucket-types/)
datatype == a description of how a stored object's type, like a map/set/counter (http://docs.basho.com/riak/2.0.0/dev/using/data-types/)

Hope that helps,
Eric



On Aug 17, 2014, at 11:12 AM, Alex De la rosa <alex.rosa.box at gmail.com> wrote:

> Hi Eric!
> 
> Thank you very much! this certainly solved it! :) however, I have to say that is very non intuitive as "bucket_type" would look like the data type (counter, set, map) and the "bucket" part the name of the bucket you created... so it looks as it should work exactly the contrary as how it has to be done (><).
> 
> However, is finally fixed and I can finally use counters! thank you so much.
> 
> Thanks!
> Alex
> 
> 
> On Sun, Aug 17, 2014 at 8:04 PM, Eric Redmond <eredmond at basho.com> wrote:
> Alex,
> 
> looking through your previous emails, it looked like you created a bucket type named "likes". If that's the case, you'd swap the function params:
> 
> bucket = client.bucket_type('likes').bucket('counter_bucket')
> 
> Hope that helps,
> Eric
> 
> 
> On Aug 17, 2014, at 10:33 AM, Alex De la rosa <alex.rosa.box at gmail.com> wrote:
> 
> > Hi there,
> >
> > I was able to install the latest python client version with "pip install riak==2.1.0rc1", however, counters still fails to work... I used the following code ( that is the same as in the documentation ):
> >
> > bucket = client.bucket_type('counter_bucket').bucket('likes')
> >
> > however I get the following error:
> >
> > Traceback (most recent call last):
> >   File "x.py", line 18, in <module>
> >     counter = bucket.new('Barcelona')
> >   File "/usr/local/lib/python2.7/dist-packages/riak/bucket.py", line 159, in new
> >     if self.bucket_type.datatype:
> >   File "/usr/local/lib/python2.7/dist-packages/riak/util.py", line 78, in __get__
> >     value = self.fget(obj)
> >   File "/usr/local/lib/python2.7/dist-packages/riak/bucket.py", line 618, in datatype
> >     return self.get_properties().get('datatype')
> >   File "/usr/local/lib/python2.7/dist-packages/riak/bucket.py", line 557, in get_properties
> >     return self._client.get_bucket_type_props(self)
> >   File "/usr/local/lib/python2.7/dist-packages/riak/client/transport.py", line 184, in wrapper
> >     return self._with_retries(pool, thunk)
> >   File "/usr/local/lib/python2.7/dist-packages/riak/client/transport.py", line 126, in _with_retries
> >     return fn(transport)
> >   File "/usr/local/lib/python2.7/dist-packages/riak/client/transport.py", line 182, in thunk
> >     return fn(self, transport, *args, **kwargs)
> >   File "/usr/local/lib/python2.7/dist-packages/riak/client/operations.py", line 265, in get_bucket_type_props
> >     return transport.get_bucket_type_props(bucket_type)
> >   File "/usr/local/lib/python2.7/dist-packages/riak/transports/pbc/transport.py", line 381, in get_bucket_type_props
> >     MSG_CODE_GET_BUCKET_RESP)
> >   File "/usr/local/lib/python2.7/dist-packages/riak/transports/pbc/connection.py", line 50, in _request
> >     return self._recv_msg(expect)
> >   File "/usr/local/lib/python2.7/dist-packages/riak/transports/pbc/connection.py", line 142, in _recv_msg
> >     raise RiakError(err.errmsg)
> > riak.RiakError: 'Invalid bucket type: <<"counter_bucket">>'
> >
> > It says the bucket type is wrong (but is the same as in the documentation)... I tried other combinations and all of them failed too:
> >
> > riak.RiakError: 'Invalid bucket type: <<"counters_bucket">>'
> > riak.RiakError: 'Invalid bucket type: <<"counters">>'
> > riak.RiakError: 'Invalid bucket type: <<"counter">>'
> >
> > so... no plural, no singular, not isolated... which is the correct "bucket_type" to use then??
> >
> > Thanks!
> > Alex
> > _______________________________________________
> > riak-users mailing list
> > riak-users at lists.basho.com
> > http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20140817/36bc2e9e/attachment.html>


More information about the riak-users mailing list