【问题标题】:Caused by: java.lang.ClassCastException: org.apache.hadoop.io.LongWritable cannot be cast to org.apache.hadoop.io.Text引起:java.lang.ClassCastException:org.apache.hadoop.io.LongWritable 不能转换为 org.apache.hadoop.io.Text
【发布时间】:2014-11-12 05:14:58
【问题描述】:

我正在尝试编译以下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> {

和Map函数如下

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)

【问题讨论】:

  • 您尝试写信到专用邮件列表吗? groups.google.com/forum/#!forum/digitalpebble
  • 我刚刚在上面的群里发了这个话题。我不知道上面提到的论坛!如果我对上述问题有任何答案,请告诉您...同时,您或任何人是否可以告诉我为什么我会遇到上述问题?

标签: hadoop github mapreduce bigdata uima


【解决方案1】:

使用 LongWritable 作为映射器的输入键类型,而不是 Text。 它应该可以工作。

【讨论】:

    猜你喜欢
    • 2013-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-07
    • 2017-12-27
    • 1970-01-01
    • 2023-03-09
    • 2015-06-21
    相关资源
    最近更新 更多