Take the 2-minute tour ×
MathOverflow is a question and answer site for professional mathematicians. It's 100% free, no registration required.

For a while I was thinking that you just need a map to a monoid, and then reduce would do reduction according to monoid's multiplication.

First, this is not exactly how monoids work, and second, this is not exactly how map/reduce works in practice.

Namely, take the ubiquitous "count" example. If there's nothing to count, any map/reduce engine will return an empty dataset, not a neutral element. Bummer.

Besides, in a monoid, an operation is defined for two elements. We can easily extend it to finite sequences, or, due to associativity, to finite ordered sets. But there's no way to extend it to arbitrary "collections" unless we actually have a sigma-algebra.

So, what's the theory? I tried to figure it out, but I could not; and I tried to go google it but found nothing.

share|improve this question
3  
What do you mean by map/reduce? –  Benjamin Steinberg Dec 17 '11 at 23:02
4  
Asking on the stackexchange CS site will work much better than here, where you'll have to explain whatmap/reduce is :) –  Mariano Suárez-Alvarez Dec 17 '11 at 23:18
1  
Even though I have heard of map/reduce several times and even seen some examples, I'd like to see the closest thing the OP knows to a definition of map/reduce. Certainly it won't be an exact definition, since this is what the OP is searching for, but at least it will probably be more formal and less handwaving than what I know about it. –  darij grinberg Dec 17 '11 at 23:24
1  
Lookup monad instead of monoid. –  François G. Dorais Dec 18 '11 at 0:11
    
(reduction need not be associative though...) –  Mariano Suárez-Alvarez Dec 18 '11 at 0:15
add comment

2 Answers

up vote 15 down vote accepted

Yes.

Ok, while that was fun, let's give you a real answer. As François mentionned, the key word is 'Monad'. Basically/roughly your programming language forms a category, with types as the objects, and functions as the arrows. Then 'map' is the action of a functor on arrows, and 'reduce' is an ordered fold, which is (again roughly) the 'bind' of a monad -- see MapReduce as a Monad as a starting point. For the semantics of 'fold', I rather like this paper by Bird and Paterson on (generalized) folds.

share|improve this answer
    
Merci beaucoup Jacques! –  François G. Dorais Dec 18 '11 at 5:31
    
Hmm. the discussion by the first link is about "generalized monad", Haskell style. While it is probably feasible to split the notion into two functors, declaring the second one a monad, I'd stay away from the arbitrariness of programming thinking and hold to a more mathematical interpretation. As to the second paper, monads are not even mentioned there. Instead, as expected, it talks about monoids being used for reduction; and duly so. More, it defines the monoid on Map type that is being used in map/reduce, thus answering my question. –  Vlad Patryshev Feb 20 '12 at 1:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.