Product SiteDocumentation Site

4.2. Iterative

The iterative version of the Scheme library for WebMapReduce is more similar to other languages. For performance reasons, it uses streams, special variants of lists, to expose values to the reducer.
The mapper and reducer must have these signatures:
(mapper key value)
Maps the pair composed of key and value. The return value is ignored—output should be sent through the wmr-emit function.
(reducer key value-stream)
Reduces the values in value-stream associated with the given key.
value-stream has the type stream as defined in SRFI 41. Streams can generally be treated like lists, except they require different primitives: For example, rather than car and cdr, use stream-car and stream-cdr. See the text of SRFI 41 for more functions available to operate on streams.
Both key and the elements of value-stream are strings. As with mapper, the return value is ignored. Use wmr-emit for output.

4.2.1. API

In addition to standard R6RS scheme, SRFIs 1 (lists), 13 (strings), and 41 (streams), and any other modules included by default in MZScheme, WebMapReduce provides the following procedure:
(wmr-emit key value [display-func])
Output a pair composed of key and value. Both arguments can be of any type, and will be converted to strings and output using the procedure display-func.
If display-func is not specified (which is the typical use), display will be used. Its primary purpose is to allow the use of write, which enables values to be easily converted from strings back to their original types.