You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-user@hadoop.apache.org by akhil1988 <ak...@gmail.com> on 2010/05/15 13:40:22 UTC

FileInputStream for HDFS

I have a file that contains java serialized objects like "Vector". I have
stored this file over Hadoop Distributed File System(HDFS). Now I intend to
read this file (using method readObject) in one of the map task. I suppose

FileInputStream in = new FileInputStream("hdfs/path/to/file");

wont' work as the file is stored over HDFS. So I thought of using
org.apache.hadoop.fs.FileSystem class. But Unfortunately it does not have
any method that returns FileInputStream. All it has is a method that returns
FSDataInputStream but I want a inputstream that can read serialized java
objects like vector from a file rather than just primitive data types that
FSDataInputStream would do
-- 
View this message in context: http://old.nabble.com/FileInputStream-for-HDFS-tp28567783p28567783.html
Sent from the Hadoop core-user mailing list archive at Nabble.com.


Re: FileInputStream for HDFS

Posted by Andy Liu <an...@gmail.com>.
FSDataInputStream IS an InputStream.  So you can wrap it with another
implementation of InputStream, i.e. ObjectInputStream to read your
serialized data.

On Sat, May 15, 2010 at 7:40 AM, akhil1988 <ak...@gmail.com> wrote:

>
> I have a file that contains java serialized objects like "Vector". I have
> stored this file over Hadoop Distributed File System(HDFS). Now I intend to
> read this file (using method readObject) in one of the map task. I suppose
>
> FileInputStream in = new FileInputStream("hdfs/path/to/file");
>
> wont' work as the file is stored over HDFS. So I thought of using
> org.apache.hadoop.fs.FileSystem class. But Unfortunately it does not have
> any method that returns FileInputStream. All it has is a method that
> returns
> FSDataInputStream but I want a inputstream that can read serialized java
> objects like vector from a file rather than just primitive data types that
> FSDataInputStream would do
> --
> View this message in context:
> http://old.nabble.com/FileInputStream-for-HDFS-tp28567783p28567783.html
> Sent from the Hadoop core-user mailing list archive at Nabble.com.
>
>