我试图在hadoop2.0中读取一个sequencefile,但是我无法实现它。我正在使用下面的代码,它在hadoop1.0中运行得非常好。请让我知道如果我错过了wrt 2.0的东西
Configuration conf = new Configuration();
try {
FileSystem fs = FileSystem.get(conf);
Path p = new Path("/Users/xxx/git/xxx/src/test/cntr-20140527104344-r-00172");
SequenceFile.Reader reader = new SequenceFile.Reader(fs,p,conf);
Writable key = (Writable) ReflectionUtils.newInstance(reader.getKeyClass(), conf);
Writable value = (Writable) ReflectionUtils.newInstance(reader.getValueClass(), conf);
我在尝试调试时遇到以下错误。
2014-05-28 23:30:31,567 WARN util.NativeCodeLoader (NativeCodeLoader.java:<clinit>(52)) - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
2014-05-28 23:30:31,572 INFO compress.CodecPool (CodecPool.java:getDecompressor(121)) - Got brand-new decompressor
java.io.EOFException
at java.util.zip.GZIPInputStream.readUByte(GZIPInputStream.java:264)
at java.util.zip.GZIPInputStream.readUShort(GZIPInputStream.java:254)
at java.util.zip.GZIPInputStream.readHeader(GZIPInputStream.java:163)
at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:78)
at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:90)
at org.apache.hadoop.io.compress.GzipCodec$GzipInputStream$ResetableGZIPInputStream.<init>(GzipCodec.java:92)
at org.apache.hadoop.io.compress.GzipCodec$GzipInputStream.<init>(GzipCodec.java:101)
at org.apache.hadoop.io.compress.GzipCodec.createInputStream(GzipCodec.java:169)
at org.apache.hadoop.io.compress.GzipCodec.createInputStream(GzipCodec.java:179)
at org.apache.hadoop.io.SequenceFile$Reader.init(SequenceFile.java:1520)
at org.apache.hadoop.io.SequenceFile$Reader.<init>(SequenceFile.java:1428)
at org.apache.hadoop.io.SequenceFile$Reader.<init>(SequenceFile.java:1417)
at org.apache.hadoop.io.SequenceFile$Reader.<init>(SequenceFile.java:1412)
at com.xxx.bis.social.feedbehavior.cdl.Debuger.testSpliter(Debuger.java:30)
请帮忙。
注意:使用hadoop2.0api读写sequencefile我引用了这个链接。但没有起作用。
1条答案
按热度按时间ugmeyewa1#
似乎你的系统上有错误的hadoop类。看看这个问题。