Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
MapReduce >> mail # user >> Re: SequenceFileReadDemo issue


Copy link to this message
-
Re: SequenceFileReadDemo issue
Hi,

Can you look at this please, this might help you --

http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestSequenceFile.java?view=markup
Thanks,

On Mon, Sep 16, 2013 at 7:48 AM, kun yan <[EMAIL PROTECTED]> wrote:

> 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
> [EMAIL PROTECTED]
>
>
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB