The Mapper class is a generic type with four formal parameters that define the input key, input value, output key, and output values ββfor the display function.
public class MaxTemperatureMapper extends Mapper<LongWritable, Text, Text, IntWritable> { @Override public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException { } @Override public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException { } }
For example code, the input key is a long integer offset, the input value is a string of text. the output key is an integer, and the output value is an integer. Instead of using the built-in types of Java, Hadoop provides its own set of basic types, optimized for serializing the network. They are in the package org.apache.hadoop.io.
Here we use LongWritable, which corresponds to Java Long, Text (e.g. String Java) and IntWritable (e.g. Java Integer).
source share