hadoop-mapreduce-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kun yan <yankunhad...@gmail.com>
Subject SequenceFileReadDemo issue
Date Mon, 16 Sep 2013 02:18:20 GMT
Hi all when i read  SequenceFIle occur exception

Exception in thread "main" java.lang.RuntimeException:
java.lang.NoSuchMethodException:
org.apache.hadoop.io.SequenceFile$Reader.<init>()
at
org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:128)
at
com.yanbit.hadoop.filesystem.sequence.SequenceFileReadDemo.main(SequenceFileReadDemo.java:24)
Caused by: java.lang.NoSuchMethodException:
org.apache.hadoop.io.SequenceFile$Reader.<init>()
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.getDeclaredConstructor(Unknown Source)
at
org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:122)
... 1 more

follow is my source code

public class SequenceFileReadDemo {
    public static void main(String[] args) throws IOException {
String uri = args[0];// /sequence/sequencefile
Configuration conf = new Configuration();
conf.set("fs.defaultFS", "hdfs://hydra0001:8020");
FileSystem fs = FileSystem.get(conf);
Path path = new Path(uri);
SequenceFile.Reader reader = null;

try {
    reader = new SequenceFile.Reader(fs, path, conf);
    Writable key = (Writable) ReflectionUtils.newInstance(
     reader.getClass(), conf);
    Writable value = (Writable) ReflectionUtils.newInstance(
     reader.getValueClass(), conf);
    long position = reader.getPosition();
    while (reader.next(key,value)) {
        String syncSeen = reader.syncSeen() ? "*" : "";
        System.out.printf("[%s%s]\t%s\t%s\n",  position,  syncSeen,  key,
 value);
        position = reader.getPosition(); // beginning of next record
    }
} finally {
    IOUtils.closeStream(reader);
}
    }
}

-- 

In the Hadoop world, I am just a novice, explore the entire Hadoop
ecosystem, I hope one day I can contribute their own code

YanBit
yankunhadoop@gmail.com

Mime
View raw message