Return-Path: X-Original-To: apmail-hadoop-mapreduce-user-archive@minotaur.apache.org Delivered-To: apmail-hadoop-mapreduce-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3F64110C3F for ; Mon, 16 Sep 2013 02:36:12 +0000 (UTC) Received: (qmail 33322 invoked by uid 500); 16 Sep 2013 02:36:04 -0000 Delivered-To: apmail-hadoop-mapreduce-user-archive@hadoop.apache.org Received: (qmail 32934 invoked by uid 500); 16 Sep 2013 02:36:04 -0000 Mailing-List: contact user-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hadoop.apache.org Delivered-To: mailing list user@hadoop.apache.org Received: (qmail 32927 invoked by uid 99); 16 Sep 2013 02:36:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Sep 2013 02:36:03 +0000 X-ASF-Spam-Status: No, hits=2.5 required=5.0 tests=FREEMAIL_REPLY,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of schhajed.iet@gmail.com designates 209.85.215.49 as permitted sender) Received: from [209.85.215.49] (HELO mail-la0-f49.google.com) (209.85.215.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Sep 2013 02:35:56 +0000 Received: by mail-la0-f49.google.com with SMTP id ev20so2598837lab.22 for ; Sun, 15 Sep 2013 19:35:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=Xk/fh6e24hoRZlL82K4Mi6cY7scDu2sAGNAdAcoc2Ds=; b=sBarjmMriDvhi2R6u8ssZr75kJebFdwAKMMXWlJA6qxBmIZRf/w+s3x6DujQG0H3qn rUZanPgl2xn1tBJfCS0jVP4rCM09Fi29CClykc4PG8eVUzh/qsM2OTj/9KHZGuNsd7Xm 4x8ni/kNsj9yglIZSdQ2Wj+z44n1xM9AQAC0ulBWP8uXlg3Ucqd+rvVn9W8ipfZLYOfr 2N1K+lUaCNUuz4TjxT2sVyk41JanmKPGCWJSJ52fe2ckACgse6MsE7vU68TA4abhXahz ElVyD5b47OLT5vfxoiowFKDfS4xa8RMCD3nf6FK/6/G+hlkH9GRMmbLdNvQ0+IiCJ1Q+ 4Jxw== X-Received: by 10.152.115.176 with SMTP id jp16mr22775231lab.17.1379298936356; Sun, 15 Sep 2013 19:35:36 -0700 (PDT) MIME-Version: 1.0 Received: by 10.114.80.70 with HTTP; Sun, 15 Sep 2013 19:35:16 -0700 (PDT) In-Reply-To: References: From: saurabh chhajed Date: Mon, 16 Sep 2013 08:05:16 +0530 Message-ID: Subject: Re: SequenceFileReadDemo issue To: user@hadoop.apache.org Content-Type: multipart/alternative; boundary=001a11c3509624035a04e6770fc1 X-Virus-Checked: Checked by ClamAV on apache.org --001a11c3509624035a04e6770fc1 Content-Type: text/plain; charset=ISO-8859-1 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 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.() > 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.() > 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 > > --001a11c3509624035a04e6770fc1 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable =


On Mon, Sep 1= 6, 2013 at 7:48 AM, kun yan <yankunhadoop@gmail.com> wr= ote:
Hi all when i read =A0= SequenceFIle occur exception=A0

Exception in = thread "main" java.lang.RuntimeException: java.lang.NoSuchMethodE= xception: 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.Seque= nceFile$Reader.<init>()
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.getDeclared= Constructor(Unknown Source)
= at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUti= ls.java:122)
... 1 more

follow is my source code=A0

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

try {
=A0 =A0reader =3D new S= equenceFile.Reader(fs, path, conf);
=A0 =A0Writable key =3D (Writable) ReflectionUtils.newInst= ance(
=A0 =A0 reader.getClass(), conf);
=A0 =A0Writable value =3D (Writable) Ref= lectionUtils.newInstance(
=A0 =A0 reader.getValueClass(), conf);
=A0 =A0long position =3D reader.get= Position();
=A0 =A0while (reader.nex= t(key,value)) {
=A0= =A0 =A0 =A0String syncSeen =3D reader.syncSeen() ? "*" : "&= quot;;
=A0 =A0 =A0 =A0System.ou= t.printf("[%s%s]\t%s\t%s\n", =A0position, =A0syncSeen, =A0key, = =A0value);=A0
=A0 = =A0 =A0 =A0position =3D reader.getPosition(); // beginning of next record
=A0 =A0}
} finally {
=A0 =A0IOUtils.closeStream(reader);
}
=A0 =A0 }
}

--

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


--001a11c3509624035a04e6770fc1--