我正在尝试编译以下 github 项目https://github.com/DigitalPebble/behemoth/tree/master/uima
我收到以下错误 java.lang.ClassCastException: org.apache.hadoop.io.LongWritable cannot be cast to org.apache.hadoop.io.Text
代码定义了以下输出键和值类。其中 BehemothDocument 是定义的自定义类
job.setInputFormat(SequenceFileInputFormat.class);
job.setOutputFormat(SequenceFileOutputFormat.class);
job.setMapOutputKeyClass(Text.class);
job.setMapOutputValueClass(BehemothDocument.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(BehemothDocument.class);
地图类如下所示
public class UIMAMapper extends MapReduceBase implements
Mapper<Text, BehemothDocument, Text, BehemothDocument> {
和地图功能如下
public void map(Text id, BehemothDocument behemoth,
OutputCollector<Text, BehemothDocument> output, Reporter reporter)
对于上述堆栈溢出错误,我已经看到了几个答案,它们要求更改 Mapper 键,我不想做的值类型。我想知道如何使用自定义类。
请对此提供帮助。以下是堆栈跟踪信息
java.lang.Exception: java.lang.ClassCastException: org.apache.hadoop.io.LongWritable cannot be cast to org.apache.hadoop.io.Text
at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:354)
Caused by: java.lang.ClassCastException: org.apache.hadoop.io.LongWritable cannot be cast to org.apache.hadoop.io.Text
at UIMAPackage.UIMAMapper.map(UIMAMapper.java:35)
at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:50)
at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:430)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:366)
at org.apache.hadoop.mapred.LocalJobRunner$Job$MapTaskRunnable.run(LocalJobRunner.java:223)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)