Menu ▾ ▴

#1 ClassCastException:LongWritable cannot be cast to Text

open-fixed
nobody
None
5
2012-02-12
2012-02-02
No

using the latest mirex from svn.
using hadoop 1.0 (also reproduceable with hadoop 0.20.2), when running the anchor text extraction, I get this error:

java.lang.ClassCastException: org.apache.hadoop.io.LongWritable cannot be cast to org.apache.hadoop.io.Text
at nl.utwente.mirex.AnchorExtract$Map.map(Unknown Source)
at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:144)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:764)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:370)
at org.apache.hadoop.mapred.Child$4.run(Child.java:255)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:396)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1083)
at org.apache.hadoop.mapred.Child.main(Child.java:249)

Discussion

  • Dieter Plaetinck

    This fix seems to work:

    diff --git a/src/nl/utwente/mirex/AnchorExtract.java b/src/nl/utwente/mirex/AnchorExtract.java
    index 5b7b41e..1094b50 100644
    --- a/src/nl/utwente/mirex/AnchorExtract.java
    +++ b/src/nl/utwente/mirex/AnchorExtract.java
    @@ -27,6 +27,7 @@ import java.util.regex.Matcher;
    import java.util.regex.Pattern;

    import org.apache.hadoop.fs.Path;
    +import org.apache.hadoop.io.LongWritable;
    import org.apache.hadoop.io.Text;
    import org.apache.hadoop.io.compress.GzipCodec;
    import org.apache.hadoop.mapreduce.Job;
    @@ -71,7 +72,7 @@ public class AnchorExtract {
    /**
    * -- Mapper: Extracts anchors.
    */
    - public static class Map extends Mapper<Text, WritableWarcRecord, Text, Text> {
    + public static class Map extends Mapper<LongWritable, WritableWarcRecord, Text, Text> {
    //public static class Map extends MapReduceBase implements Mapper<LongWritable, WritableWarcRecord, Text, Text> {

    private final static Pattern
    @@ -103,7 +104,7 @@ public class AnchorExtract {
    * @param value the web page
    * @param output (URL, anchor text <i>or</i> TREC-ID)
    */
    - public void map(Text key, WritableWarcRecord value, Context context)
    + public void map(LongWritable key, WritableWarcRecord value, Context context)
    throws IOException, InterruptedException {
    String baseUri, trecId, content;
    Text link = new Text(), anchor = new Text();

     
  • Robin Aly

    Robin Aly - 2012-02-12
    • status: open --> open-fixed
     

Log in to post a comment.