Riak Sort on MapReduce

Daniel Reverri dan at basho.com
Sun Mar 18 14:28:15 EDT 2012


Hi James 

Based on your stackexchange post it looks like the values passed to the reduce function look like [key, data]. This means the sort function would have to access the second element of the array and then access the timestamp. 

return b[1]['timestamp'] - a[1]['timestamp'];

Let us know if that works for you. 

Thanks
Dan

Sent from my iPad

On Mar 17, 2012, at 3:09 PM, James Proud <james.proud at gmail.com> wrote:

> function(values) { 
> 
> 
>     return values.sort(
>         function(a, b) {
> 
> 
>             return b['timestamp'] - a['timestamp'];
> 
> 
>         }
>     );
> }
> I'm currently executing the above code for the reduce phase of a Riak MapReduce query but it is not correctly sorting by the value of timestamp key. Any ideas why?
> 
> Stackoverflow: http://stackoverflow.com/questions/9752931/riak-sort-on-map-reduce
> 
> _______________________________________________
> riak-users mailing list
> riak-users at lists.basho.com
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20120318/6fc3a1b7/attachment.html>


More information about the riak-users mailing list