[ Skip to the content ]

Institute of Formal and Applied Linguistics Wiki


[ Back to the navigation ]

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
courses:mapreduce-tutorial:step-26 [2012/01/30 15:41]
majlis
courses:mapreduce-tutorial:step-26 [2012/01/31 11:29]
straka
Line 1: Line 1:
-====== MapReduce Tutorial : Counters, compression and job configuration ======+====== MapReduce Tutorial : Compression and job configuration ======
  
-===== Counters ===== 
  
-As in the Perl API, a mapper or a reducer can increment various counters by using ''context.getCounter("Group", "Name").increment(value)'': 
-<code java> 
-public void map(Text key, Text value, Context context) throws IOException, InterruptedException { 
-  ... 
-  context.getCounter("Group", "Name").increment(value); 
-  ... 
-} 
-</code> 
-The ''getCounter'' method returns a [[http://hadoop.apache.org/common/docs/r1.0.0/api/org/apache/hadoop/mapreduce/Counter.html|Counter]] object, so if a counter is incremented frequently, the ''getCounter'' method can be called only once: 
-<code java> 
-public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException { 
-  ... 
-  Counter values = context.getCounter("Reducer", "Number of values"); 
-  for (IntWritable value : values) { 
-    ... 
-    values.increment(1); 
-  } 
-} 
-</code> 
  
 ===== Compression ===== ===== Compression =====

[ Back to the navigation ] [ Back to the content ]