如何在Reducer中导入BigIntegerWritable?

时间:2013-10-24 03:52:00

标签: java hadoop biginteger

我正在写一个reducer,每个键的值可能非常大(大于long值的范围)。我打算使用BigInteger作为值的类型,我注意到在pig中定义了一个类BigIntegerWritable。但是,我使用库pig-0.11.0.jarpig-0.11.0-withouthadoop.jar进行编译。它无法找到BigIntegerWritable

这是我用来编译的命令:

javac -classpath /var/hadoop/hadoop-core-1.0.4.jar:/var/pig/pig-0.11.0.jar wordcount.java wordcountReducer.java wordcountMapper.java

以下是错误消息:

wordcountReducer.java:8: error: cannot find symbol
import org.apache.pig.backend.hadoop.BigIntegerWritable;
                                ^
symbol:   class BigIntegerWritable
location: package org.apache.pig.backend.hadoop
wordcountReducer.java:18: error: cannot find symbol
implements Reducer<Text, LongWritable, Text, BigIntegerWritable> {
                                           ^
symbol: class BigIntegerWritable
wordcountReducer.java:21: error: cannot find symbol
OutputCollector<Text, BigIntegerWritable> output, Reporter reporter)
                        ^
symbol:   class BigIntegerWritable
location: class wordcountReducer
wordcountReducer.java:28: error: cannot find symbol
output.collect(key, new BigIntegerWritable(wordNumber));
                        ^
symbol:   class BigIntegerWritable
location: class wordcountReducer
4 errors

1 个答案:

答案 0 :(得分:1)

我相当肯定BigIntegerWritable成为Pig 0.12中的一个东西,见here。所以你需要那个版本。即使如此,我也不认为将猪包括在这里只是为了帮助你的减速器而上课。

我认为你最好自己编写BigIntegerWritable。它不会太难,因为它已经有来往byte[]的方法。只需使用IntWritable作为模型。