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

十余年專(zhuān)注建站、設(shè)計(jì)、互聯(lián)網(wǎng)產(chǎn)品按需制作網(wǎng)站服務(wù),業(yè)務(wù)涵蓋高端網(wǎng)站設(shè)計(jì)、商城開(kāi)發(fā)、微信小程序、軟件系統(tǒng)開(kāi)發(fā)、手機(jī)APP定制開(kāi)發(fā)等。憑借多年豐富的經(jīng)驗(yàn),我們會(huì)仔細(xì)了解每個(gè)客戶(hù)的需求而做出多方面的分析、設(shè)計(jì)、整合,為客戶(hù)設(shè)計(jì)出具風(fēng)格及創(chuàng)意性的商業(yè)解決方案,創(chuàng)新互聯(lián)公司更提供一系列網(wǎng)站制作和網(wǎng)站推廣的服務(wù),以推動(dòng)各中小企業(yè)全面信息數(shù)字化,并利用創(chuàng)新技術(shù)幫助各行業(yè)提升企業(yè)形象和運(yùn)營(yíng)效率。
public class Mapper {
/**
* 預(yù)處理,僅在map task啟動(dòng)時(shí)運(yùn)行一次
*/
protected void setup(Context context) throws IOException, InterruptedException {
}
/**
* 對(duì)于InputSplit中的每一對(duì)都會(huì)運(yùn)行一次
*/
@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ū)動(dòng)器
*/
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)站網(wǎng)址:http://fisionsoft.com.cn/article/cdsoeod.html


咨詢(xún)
建站咨詢(xún)
