新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Hadoop教程:HadoopMapper
主要是讀取InputSplit的每一個Key,Value對并進行處理

十余年專注建站、設計、互聯(lián)網(wǎng)產(chǎn)品按需制作網(wǎng)站服務,業(yè)務涵蓋高端網(wǎng)站設計、商城開發(fā)、微信小程序、軟件系統(tǒng)開發(fā)、手機APP定制開發(fā)等。憑借多年豐富的經(jīng)驗,我們會仔細了解每個客戶的需求而做出多方面的分析、設計、整合,為客戶設計出具風格及創(chuàng)意性的商業(yè)解決方案,創(chuàng)新互聯(lián)公司更提供一系列網(wǎng)站制作和網(wǎng)站推廣的服務,以推動各中小企業(yè)全面信息數(shù)字化,并利用創(chuàng)新技術(shù)幫助各行業(yè)提升企業(yè)形象和運營效率。
public class Mapper {
/**
* 預處理,僅在map task啟動時運行一次
*/
protected void setup(Context context) throws IOException, InterruptedException {
}
/**
* 對于InputSplit中的每一對都會運行一次
*/
@SuppressWarnings("unchecked")
protected void map(KEYIN key, VALUEIN value, Context context) throws IOException, InterruptedException {
context.write((KEYOUT) key, (VALUEOUT) value);
}
/**
* 掃尾工作,比如關(guān)閉流等
*/
protected void cleanup(Context context) throws IOException, InterruptedException {
}
/**
* map task的驅(qū)動器
*/
public void run(Context context) throws IOException, InterruptedException {
setup(context);
while (context.nextKeyValue()) {
map(context.getCurrentKey(), context.getCurrentValue(), context);
}
cleanup(context);
}
}
public class MapContext extends TaskInputOutputContext {
private RecordReader reader;
private InputSplit split;
/**
* Get the input split for this map.
*/
public InputSplit getInputSplit() {
return split;
}
@Override
public KEYIN getCurrentKey() throws IOException, InterruptedException {
return reader.getCurrentKey();
}
@Override
public VALUEIN getCurrentValue() throws IOException, InterruptedException {
return reader.getCurrentValue();
}
@Override
public boolean nextKeyValue() throws IOException, InterruptedException {
return reader.nextKeyValue();
}
} 當前標題:創(chuàng)新互聯(lián)Hadoop教程:HadoopMapper
網(wǎng)址分享:http://m.5511xx.com/article/cdsoeod.html


咨詢
建站咨詢
