MapReduce中ArrayWritable 使用指南
在編寫MapReduce程序時(shí),Map和Reduce之間傳遞的數(shù)據(jù)需要是ArrayList類型的,在調(diào)試運(yùn)行時(shí)遇到了這樣的一個(gè)錯(cuò)誤:
java.lang.RuntimeException: java.lang.NoSuchMethodException: org.apache.hadoop.io.ArrayWritable.<init>()
經(jīng)查詢官網(wǎng)API文檔后發(fā)現(xiàn)這樣的一段話:
A Writable for arrays containing instances of a class. The elements of this writable must all be instances of the same class. If this writable will be the input for a Reducer, you will need to create a subclass that sets the value to be of the proper type. For example: public class IntArrayWritable extends ArrayWritable { public IntArrayWritable() { super(IntWritable.class); } }
原來(lái)是要自己實(shí)現(xiàn)一個(gè)ArrayWritable類的派生類,使用時(shí)只要實(shí)現(xiàn)兩個(gè)構(gòu)造函數(shù)即可
public static class TextArrayWritable extends ArrayWritable {
public TextArrayWritable() {
super(Text.class);
}
public TextArrayWritable(String[] strings) {
super(Text.class);
Text[] texts = new Text[strings.length];
for (int i = 0; i < strings.length; i++) {
texts[i] = new Text(strings[i]);
}
set(texts);
}
}
- MongoDB中MapReduce編程模型使用實(shí)例
- 用PHP和Shell寫Hadoop的MapReduce程序
- java連接hdfs ha和調(diào)用mapreduce jar示例
- Mongodb中MapReduce實(shí)現(xiàn)數(shù)據(jù)聚合方法詳解
- JavaScript mapreduce工作原理簡(jiǎn)析
- MongoDB中的MapReduce簡(jiǎn)介
- Java函數(shù)式編程(七):MapReduce
- Java/Web調(diào)用Hadoop進(jìn)行MapReduce示例代碼
- MongoDB中MapReduce的使用方法詳解
- 通用MapReduce程序復(fù)制HBase表數(shù)據(jù)
相關(guān)文章
Springboot WebFlux集成Spring Security實(shí)現(xiàn)JWT認(rèn)證的示例
這篇文章主要介紹了Springboot WebFlux集成Spring Security實(shí)現(xiàn)JWT認(rèn)證的示例,幫助大家更好的理解和學(xué)習(xí)使用springboot框架,感興趣的朋友可以了解下2021-04-04
Spring整合Quartz實(shí)現(xiàn)動(dòng)態(tài)定時(shí)器的示例代碼
本篇文章主要介紹了Spring整合Quartz實(shí)現(xiàn)動(dòng)態(tài)定時(shí)器的示例代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。2017-01-01
httpclient模擬post請(qǐng)求json封裝表單數(shù)據(jù)的實(shí)現(xiàn)方法
下面小編就為大家?guī)?lái)一篇httpclient模擬post請(qǐng)求json封裝表單數(shù)據(jù)的實(shí)現(xiàn)方法。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-12-12
通過(guò)Docker啟動(dòng)Solace并在Spring?Boot通過(guò)JMS整合Solace的操作方法
本文將介紹如何在Spring中使用,雖然代碼使用的是Spring Boot,但并沒(méi)有使用相關(guān)starter,跟Spring的整合一樣,可通用,JMS是通過(guò)的消息處理框架,可以深入學(xué)習(xí)一下,不同的MQ在JMS的整合上都是類似的,感興趣的朋友跟隨小編一起看看吧2023-01-01
Java基本知識(shí)點(diǎn)之變量和數(shù)據(jù)類型
這篇文章主要給大家介紹了關(guān)于Java基本知識(shí)點(diǎn)之變量和數(shù)據(jù)類型的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2021-04-04
Java實(shí)現(xiàn)簡(jiǎn)單郵件發(fā)送
這篇文章主要介紹了Java實(shí)現(xiàn)簡(jiǎn)單郵件發(fā)送的相關(guān)資料,實(shí)例講解了java郵件發(fā)送實(shí)現(xiàn)方法,感興趣的小伙伴們可以參考一下2016-02-02
Java NumberFormat格式化float類型的bug
今天小編就為大家分享一篇關(guān)于Java NumberFormat格式化float類型的bug,小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧2018-10-10

