NoSQL Distilled: A Brief Guide to the Emerging World of Polyglot Persistence by pramod j. sadalage & martin fowler

NoSQL Distilled: A Brief Guide to the Emerging World of Polyglot Persistence by pramod j. sadalage & martin fowler

Author:pramod j. sadalage & martin fowler [pramod j. sadalage]
Language: eng
Format: epub
Publisher: Addison-Wesley Professional
Published: 2012-08-20T16:00:00+00:00


7.3. Composing Map-Reduce Calculations

The map-reduce approach is a way of thinking about concurrent processing that trades off flexibility in how you structure your computation for a relatively straightforward model for parallelizing the computation over a cluster. Since it’s a tradeoff, there are constraints on what you can do in your calculations. Within a map task, you can only operate on a single aggregate. Within a reduce task, you can only operate on a single key. This means you have to think differently about structuring your programs so they work well within these constraints.

One simple limitation is that you have to structure your calculations around operations that fit in well with the notion of a reduce operation. A good example of this is calculating averages. Let’s consider the kind of orders we’ve been looking at so far; suppose we want to know the average ordered quantity of each product. An important property of averages is that they are not composable—that is, if I take two groups of orders, I can’t combine their averages alone. Instead, I need to take total amount and the count of orders from each group, combine those, and then calculate the average from the combined sum and count (see Figure 7.6).



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.