Daniel -

Nothing detects whether there is a vclock or not. If there isn't one
provided (the value is `null` in Java), then one isn't sent to Riak -
it is not a requirement for a store operation for it to be present. If
an object exists when such a store is performed and allow_multi=true
for the bucket, then a sibling is created.

The .withoutFetch() method was added to the StoreObject as a requested
feature. It is meant for when you are storing an object that was
previously fetched from Riak and want to avoid doing another fetch. If
that previous fetch returned nothing (the key was not found) then the
vector clock will be null.

When talking about deleted keys ... unless you change the default
`delete_mode` in Riak's app.config, you're not usually going to get a
tombstone - they are reaped after 3s.  Unless either you do a fetch
immediately following a delete, you're doing store operations without
vclocks with allow_multi=true for the bucket (which is basically
"doing it wrong") immediately after a delete and a sibling gets
created, or hit a very small window with multiple writers under heavy
load where the read/write cycle interleaves with a delete and a
tombstone sibling gets created.

With that being said, yes, unless you set 'returnDeletedVClock(true)`
they are silently discarded by the Java client and not passed to the
Converter. If that has been set, the default JSONConverter will return
a new instance of whatever POJO is being used (if possible - if
there's not a default constructor it will throw an exception) and then
set a @RiakTombstone annotated boolean field to `true` if one exists.
It detects this by calling the .isDeleted() method of the returned
IRiakObject.

- Roach

On Tue, Mar 12, 2013 at 9:43 AM, Daniel Iwan <iwan.dan...@gmail.com> wrote:
> Brian,
>
> Where I got lost was the fact that I was using custom Converter and I did
> not do anything with vclock passed into fromDomain().
> That was undetected because at the same time I wasn't using withoutFetch,
> which I believe is the only moment where missing @RiakVClock annotation
> can be detected. Normally when JSONConverter is used missing @RiakVClock
> would also be detected.
> Could you confirm?
>
> Few additional, related questions:
> - if I use byte[] or VClock field and use withoutFetch() what is default
> value it should be set to (since it will be extracted via StoreObject)?
> - if I want to avoid overwriting deleted keys, I guess I need to set
> returnDeletedVClock as below,
>      DomainBucketBuilder<Custom> builder = DomainBucket.builder(bucket,
> Custom.class)
>      builder.returnDeletedVClock(true);
>
> and then check isDeleted on sibblings and use ConditionalStoreMutation to
> return false id one of he sibblings has that flag set to true?
> I believe it needs to use VClock of deleted sibbling as well?
>
> Thanks
> Daniel
>
>
>
>> The .withoutFetch() method isn't available when using the DomanBucket.
>>
>> As for the vector clock, when using .withoutFetch() the .execute()
>> method of StoreObject is going to extract the vector clock from the
>> POJO returned from your Mutation by looking for a VectorClock or
>> byte[] field that is annotated with @RiakVClock. It is then passed to
>> the Converter's .fromDomain() method as an argument.  If you are
>> storing an object you previously fetched from Riak, that vector clock
>> and annotation needs to be there.
>>
>> The easiest way to implement that is:
>> 1. Have a VectorClock or byte[] field in your POJO annotated with
>> @RiakVClock
>>
>> 2. When you fetch, in the .toDomain() method of your Converter have
>> the line of code you noted.
>>
>> 3. When you store, the vector clock stored in that field will be
>> passed to the .fromDomain() method of your Converter. Make sure to
>> call the .withVClock(vclock) method of the RiakObjectBuilder or
>> explicitly set it in the IRiakObject being returned.
>>
>> - Roach
>>
>>
>> On Fri, Mar 8, 2013 at 3:31 PM, Daniel Iwan <iwan.dan...@gmail.com> wrote:
>> > Somehow I cannot find a way to avoid pre-fetch during store operation
>> > (Java
>> > client).
>> > I know in StoreObject there is withoutFetch method for that purpose but
>> > I
>> > cannot find corresponding method/property in DomainBucket or
>> > DomainBucketBuilder
>> >
>> > Am I missing something?
>> >
>> > Also on related note when withoutFetch is used I guess I need to provide
>> > annotated RiakVClock field and use something like:
>> >
>> > VClockUtil.setVClock(domainObject, riakObject.getVClock());
>> >
>> > in my Converter. Is that right or is there better way to do it?
>> >
>> >
>> > I'm using Riak Java client 1.1.0
>> >
>> > Thanks
>> > Daniel
>> >
>> > _______________________________________________
>> > riak-users mailing list
>> > riak-users@lists.basho.com
>> > http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>> >
>
>

_______________________________________________
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to