On Mar 10, 2011, at 8:26 AM, Antonio Rohman Fernandez wrote:

> Dear Sean,
> thank you for your quick reply.
> 
> "Your reduce function can (almost) never assume that it is operating on the 
> entire result set." -> wow! that totally kills my implementation... i wanted 
> to use the Reduce phase to cut the array as a Limit + Pagination ( like LIMIT 
> 10 PAGE 2 in SQL )... but if i don't have the full result set is impossible 
> and useless. I will have to get all the rows and then process it outside Riak 
> for that.
> 

Note I said "(almost)". In the case where the reduce phase is preceded by 
another reduce phase, you can generally assume that it will only be executed 
once. So, pagination is hard to do but not impossible - do a sorting phase 
before your limit/slice.

> "you must structure your reduce function such that it can receive as inputs 
> anything that it outputs" -> what do you mean with that? can i merge Reduce 
> phases? any example?
> 

What that means is any data you return might again become inputs to the same 
function as I described. The properties we say are needed for reduce functions 
are "commutative, associative, and idempotent". Commutative - it can be applied 
in any order and produce the same result. Associative - any grouping of the 
same inputs will produce the same result. Idempotent - given the same inputs, 
you will get the same result every time (i.e. it has no side-effects).

> i'm building a php MVC framework in top of Riak, and i would like to clone 
> from my SQL implementation as much functionality as i can, so people can 
> easily use Riak as if they were using MySQL/PostgreSQL/etc without noticing.
> thanks.

I can understand the desire to provide similar functionality, but Riak is NOT 
an SQL-like system. Having tried some similar things in Ruby, I believe it's ok 
to provide your users a nice interface, but don't delude them about having the 
same querying capabilities -- it's just NOT the same. It's better to craft the 
features in a way that exposes tradeoffs to them rather than hiding them.

Sean Cribbs <s...@basho.com>
Developer Advocate
Basho Technologies, Inc.
http://basho.com/


_______________________________________________
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to