Hi Deepak,

I can answer one of two questions here...

On Fri, Sep 14, 2012 at 9:42 AM, Deepak Balasubramanyam
<deepak.b...@gmail.com> wrote:
> Thanks for the tip Russell. I managed to get this done.
>
> I have one more question and a suggestion.
>
> Is the name keyData a misnomer in the mapping function ->  function(value,
> keyData, arg)  ? keyData is a String that carries the bucket name. The value
> object carries more information. value[0].data represents the data itself
> among other properties that represent user metadata; riak links; indexes;
> key; etc etc.
> If mapValuesJson: function(value, keyData, arg) can take an input argument
> and use it to add a json property whose value is the riak key, a custom
> function would not be necessary. It would be a neat little system feature
> which I take would need amendments to mapred_builtins.js.
>
> Is riak_kv the repo to make contributions to system built functions ? There
> are quite a few open pull requests on that repo, so I'm not sure where this
> change should go.
>

The riak_kv repo is indeed the repo you want for this. Specifically,
you'll want to start here:

https://github.com/basho/riak_kv/blob/master/priv/mapred_builtins.js

As far as the large queue of pull requests go, we're working on
merging/addressing the backlog (for this and a few other repos). Send
yours our way. It'll get some love when time allows.

Thanks.

Mark


>
> Thanks
> Deepak Bala
>
> On Fri, Sep 14, 2012 at 7:16 PM, Russell Brown <russell.br...@me.com> wrote:
>>
>>
>> On 14 Sep 2012, at 14:24, Deepak Balasubramanyam wrote:
>>
>> > Hi,
>> >
>> > I've written a map reduce query on the riak java client like so...
>> >
>> > client.mapReduce(BUCKET).addKeyFilter(keyFilter)
>> >                     .addLinkPhase(BUCKET, "_", false)
>> >                     .addMapPhase(new
>> > NamedJSFunction("Riak.mapValuesJson"), false)
>> >                     .addReducePhase(phaseFunction).execute();
>> > Collection<MyType> types = result.getResult(MyType.class);
>> >
>> > This is the class definition for MyType
>> >
>> > public class MyType
>> > {
>> >     @RiakKey
>> >     private String myKey;
>> >     private String property1;
>> >     private String property2;
>> >
>> >     /*  Getters / Setters go here */
>> > }
>> >
>> > When the object mapper deserializes the results into Collection<MyType>,
>> > none of the types have the myKey property populated in them. When I 
>> > debugged
>> > the calls made by riak I realized that the result of the /mapred call does
>> > not contain any key information in the body. It only contains the value 
>> > that
>> > each key represents. So that explains why the keys are null in the result.
>>
>> The Java client doesn't add the value of the @RiakKey field to the value
>> stored in riak.
>>
>> >
>> > On the contrary, a link walk in riak returns the Location header for
>> > each multipart form entry in the response (Location: /riak/bucket/key). So 
>> > I
>> > guess there is at least some way to tweak a client to parse the location to
>> > get the keys, but you lose out on the map-reduce goodness.
>> >
>> > Is there some way a map-reduce query can be formed to allow the
>> > resulting type's RiakKey to be populated ? What are my options ?
>>
>> A custom Map function may do what you want. Get the Key from the Key Data
>> passed to the Map function and add it to the JSON value returned. Jackson
>> should then take care of de-serialising it into your values.
>>
>> Cheers
>>
>> Russell
>>
>> >
>> > Thanks
>> > Deepak Bala
>> > _______________________________________________
>> > 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
>

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

Reply via email to