1. 程式人生 > >Mapreduce學習:mapper類中的4個泛型引數解析

Mapreduce學習:mapper類中的4個泛型引數解析

先看程式碼

public class FlowCountMapper extends Mapper<LongWritable, Text, Text, FlowBean>{
}

1、LongWritable:表示worder傳入KEY的資料型別,預設是一行起始偏移量 2、Text:表示worder傳入VALUE的資料型別,預設是下一行的文字內容 3、Test:表示自己map方法產生產生的結果資料型別KEY 4、FlowBean:表示自己map方法產生的結果資料的VALUE型別

重寫Mapper方法

@Override
protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, FlowBean>.Context context)throws IOException, InterruptedException {
}
//Mapper<LongWritable, Text, Text, FlowBean>.Context context 表示上下文工具,用於將資料返回worker

map()被 map task 呼叫,每讀一行呼叫,將這一行偏移量傳入引數key,內容傳入引數value