Unexpected issue w/ m/r Riak.reduceSlice

Jonathan Langevin jlangevin at loomlearning.com
Tue Nov 29 17:21:44 EST 2011

When attempting to run m/r queries that execute Riak.reduceSlice to create
paginated result sets, I've found an unexpected result.

For instance, if I call Riak.reduceSlice with start = 80, end = 85, which
you would expect to return 5 results (knowing that you have a total of 115
objects stored in Riak), you might instead get 16 objects returned back.
This is due to the logic of Riak.reduceSlice, which just returns the
results-thus-far when it finds that the end value (85) is greater than the
current length of value (16 objects).

I suppose ultimately this is due to how Riak sends data in chunks between
phases (at least, that's my understanding)? So it happens to send a small
chunk of 16 results from the map phase to the reduce phase, and reduce
returns back the current "value" chunk since 16 results is less than 85

How can I plan for this, so that I can ensure I'm getting the expected #
results back, and in fair context to the "page" of results that I should be
And just a note, while I tested with & without sorted results, the final
code would be with sorted results that are then paginated.

Example data payload:
            "source":"function(value){return [value.key];}"

 Jonathan Langevin
Manager, Information Technology
Loom Inc.
Wilmington, NC: (910) 241-0433 - jlangevin at loomlearning.com -
www.loomlearning.com - Skype: intel352
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20111129/726a910a/attachment.html>

More information about the riak-users mailing list