View Javadoc

1   /* Copyright (c) 2008 Sascha Kohlmann
2    *
3    * This program is free software: you can redistribute it and/or modify
4    * it under the terms of the GNU Affero General Public License as published by
5    * the Free Software Foundation, either version 3 of the License, or
6    * (at your option) any later version.
7    *
8    * This program is distributed in the hope that it will be useful,
9    * but WITHOUT ANY WARRANTY; without even the implied warranty of
10   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11   * GNU Affero General Public License for more details.
12   *
13   * You should have received a copy of the GNU Affero General Public License
14   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15   */
16  package net.sf.eos.hadoop.mapred.index;
17  
18  import net.sf.eos.hadoop.mapred.EosDocumentSupportMapReduceBase;
19  import net.sf.eos.hadoop.mapred.Index;
20  
21  import org.apache.hadoop.io.Text;
22  import org.apache.hadoop.io.WritableComparable;
23  import org.apache.hadoop.mapred.JobConf;
24  import org.apache.hadoop.mapred.Mapper;
25  import org.apache.hadoop.mapred.OutputCollector;
26  import org.apache.hadoop.mapred.Reporter;
27  
28  import java.io.IOException;
29  
30  public class IndexMapper<K extends WritableComparable>
31          extends EosDocumentSupportMapReduceBase
32          implements Mapper<K, Text, K, Text> {
33  
34      private JobConf conf;
35  
36      public void map(final K key,
37                      final Text value,
38                      final OutputCollector<K, Text> output,
39                      final Reporter reporter)
40              throws IOException {
41          output.collect(key, value);
42          reporter.incrCounter(Index.MAP, 1);
43      }
44  
45      /**
46       * @param conf the configuration
47       */
48      @Override
49      public void configure(@SuppressWarnings("hiding") final JobConf conf) {
50          super.configure(conf);
51          this.conf = conf;
52      }
53  
54      @Override
55      public void close() throws IOException {
56          super.close();
57      }
58  }