Riak Java client questions

Oved Machlev omachlev at interwise.com
Thu Aug 2 13:04:17 EDT 2012


Hi,

I have been working with Riak in past 3 weeks, using the java client.
I have encountered a few issues, and could not find solutions so far.
This is the first time I write an email to this mailing list - Would be great if it reaches the right destination :)


1.       Riak supports auto generated keys when storing an object - http://wiki.basho.com/Basic-Riak-API-Operations.html:

Store a new object and assign random key #

If your application would rather leave key-generation up to Riak, issue a POST request to the bucket URL instead of a PUT to a bucket/key pair: POST /riak/bucket If you don't pass Riak a "key" name after the bucket, it will know to create one for you.

Is it possible to do the same when using the java client? it seems that key must be provided when storing an object.

2.       I have a POJO which I store. It contains a set of objects which I do not wish to persist, I mark it as transient:



transient private Set<Service> services;

but still, this set is being persisted - when I fetch my POJO (curl and java) I can see this:



                {"name":"oved","lastUpdate":"1343923201735","data":null,"services":[]}



Is there something else I need to do to tell Riak to ignore it?



3.       This is more basic question - I keep on thinking that my stored objects should implement the IRIAKObject, but I avoided doing that so far, because in all the examples in the cookbook, it is never being done. So in theoretical level - should the objects that are stored in riak database implement this interface or not? Is there any value in doing that?



4.       MapReduce - If I perform the following without the line in bold (link) I get the collection of ServiceProviders without the Services that are linked.
When adding the LinkPhase, I am getting a JsonMappingException (see below). Any idea what is causing that? What am I missing? Both objects (service and serviceProvider) are stored as JsonObjects.

    public Collection<ServiceProvider> getAllServiceProvider() throws Exception{

        BucketMapReduce m = riakClient.mapReduce("SERVICE_PROVIDER");
        m.addMapPhase(new NamedJSFunction("Riak.mapValuesJson"), true);
        m.addLinkPhase("SERVICE", "_");
        MapReduceResult result = m.execute();
        return result.getResult(ServiceProvider.class);
    }


The exception:
com.basho.riak.client.convert.ConversionException: org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of com.att.cso.omss.datastore.riak.entities.ServiceProvider out of START_ARRAY token
 at [Source: java.io.StringReader at 31958905<mailto:java.io.StringReader at 31958905>; line: 1, column: 2]
    at com.basho.riak.client.raw.http.ConversionUtil$1.getResult(ConversionUtil.java:601)


Sorry for the long email, and thanks in advance...


Thanks,
Oved Machlev
____________________________
Get AT&T Connect for Mobile now!
Android<https://play.google.com/store/apps/details?id=com.att.connect> | iPhone<http://itunes.apple.com/us/app/at-t-connect-mobile/id318798264?mt=8> | iPad<http://itunes.apple.com/il/app/at-t-connect-mobile-application/id459888209?mt=8> | BB<http://downloads.uc.att.com/BB/Public/Latest/En/KB/att_connect.jad>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20120802/123b48b0/attachment.html>


More information about the riak-users mailing list