Product SiteDocumentation Site

3.3. Example Usage

The following mapper and reducer demonstrate WordCount in Python 3:
def mapper(key, value):
  words = key.split()
  for word in words:
    Wmr.emit(word, 1)
def reducer(key, values):
  count = 0
  for value in values:
    count += int(value)
  Wmr.emit(key, count)