MapReduce paging result

郎咸武 langxianzhe at gmail.com
Thu Aug 9 20:27:51 EDT 2012


Who can answer me?  thanks.

2012/8/10 郎咸武 <langxianzhe at gmail.com>

> Hi guys,
>     How to do a paging in MapReduce queries?
>     I try to write some  method in the module(trend_riak.erl, Add  -pa
> /home/jason/work/server/trunk/trend_riak    to vm.args).
>     I thought it will well, but unfortunately it does not work. Becase the
> "Reduce" ,the result is wrong.
>     Is there the other methods? Thanks.
>
>    Cheers Jason
>
> 121 get_reduce_bucket_values(Records, {Start, Max}) ->
> 122     Skip = get_skip_num(Start, Max),
> 123     io:format("get_reduce_bucket_values Records=~p Skip= ~p~n",
> [length(Records), Skip]),
>
> 124     if length(Records) >= Skip  ->
> 125             %%NewList = lists:keysort(#pubsub_item.published, Records),
> 126             F = fun(#pubsub_item{published=Published1, level=Level1},
> 127                     #pubsub_item{published=Published2, level=Level2})
> ->
> 128                     if Level1 > Level2 -> true;
> 129                        Level1 == Level2 ->
> 130                             if  Published1 > Published2 -> true;
> 131                                 true -> false
> 132                             end;
> 133                        true -> false
> 134                     end
> 135                 end,
> 136             NewList = lists:sort(F, Records),
> 137             R = lists:sublist(NewList, Skip, Max),
> 138             io:format("get_reduce_bucket_value R=~p Skip= ~p~n",
> [length(R), skip]),
> 139             R;
> 140        true ->
> 141             []
> 142             %Records
> 143     end.
>
>
> --
> 只为成功找方法,不为失败找理由
>



-- 
只为成功找方法,不为失败找理由
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20120810/8ec9af82/attachment.html>


More information about the riak-users mailing list