sumup all the corresponding values

Venki Yedidha venkatesh.yedidha at gmail.com
Thu Aug 30 03:10:38 EDT 2012


Hi All,

      I have a json generated from the map function like this:


[{"Africa":{"BW":{"female":{"all":109100,"a_13_17":12700,"a_18_24":41640,"a_25_34":34140,"a_35_44":9280,"a_45_54":3040,"a_55_64":1300,"a_65":6960},"male":{"all":131360,"a_13_17":16660,"a_18_24":44780,"a_25_34":39840,"a_35_44":13780,"a_45_54":4120,"a_55_64":1720,"a_65":9600}}}},{"Africa":{"DZ":{"female":{"all":1179820,"a_13_17":290180,"a_18_24":549780,"a_25_34":241080,"a_35_44":56460,"a_45_54":22480,"a_55_64":6420,"a_65":13440},"male":{"all":2522920,"a_13_17":480660,"a_18_24":1020880,"a_25_34":700620,"a_35_44":185820,"a_45_54":73380,"a_55_64":25480,"a_65":36120}}}},{"Africa":{"BF":{"female":{"all":30780,"a_13_17":3700,"a_18_24":11200,"a_25_34":11240,"a_35_44":2800,"a_45_54":920,"a_55_64":380,"a_65":520},"male":{"all":90520,"a_13_17":7680,"a_18_24":27760,"a_25_34":34780,"a_35_44":13320,"a_45_54":4280,"a_55_64":1020,"a_65":1520}}}}]

In reduce function, I need to sum up corresponding values like this:

[Africa][female][all] = [Africa][female][BW][all] +
[Africa][female][DZ][all] +[Africa][female][BF][all]

[Africa][female][a_13_17] = [Africa][female][BW][a_13_17] +
[Africa][female][DZ][a_13_17] +[Africa][female][BF][a_13_17]

like wise...

I cannot use Riak's predefined reduceSum on this type of json...

Please help on the above..

Thanks,
Venkatesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20120830/188ea241/attachment.html>


More information about the riak-users mailing list