MapReduce paging result

Parnell Springmeyer ixmatus at gmail.com
Thu Aug 9 21:20:51 EDT 2012


Your email is slightly confusing - I assume by "paging" you mean "pagination"? I recommend not trying to do pagination in Riak.

I can't help you at all with your custom map/reduce phase code in trend_riak.erl without seeing vm.args, trend_riak.erl, &c...

On Aug 9, 2012, at 7:27 PM, 郎咸武 wrote:

> 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.
> 
> 
> -- 
> 只为成功找方法,不为失败找理由
> 
> 
> 
> -- 
> 只为成功找方法,不为失败找理由
> _______________________________________________
> 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/20120809/3b270b83/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20120809/3b270b83/attachment.asc>


More information about the riak-users mailing list