1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
---|
2 | <!--NewPage--> |
---|
3 | <HTML> |
---|
4 | <HEAD> |
---|
5 | <!-- Generated by javadoc (build 1.6.0_07) on Tue Sep 01 20:56:56 UTC 2009 --> |
---|
6 | <TITLE> |
---|
7 | Reducer (Hadoop 0.20.1 API) |
---|
8 | </TITLE> |
---|
9 | |
---|
10 | <META NAME="date" CONTENT="2009-09-01"> |
---|
11 | |
---|
12 | <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style"> |
---|
13 | |
---|
14 | <SCRIPT type="text/javascript"> |
---|
15 | function windowTitle() |
---|
16 | { |
---|
17 | if (location.href.indexOf('is-external=true') == -1) { |
---|
18 | parent.document.title="Reducer (Hadoop 0.20.1 API)"; |
---|
19 | } |
---|
20 | } |
---|
21 | </SCRIPT> |
---|
22 | <NOSCRIPT> |
---|
23 | </NOSCRIPT> |
---|
24 | |
---|
25 | </HEAD> |
---|
26 | |
---|
27 | <BODY BGCOLOR="white" onload="windowTitle();"> |
---|
28 | <HR> |
---|
29 | |
---|
30 | |
---|
31 | <!-- ========= START OF TOP NAVBAR ======= --> |
---|
32 | <A NAME="navbar_top"><!-- --></A> |
---|
33 | <A HREF="#skip-navbar_top" title="Skip navigation links"></A> |
---|
34 | <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> |
---|
35 | <TR> |
---|
36 | <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> |
---|
37 | <A NAME="navbar_top_firstrow"><!-- --></A> |
---|
38 | <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> |
---|
39 | <TR ALIGN="center" VALIGN="top"> |
---|
40 | <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> |
---|
41 | <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> |
---|
42 | <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> |
---|
43 | <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Reducer.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> |
---|
44 | <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> |
---|
45 | <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> |
---|
46 | <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> |
---|
47 | <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> |
---|
48 | </TR> |
---|
49 | </TABLE> |
---|
50 | </TD> |
---|
51 | <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> |
---|
52 | </EM> |
---|
53 | </TD> |
---|
54 | </TR> |
---|
55 | |
---|
56 | <TR> |
---|
57 | <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> |
---|
58 | <A HREF="../../../../org/apache/hadoop/mapred/RecordWriter.html" title="interface in org.apache.hadoop.mapred"><B>PREV CLASS</B></A> |
---|
59 | <A HREF="../../../../org/apache/hadoop/mapred/Reporter.html" title="interface in org.apache.hadoop.mapred"><B>NEXT CLASS</B></A></FONT></TD> |
---|
60 | <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> |
---|
61 | <A HREF="../../../../index.html?org/apache/hadoop/mapred/Reducer.html" target="_top"><B>FRAMES</B></A> |
---|
62 | <A HREF="Reducer.html" target="_top"><B>NO FRAMES</B></A> |
---|
63 | <SCRIPT type="text/javascript"> |
---|
64 | <!-- |
---|
65 | if(window==top) { |
---|
66 | document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>'); |
---|
67 | } |
---|
68 | //--> |
---|
69 | </SCRIPT> |
---|
70 | <NOSCRIPT> |
---|
71 | <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A> |
---|
72 | </NOSCRIPT> |
---|
73 | |
---|
74 | |
---|
75 | </FONT></TD> |
---|
76 | </TR> |
---|
77 | <TR> |
---|
78 | <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> |
---|
79 | SUMMARY: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> |
---|
80 | <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> |
---|
81 | DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD> |
---|
82 | </TR> |
---|
83 | </TABLE> |
---|
84 | <A NAME="skip-navbar_top"></A> |
---|
85 | <!-- ========= END OF TOP NAVBAR ========= --> |
---|
86 | |
---|
87 | <HR> |
---|
88 | <!-- ======== START OF CLASS DATA ======== --> |
---|
89 | <H2> |
---|
90 | <FONT SIZE="-1"> |
---|
91 | org.apache.hadoop.mapred</FONT> |
---|
92 | <BR> |
---|
93 | Interface Reducer<K2,V2,K3,V3></H2> |
---|
94 | <DL> |
---|
95 | <DT><B>All Superinterfaces:</B> <DD><A HREF="http://java.sun.com/javase/6/docs/api/java/io/Closeable.html?is-external=true" title="class or interface in java.io">Closeable</A>, <A HREF="../../../../org/apache/hadoop/mapred/JobConfigurable.html" title="interface in org.apache.hadoop.mapred">JobConfigurable</A></DD> |
---|
96 | </DL> |
---|
97 | <DL> |
---|
98 | <DT><B>All Known Implementing Classes:</B> <DD><A HREF="../../../../org/apache/hadoop/mapred/lib/ChainReducer.html" title="class in org.apache.hadoop.mapred.lib">ChainReducer</A>, <A HREF="../../../../org/apache/hadoop/contrib/utils/join/DataJoinMapperBase.html" title="class in org.apache.hadoop.contrib.utils.join">DataJoinMapperBase</A>, <A HREF="../../../../org/apache/hadoop/contrib/utils/join/DataJoinReducerBase.html" title="class in org.apache.hadoop.contrib.utils.join">DataJoinReducerBase</A>, <A HREF="../../../../org/apache/hadoop/mapred/lib/FieldSelectionMapReduce.html" title="class in org.apache.hadoop.mapred.lib">FieldSelectionMapReduce</A>, <A HREF="../../../../org/apache/hadoop/mapred/lib/IdentityReducer.html" title="class in org.apache.hadoop.mapred.lib">IdentityReducer</A>, <A HREF="../../../../org/apache/hadoop/contrib/index/mapred/IndexUpdateCombiner.html" title="class in org.apache.hadoop.contrib.index.mapred">IndexUpdateCombiner</A>, <A HREF="../../../../org/apache/hadoop/contrib/index/mapred/IndexUpdateReducer.html" title="class in org.apache.hadoop.contrib.index.mapred">IndexUpdateReducer</A>, <A HREF="../../../../org/apache/hadoop/contrib/utils/join/JobBase.html" title="class in org.apache.hadoop.contrib.utils.join">JobBase</A>, <A HREF="../../../../org/apache/hadoop/mapred/lib/LongSumReducer.html" title="class in org.apache.hadoop.mapred.lib">LongSumReducer</A>, <A HREF="../../../../org/apache/hadoop/examples/PiEstimator.PiReducer.html" title="class in org.apache.hadoop.examples">PiEstimator.PiReducer</A>, <A HREF="../../../../org/apache/hadoop/streaming/PipeReducer.html" title="class in org.apache.hadoop.streaming">PipeReducer</A>, <A HREF="../../../../org/apache/hadoop/examples/SleepJob.html" title="class in org.apache.hadoop.examples">SleepJob</A>, <A HREF="../../../../org/apache/hadoop/mapred/lib/aggregate/ValueAggregatorCombiner.html" title="class in org.apache.hadoop.mapred.lib.aggregate">ValueAggregatorCombiner</A>, <A HREF="../../../../org/apache/hadoop/mapred/lib/aggregate/ValueAggregatorJobBase.html" title="class in org.apache.hadoop.mapred.lib.aggregate">ValueAggregatorJobBase</A>, <A HREF="../../../../org/apache/hadoop/mapred/lib/aggregate/ValueAggregatorMapper.html" title="class in org.apache.hadoop.mapred.lib.aggregate">ValueAggregatorMapper</A>, <A HREF="../../../../org/apache/hadoop/mapred/lib/aggregate/ValueAggregatorReducer.html" title="class in org.apache.hadoop.mapred.lib.aggregate">ValueAggregatorReducer</A></DD> |
---|
99 | </DL> |
---|
100 | <HR> |
---|
101 | <B>Deprecated.</B> <I>Use <A HREF="../../../../org/apache/hadoop/mapreduce/Reducer.html" title="class in org.apache.hadoop.mapreduce"><CODE>Reducer</CODE></A> instead.</I> |
---|
102 | <P> |
---|
103 | <DL> |
---|
104 | <DT><PRE><FONT SIZE="-1"><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Deprecated.html?is-external=true" title="class or interface in java.lang">@Deprecated</A> |
---|
105 | </FONT>public interface <B>Reducer<K2,V2,K3,V3></B><DT>extends <A HREF="../../../../org/apache/hadoop/mapred/JobConfigurable.html" title="interface in org.apache.hadoop.mapred">JobConfigurable</A>, <A HREF="../../../../org/apache/hadoop/io/Closeable.html" title="interface in org.apache.hadoop.io">Closeable</A></DL> |
---|
106 | </PRE> |
---|
107 | |
---|
108 | <P> |
---|
109 | Reduces a set of intermediate values which share a key to a smaller set of |
---|
110 | values. |
---|
111 | |
---|
112 | <p>The number of <code>Reducer</code>s for the job is set by the user via |
---|
113 | <A HREF="../../../../org/apache/hadoop/mapred/JobConf.html#setNumReduceTasks(int)"><CODE>JobConf.setNumReduceTasks(int)</CODE></A>. <code>Reducer</code> implementations |
---|
114 | can access the <A HREF="../../../../org/apache/hadoop/mapred/JobConf.html" title="class in org.apache.hadoop.mapred"><CODE>JobConf</CODE></A> for the job via the |
---|
115 | <A HREF="../../../../org/apache/hadoop/mapred/JobConfigurable.html#configure(org.apache.hadoop.mapred.JobConf)"><CODE>JobConfigurable.configure(JobConf)</CODE></A> method and initialize themselves. |
---|
116 | Similarly they can use the <A HREF="http://java.sun.com/javase/6/docs/api/java/io/Closeable.html?is-external=true#close()" title="class or interface in java.io"><CODE>Closeable.close()</CODE></A> method for |
---|
117 | de-initialization.</p> |
---|
118 | |
---|
119 | <p><code>Reducer</code> has 3 primary phases:</p> |
---|
120 | <ol> |
---|
121 | <li> |
---|
122 | |
---|
123 | <h4 id="Shuffle">Shuffle</h4> |
---|
124 | |
---|
125 | <p><code>Reducer</code> is input the grouped output of a <A HREF="../../../../org/apache/hadoop/mapred/Mapper.html" title="interface in org.apache.hadoop.mapred"><CODE>Mapper</CODE></A>. |
---|
126 | In the phase the framework, for each <code>Reducer</code>, fetches the |
---|
127 | relevant partition of the output of all the <code>Mapper</code>s, via HTTP. |
---|
128 | </p> |
---|
129 | </li> |
---|
130 | |
---|
131 | <li> |
---|
132 | <h4 id="Sort">Sort</h4> |
---|
133 | |
---|
134 | <p>The framework groups <code>Reducer</code> inputs by <code>key</code>s |
---|
135 | (since different <code>Mapper</code>s may have output the same key) in this |
---|
136 | stage.</p> |
---|
137 | |
---|
138 | <p>The shuffle and sort phases occur simultaneously i.e. while outputs are |
---|
139 | being fetched they are merged.</p> |
---|
140 | |
---|
141 | <h5 id="SecondarySort">SecondarySort</h5> |
---|
142 | |
---|
143 | <p>If equivalence rules for keys while grouping the intermediates are |
---|
144 | different from those for grouping keys before reduction, then one may |
---|
145 | specify a <code>Comparator</code> via |
---|
146 | <A HREF="../../../../org/apache/hadoop/mapred/JobConf.html#setOutputValueGroupingComparator(java.lang.Class)"><CODE>JobConf.setOutputValueGroupingComparator(Class)</CODE></A>.Since |
---|
147 | <A HREF="../../../../org/apache/hadoop/mapred/JobConf.html#setOutputKeyComparatorClass(java.lang.Class)"><CODE>JobConf.setOutputKeyComparatorClass(Class)</CODE></A> can be used to |
---|
148 | control how intermediate keys are grouped, these can be used in conjunction |
---|
149 | to simulate <i>secondary sort on values</i>.</p> |
---|
150 | |
---|
151 | |
---|
152 | For example, say that you want to find duplicate web pages and tag them |
---|
153 | all with the url of the "best" known example. You would set up the job |
---|
154 | like: |
---|
155 | <ul> |
---|
156 | <li>Map Input Key: url</li> |
---|
157 | <li>Map Input Value: document</li> |
---|
158 | <li>Map Output Key: document checksum, url pagerank</li> |
---|
159 | <li>Map Output Value: url</li> |
---|
160 | <li>Partitioner: by checksum</li> |
---|
161 | <li>OutputKeyComparator: by checksum and then decreasing pagerank</li> |
---|
162 | <li>OutputValueGroupingComparator: by checksum</li> |
---|
163 | </ul> |
---|
164 | </li> |
---|
165 | |
---|
166 | <li> |
---|
167 | <h4 id="Reduce">Reduce</h4> |
---|
168 | |
---|
169 | <p>In this phase the |
---|
170 | <A HREF="../../../../org/apache/hadoop/mapred/Reducer.html#reduce(K2, java.util.Iterator, org.apache.hadoop.mapred.OutputCollector, org.apache.hadoop.mapred.Reporter)"><CODE>reduce(Object, Iterator, OutputCollector, Reporter)</CODE></A> |
---|
171 | method is called for each <code><key, (list of values)></code> pair in |
---|
172 | the grouped inputs.</p> |
---|
173 | <p>The output of the reduce task is typically written to the |
---|
174 | <A HREF="../../../../org/apache/hadoop/fs/FileSystem.html" title="class in org.apache.hadoop.fs"><CODE>FileSystem</CODE></A> via |
---|
175 | <A HREF="../../../../org/apache/hadoop/mapred/OutputCollector.html#collect(K, V)"><CODE>OutputCollector.collect(Object, Object)</CODE></A>.</p> |
---|
176 | </li> |
---|
177 | </ol> |
---|
178 | |
---|
179 | <p>The output of the <code>Reducer</code> is <b>not re-sorted</b>.</p> |
---|
180 | |
---|
181 | <p>Example:</p> |
---|
182 | <p><blockquote><pre> |
---|
183 | public class MyReducer<K extends WritableComparable, V extends Writable> |
---|
184 | extends MapReduceBase implements Reducer<K, V, K, V> { |
---|
185 | |
---|
186 | static enum MyCounters { NUM_RECORDS } |
---|
187 | |
---|
188 | private String reduceTaskId; |
---|
189 | private int noKeys = 0; |
---|
190 | |
---|
191 | public void configure(JobConf job) { |
---|
192 | reduceTaskId = job.get("mapred.task.id"); |
---|
193 | } |
---|
194 | |
---|
195 | public void reduce(K key, Iterator<V> values, |
---|
196 | OutputCollector<K, V> output, |
---|
197 | Reporter reporter) |
---|
198 | throws IOException { |
---|
199 | |
---|
200 | // Process |
---|
201 | int noValues = 0; |
---|
202 | while (values.hasNext()) { |
---|
203 | V value = values.next(); |
---|
204 | |
---|
205 | // Increment the no. of values for this key |
---|
206 | ++noValues; |
---|
207 | |
---|
208 | // Process the <key, value> pair (assume this takes a while) |
---|
209 | // ... |
---|
210 | // ... |
---|
211 | |
---|
212 | // Let the framework know that we are alive, and kicking! |
---|
213 | if ((noValues%10) == 0) { |
---|
214 | reporter.progress(); |
---|
215 | } |
---|
216 | |
---|
217 | // Process some more |
---|
218 | // ... |
---|
219 | // ... |
---|
220 | |
---|
221 | // Output the <key, value> |
---|
222 | output.collect(key, value); |
---|
223 | } |
---|
224 | |
---|
225 | // Increment the no. of <key, list of values> pairs processed |
---|
226 | ++noKeys; |
---|
227 | |
---|
228 | // Increment counters |
---|
229 | reporter.incrCounter(NUM_RECORDS, 1); |
---|
230 | |
---|
231 | // Every 100 keys update application-level status |
---|
232 | if ((noKeys%100) == 0) { |
---|
233 | reporter.setStatus(reduceTaskId + " processed " + noKeys); |
---|
234 | } |
---|
235 | } |
---|
236 | } |
---|
237 | </pre></blockquote></p> |
---|
238 | <P> |
---|
239 | |
---|
240 | <P> |
---|
241 | <DL> |
---|
242 | <DT><B>See Also:</B><DD><A HREF="../../../../org/apache/hadoop/mapred/Mapper.html" title="interface in org.apache.hadoop.mapred"><CODE>Mapper</CODE></A>, |
---|
243 | <A HREF="../../../../org/apache/hadoop/mapred/Partitioner.html" title="interface in org.apache.hadoop.mapred"><CODE>Partitioner</CODE></A>, |
---|
244 | <A HREF="../../../../org/apache/hadoop/mapred/Reporter.html" title="interface in org.apache.hadoop.mapred"><CODE>Reporter</CODE></A>, |
---|
245 | <A HREF="../../../../org/apache/hadoop/mapred/MapReduceBase.html" title="class in org.apache.hadoop.mapred"><CODE>MapReduceBase</CODE></A></DL> |
---|
246 | <HR> |
---|
247 | |
---|
248 | <P> |
---|
249 | |
---|
250 | <!-- ========== METHOD SUMMARY =========== --> |
---|
251 | |
---|
252 | <A NAME="method_summary"><!-- --></A> |
---|
253 | <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> |
---|
254 | <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> |
---|
255 | <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> |
---|
256 | <B>Method Summary</B></FONT></TH> |
---|
257 | </TR> |
---|
258 | <TR BGCOLOR="white" CLASS="TableRowColor"> |
---|
259 | <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> |
---|
260 | <CODE> void</CODE></FONT></TD> |
---|
261 | <TD><CODE><B><A HREF="../../../../org/apache/hadoop/mapred/Reducer.html#reduce(K2, java.util.Iterator, org.apache.hadoop.mapred.OutputCollector, org.apache.hadoop.mapred.Reporter)">reduce</A></B>(<A HREF="../../../../org/apache/hadoop/mapred/Reducer.html" title="type parameter in Reducer">K2</A> key, |
---|
262 | <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Iterator.html?is-external=true" title="class or interface in java.util">Iterator</A><<A HREF="../../../../org/apache/hadoop/mapred/Reducer.html" title="type parameter in Reducer">V2</A>> values, |
---|
263 | <A HREF="../../../../org/apache/hadoop/mapred/OutputCollector.html" title="interface in org.apache.hadoop.mapred">OutputCollector</A><<A HREF="../../../../org/apache/hadoop/mapred/Reducer.html" title="type parameter in Reducer">K3</A>,<A HREF="../../../../org/apache/hadoop/mapred/Reducer.html" title="type parameter in Reducer">V3</A>> output, |
---|
264 | <A HREF="../../../../org/apache/hadoop/mapred/Reporter.html" title="interface in org.apache.hadoop.mapred">Reporter</A> reporter)</CODE> |
---|
265 | |
---|
266 | <BR> |
---|
267 | <B>Deprecated.</B> <i>Reduces</i> values for a given key.</TD> |
---|
268 | </TR> |
---|
269 | </TABLE> |
---|
270 | <A NAME="methods_inherited_from_class_org.apache.hadoop.mapred.JobConfigurable"><!-- --></A> |
---|
271 | <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> |
---|
272 | <TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"> |
---|
273 | <TH ALIGN="left"><B>Methods inherited from interface org.apache.hadoop.mapred.<A HREF="../../../../org/apache/hadoop/mapred/JobConfigurable.html" title="interface in org.apache.hadoop.mapred">JobConfigurable</A></B></TH> |
---|
274 | </TR> |
---|
275 | <TR BGCOLOR="white" CLASS="TableRowColor"> |
---|
276 | <TD><CODE><A HREF="../../../../org/apache/hadoop/mapred/JobConfigurable.html#configure(org.apache.hadoop.mapred.JobConf)">configure</A></CODE></TD> |
---|
277 | </TR> |
---|
278 | </TABLE> |
---|
279 | <A NAME="methods_inherited_from_class_java.io.Closeable"><!-- --></A> |
---|
280 | <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> |
---|
281 | <TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"> |
---|
282 | <TH ALIGN="left"><B>Methods inherited from interface java.io.<A HREF="http://java.sun.com/javase/6/docs/api/java/io/Closeable.html?is-external=true" title="class or interface in java.io">Closeable</A></B></TH> |
---|
283 | </TR> |
---|
284 | <TR BGCOLOR="white" CLASS="TableRowColor"> |
---|
285 | <TD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/io/Closeable.html?is-external=true#close()" title="class or interface in java.io">close</A></CODE></TD> |
---|
286 | </TR> |
---|
287 | </TABLE> |
---|
288 | |
---|
289 | <P> |
---|
290 | |
---|
291 | <!-- ============ METHOD DETAIL ========== --> |
---|
292 | |
---|
293 | <A NAME="method_detail"><!-- --></A> |
---|
294 | <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> |
---|
295 | <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> |
---|
296 | <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> |
---|
297 | <B>Method Detail</B></FONT></TH> |
---|
298 | </TR> |
---|
299 | </TABLE> |
---|
300 | |
---|
301 | <A NAME="reduce(java.lang.Object,java.util.Iterator,org.apache.hadoop.mapred.OutputCollector,org.apache.hadoop.mapred.Reporter)"><!-- --></A><A NAME="reduce(K2, java.util.Iterator, org.apache.hadoop.mapred.OutputCollector, org.apache.hadoop.mapred.Reporter)"><!-- --></A><H3> |
---|
302 | reduce</H3> |
---|
303 | <PRE> |
---|
304 | void <B>reduce</B>(<A HREF="../../../../org/apache/hadoop/mapred/Reducer.html" title="type parameter in Reducer">K2</A> key, |
---|
305 | <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Iterator.html?is-external=true" title="class or interface in java.util">Iterator</A><<A HREF="../../../../org/apache/hadoop/mapred/Reducer.html" title="type parameter in Reducer">V2</A>> values, |
---|
306 | <A HREF="../../../../org/apache/hadoop/mapred/OutputCollector.html" title="interface in org.apache.hadoop.mapred">OutputCollector</A><<A HREF="../../../../org/apache/hadoop/mapred/Reducer.html" title="type parameter in Reducer">K3</A>,<A HREF="../../../../org/apache/hadoop/mapred/Reducer.html" title="type parameter in Reducer">V3</A>> output, |
---|
307 | <A HREF="../../../../org/apache/hadoop/mapred/Reporter.html" title="interface in org.apache.hadoop.mapred">Reporter</A> reporter) |
---|
308 | throws <A HREF="http://java.sun.com/javase/6/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></PRE> |
---|
309 | <DL> |
---|
310 | <DD><B>Deprecated.</B> <DD><i>Reduces</i> values for a given key. |
---|
311 | |
---|
312 | <p>The framework calls this method for each |
---|
313 | <code><key, (list of values)></code> pair in the grouped inputs. |
---|
314 | Output values must be of the same type as input values. Input keys must |
---|
315 | not be altered. The framework will <b>reuse</b> the key and value objects |
---|
316 | that are passed into the reduce, therefore the application should clone |
---|
317 | the objects they want to keep a copy of. In many cases, all values are |
---|
318 | combined into zero or one value. |
---|
319 | </p> |
---|
320 | |
---|
321 | <p>Output pairs are collected with calls to |
---|
322 | <A HREF="../../../../org/apache/hadoop/mapred/OutputCollector.html#collect(K, V)"><CODE>OutputCollector.collect(Object,Object)</CODE></A>.</p> |
---|
323 | |
---|
324 | <p>Applications can use the <A HREF="../../../../org/apache/hadoop/mapred/Reporter.html" title="interface in org.apache.hadoop.mapred"><CODE>Reporter</CODE></A> provided to report progress |
---|
325 | or just indicate that they are alive. In scenarios where the application |
---|
326 | takes an insignificant amount of time to process individual key/value |
---|
327 | pairs, this is crucial since the framework might assume that the task has |
---|
328 | timed-out and kill that task. The other way of avoiding this is to set |
---|
329 | <a href="../../../../../mapred-default.html#mapred.task.timeout"> |
---|
330 | mapred.task.timeout</a> to a high-enough value (or even zero for no |
---|
331 | time-outs).</p> |
---|
332 | <P> |
---|
333 | <DD><DL> |
---|
334 | </DL> |
---|
335 | </DD> |
---|
336 | <DD><DL> |
---|
337 | <DT><B>Parameters:</B><DD><CODE>key</CODE> - the key.<DD><CODE>values</CODE> - the list of values to reduce.<DD><CODE>output</CODE> - to collect keys and combined values.<DD><CODE>reporter</CODE> - facility to report progress. |
---|
338 | <DT><B>Throws:</B> |
---|
339 | <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></CODE></DL> |
---|
340 | </DD> |
---|
341 | </DL> |
---|
342 | <!-- ========= END OF CLASS DATA ========= --> |
---|
343 | <HR> |
---|
344 | |
---|
345 | |
---|
346 | <!-- ======= START OF BOTTOM NAVBAR ====== --> |
---|
347 | <A NAME="navbar_bottom"><!-- --></A> |
---|
348 | <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> |
---|
349 | <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> |
---|
350 | <TR> |
---|
351 | <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> |
---|
352 | <A NAME="navbar_bottom_firstrow"><!-- --></A> |
---|
353 | <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> |
---|
354 | <TR ALIGN="center" VALIGN="top"> |
---|
355 | <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> |
---|
356 | <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> |
---|
357 | <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> |
---|
358 | <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Reducer.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> |
---|
359 | <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> |
---|
360 | <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> |
---|
361 | <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> |
---|
362 | <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> |
---|
363 | </TR> |
---|
364 | </TABLE> |
---|
365 | </TD> |
---|
366 | <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> |
---|
367 | </EM> |
---|
368 | </TD> |
---|
369 | </TR> |
---|
370 | |
---|
371 | <TR> |
---|
372 | <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> |
---|
373 | <A HREF="../../../../org/apache/hadoop/mapred/RecordWriter.html" title="interface in org.apache.hadoop.mapred"><B>PREV CLASS</B></A> |
---|
374 | <A HREF="../../../../org/apache/hadoop/mapred/Reporter.html" title="interface in org.apache.hadoop.mapred"><B>NEXT CLASS</B></A></FONT></TD> |
---|
375 | <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> |
---|
376 | <A HREF="../../../../index.html?org/apache/hadoop/mapred/Reducer.html" target="_top"><B>FRAMES</B></A> |
---|
377 | <A HREF="Reducer.html" target="_top"><B>NO FRAMES</B></A> |
---|
378 | <SCRIPT type="text/javascript"> |
---|
379 | <!-- |
---|
380 | if(window==top) { |
---|
381 | document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>'); |
---|
382 | } |
---|
383 | //--> |
---|
384 | </SCRIPT> |
---|
385 | <NOSCRIPT> |
---|
386 | <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A> |
---|
387 | </NOSCRIPT> |
---|
388 | |
---|
389 | |
---|
390 | </FONT></TD> |
---|
391 | </TR> |
---|
392 | <TR> |
---|
393 | <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> |
---|
394 | SUMMARY: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> |
---|
395 | <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> |
---|
396 | DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD> |
---|
397 | </TR> |
---|
398 | </TABLE> |
---|
399 | <A NAME="skip-navbar_bottom"></A> |
---|
400 | <!-- ======== END OF BOTTOM NAVBAR ======= --> |
---|
401 | |
---|
402 | <HR> |
---|
403 | Copyright © 2009 The Apache Software Foundation |
---|
404 | </BODY> |
---|
405 | </HTML> |
---|