0
votes

Previously I asked what the use case for passing a list of keys to CouchDB's reduce function was; the answer (https://stackoverflow.com/a/46713674/3114742) mentions two potential use-cases:

  1. From a design perspective you may want to work with keys emitted by a map function
  2. You may be calculating something based on key input (such as how often a particular key appears)

Do all implementations of MapReduce take an array of keys as input to the reduce functions? CouchDB specifically keeps track of the original document that produces a key. i.e. the input to a CouchDB reduce function:

function(keys, values, rereduce) {...}

The keys arg looks like this: [[key1,id1], [key2,id2], [key3,id3]].

i.e. Couch keeps track of the entity that emitted the key as a result of the Map function, even in the reduce function. Do other MapReduce implementations keep track of this information? Or is this specific to CouchDB...

1

1 Answers

1
votes

Not all mapreduce implementation has the same structure as in couchdb. For example in mongodb mapreduce, there is just a single key and list of values unlike the couch db. So, all the keys that is emitted by map function is grouped and passed as just one key and list of values to reduce function.

Example:

emit(1,10)
emit(1,20)

will be grouped to

reduce(1,[10,20])