It’s a tricky one Timur. CRDTs are based on Join Semi-Lattices, and they have 
the concept of a bottom value. That is what you are seeing. Implicitly all keys 
exist at the bottom value until you operate on them. Since you cannot do a 
compare-and-set operation with a counter anyway (that is you can’t “put counter 
with value 0” at that key), why do you need to distinguish between 0 as bottom 
and 0 as value?

On 20 Aug 2015, at 01:59, Timur Fayruzov <[email protected]> wrote:

> Hello,
> 
> It seems that Riak Datatype API does not allow to distinguish between 
> non-existing keys and default values. For example, if I query for 
> non-existing key as follows:
> 
> val fetchOp = new FetchCounter.Builder(key).build()
> val c = client.execute(fetchOp).getDatatype
> 
> I'll get a counter that holds 0. Now, if I put counter with value 0 at this 
> key and run the query, I get the same result. Is there any way to distinguish 
> between these two different states?
> 
> Note: when working with sets there is a context that I can check. If I fetch 
> a set and the context is null, it means that the set does not exist under 
> this key. This trick does not work for counters though, as they do not 
> maintain context. Is it a valid trick to use though?
> 
> I posted this to StackOverflow a while ago, but no luck: 
> http://stackoverflow.com/questions/31845164/riak-dataypes-default-values-vs-non-existing-keys
> 
> Thanks,
> 
> Timur
> 
> _______________________________________________
> riak-users mailing list
> [email protected]
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com


_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to