Venki, >From what I gather you're trying to specify arguments directly as objects in >the function's argument list? You reference the arg that's passed into the >MapReduce request by declaring a third parameter variable, not by specifying >an object: function(value, keydata, arg) {doSomethingWith(arg)}. Then you can >reference the argument by way of that parameter.
Cheers, Mathias http://riakhandbook.com On Friday, 6. July 2012 at 08:40, Venki Yedidha wrote: > Thanks again, > I changed args to arg. > To keep it simple, I just want to use that arg parameter value > {"gender":"G0,G1"," > agegroups":"A0,A2","metrics":"users,cpc_median","groupby":"country"} inside > my javascript function. > > If I try to assign it to a variable like: > > var k = arg; > > It is giving undefined variable arg. > > On the other hand, > If I am trying to access this variable passing as a third parameter to > function(v,k,{"",""}) > It is also giving me error. > > Please help me on the above. > > Thanks, > Venkatesh > > > On Thu, Jul 5, 2012 at 9:07 PM, Mathias Meyer <me...@paperplanes.de > (mailto:me...@paperplanes.de)> wrote: > > Venki, > > > > The parameter name is arg not args. Also, you were talking about some sort > > of error you're getting, but I couldn't see one in the listing below. > > > > Cheers, Mathias > > http://riakhandbook.com > > > > > > > > > > > > On Thursday, 5. July 2012 at 16:29, Venki Yedidha wrote: > > > > > Thanks, > > > I tried the format you sent me earlier but when I tried to access the > > > args parameter inside the function, it is showing me the error: > > > > > > {"inputs":['.$k.'],"query":[{"map":{"language":"javascript","source":"function(value,keydata,"arguments"){ > > > var data = Riak.mapValuesJson(value)[0]; > > > var obj = {}; > > > obj[value.key] = {}; > > > for(var i=1;i<3;i++) > > > { > > > var gender = \"G\"+ i; > > > obj[value.key][gender] = {}; > > > for(var j=1;j<=6;j++) > > > { > > > var agegroup = \"A\" + j; > > > obj[value.key][gender][agegroup] = {}; > > > obj[value.key][gender][agegroup][\"cpc_median\"] = > > > data[gender][j][agegroup][\"bid_estimations\"][0][\"cpc_median\"]; > > > obj[value.key][gender][agegroup][\"users\"] = > > > data[gender][j][agegroup][\"users\"]; > > > > > > } > > > } > > > return [obj]; > > > }","args":{"gender":"G0,G1","agegroups":"A0,A2","metrics":"users,cpc_median","groupby":"country"},"keep":true}}]}'; > > > > > > Please help me on the above. > > > > > > To clarify my requirement, I would like to access the args parameter > > > (before keep parameter) inside javascript function and if possible I > > > would also like to know the flow that what is the need for args param > > > after js function. > > > > > > Thanks, > > > Venkatesh.Y > > > > > > On Wed, Jul 4, 2012 at 2:11 PM, Mathias Meyer <me...@paperplanes.de > > > (mailto:me...@paperplanes.de) (mailto:me...@paperplanes.de)> wrote: > > > > Venki, > > > > > > > > You don't have to serialize the argument as a JSON string, it can > > > > simply be specified as a normal JSON data structure, just like the > > > > other data in the MapReduce request: > > > > > > > > curl -v -d '{"inputs":[["artists", "Beatles"]], > > > > "query":[{"map":{"language":"javascript","source":"function(v, k, a) > > > > {return [a];}","arg":{"paul": true}}}]}' -H "Content-Type: > > > > application/json" http://127.0.0.1:8098/mapred > > > > > > > > Cheers, Mathias > > > > http://riakhandbook.com > > > > > > > > > > > > > > > > > > > > > > > > On Wednesday, 4. July 2012 at 07:26, Venki Yedidha wrote: > > > > > > > > > Hi all, > > > > > I don't know why, I can't pass a json argument to map function. > > > > > > > > > > > > > > > "inputs":"[b1,k1],[b2,k2],[b3,k3]" > > > > > "query":[{map":{"language":"javascript","source":"function(value,keydata,args){}" > > > > > > > > > > for the args parameter I need to pass json of the form: > > > > > {\"name\":\"venkatesh\",\"age\":24} > > > > > (escaped " for json) > > > > > but it showing missing variable name.. > > > > > On the other, If I am passing an array, it is not showing the error... > > > > > Please help me on the above. > > > > > > > > > > Thanks, > > > > > Venkatesh > > > > > _______________________________________________ > > > > > riak-users mailing list > > > > > riak-users@lists.basho.com (mailto:riak-users@lists.basho.com) > > > > > (mailto:riak-users@lists.basho.com) > > > > > (mailto: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