You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-user@hadoop.apache.org by Bill Yu <yu...@gmail.com> on 2009/09/09 15:50:41 UTC

How to define the path of HDFS?

Hi everyone,

     when I run the following code:

     ObjectInputStream in = new ObjectInputStream(new
FileInputStream("hdfs://localhost:9000/myDir/trajectory/test.obj"));

     it throws an error that the directory is not exist, how can I define
the its path ?
     Any suggestion is appreciate !

Thanks,
Austin

Re: How to define the path of HDFS?

Posted by Bill Yu <yu...@gmail.com>.
My purpose is to serialize object to be a node of a btree.

 ObjectInputStream in = new ObjectInputStream(fs.open(new
Path("hdfs://leon1:9000/myDir/trajectory/" + pathToken + ".obj")));
 try {
         tempbtree =  (Btree) in.readObject();
       } catch (ClassNotFoundException e) {
       e.printStackTrace();
  }

Maybe the path is correct , but it throws an error as following :

cannot assign instance of [J to field rtree.Bnode.loc of type
[Lrtree.Trajectory; in instance of rtree.Bnode

How can I solve this problem ? Thank so much for your suggestion.

2009/9/11 Jingkei Ly <jl...@googlemail.com>

> Forgive me if I've got the wrong end of the stick as I'm not very clear on
> what you are trying to achieve. Based on your original post, I presume you
> have a serialized object that you have already stored in HDFS that you would
> like to read and deserialize?
> If that is the case, then you should use:
>
> ObjectInputStream in = new ObjectInputStream(FileSystem.open(new
> Path("hdfs://localhost:9000/myDir/trajectory/test.obj")));
>
>
> 2009/9/11 Bill Yu <yu...@gmail.com>
>
> Thanks for Jingkei's suggestion . But how can I serialize the input scream
>> to create a tree by FileSystem.open() ?
>> Anyone 's suggestion is appreciative!
>>
>> 2009/9/10 Jingkei Ly <jl...@googlemail.com>
>>
>>  You should use FileSystem.open() to obtain an input stream to read from
>>> HDFS (
>>> http://hadoop.apache.org/common/docs/current/api/org/apache/hadoop/fs/FileSystem.html#open%28org.apache.hadoop.fs.Path%29
>>> ).
>>>
>>> 2009/9/9 Bill Yu <yu...@gmail.com>
>>>
>>> Hi everyone,
>>>>
>>>>      when I run the following code:
>>>>
>>>>      ObjectInputStream in = new ObjectInputStream(new
>>>> FileInputStream("hdfs://localhost:9000/myDir/trajectory/test.obj"));
>>>>
>>>>      it throws an error that the directory is not exist, how can I
>>>> define the its path ?
>>>>      Any suggestion is appreciate !
>>>>
>>>> Thanks,
>>>> Austin
>>>
>>>
>>>
>>
>

Re: How to define the path of HDFS?

Posted by Jingkei Ly <jl...@googlemail.com>.
Forgive me if I've got the wrong end of the stick as I'm not very clear on
what you are trying to achieve. Based on your original post, I presume you
have a serialized object that you have already stored in HDFS that you would
like to read and deserialize?
If that is the case, then you should use:

ObjectInputStream in = new ObjectInputStream(FileSystem.open(new
Path("hdfs://localhost:9000/myDir/trajectory/test.obj")));


2009/9/11 Bill Yu <yu...@gmail.com>

> Thanks for Jingkei's suggestion . But how can I serialize the input scream
> to create a tree by FileSystem.open() ?
> Anyone 's suggestion is appreciative!
>
> 2009/9/10 Jingkei Ly <jl...@googlemail.com>
>
>  You should use FileSystem.open() to obtain an input stream to read from
>> HDFS (
>> http://hadoop.apache.org/common/docs/current/api/org/apache/hadoop/fs/FileSystem.html#open%28org.apache.hadoop.fs.Path%29
>> ).
>>
>> 2009/9/9 Bill Yu <yu...@gmail.com>
>>
>> Hi everyone,
>>>
>>>      when I run the following code:
>>>
>>>      ObjectInputStream in = new ObjectInputStream(new
>>> FileInputStream("hdfs://localhost:9000/myDir/trajectory/test.obj"));
>>>
>>>      it throws an error that the directory is not exist, how can I define
>>> the its path ?
>>>      Any suggestion is appreciate !
>>>
>>> Thanks,
>>> Austin
>>
>>
>>
>

Re: How to define the path of HDFS?

Posted by Bill Yu <yu...@gmail.com>.
Thanks for Jingkei's suggestion . But how can I serialize the input scream
to create a tree by FileSystem.open() ?
Anyone 's suggestion is appreciative!

2009/9/10 Jingkei Ly <jl...@googlemail.com>

> You should use FileSystem.open() to obtain an input stream to read from
> HDFS (
> http://hadoop.apache.org/common/docs/current/api/org/apache/hadoop/fs/FileSystem.html#open%28org.apache.hadoop.fs.Path%29
> ).
>
> 2009/9/9 Bill Yu <yu...@gmail.com>
>
> Hi everyone,
>>
>>      when I run the following code:
>>
>>      ObjectInputStream in = new ObjectInputStream(new
>> FileInputStream("hdfs://localhost:9000/myDir/trajectory/test.obj"));
>>
>>      it throws an error that the directory is not exist, how can I define
>> the its path ?
>>      Any suggestion is appreciate !
>>
>> Thanks,
>> Austin
>
>
>

Re: How to define the path of HDFS?

Posted by Jingkei Ly <jl...@googlemail.com>.
You should use FileSystem.open() to obtain an input stream to read from HDFS
(
http://hadoop.apache.org/common/docs/current/api/org/apache/hadoop/fs/FileSystem.html#open%28org.apache.hadoop.fs.Path%29
).

2009/9/9 Bill Yu <yu...@gmail.com>

> Hi everyone,
>
>      when I run the following code:
>
>      ObjectInputStream in = new ObjectInputStream(new
> FileInputStream("hdfs://localhost:9000/myDir/trajectory/test.obj"));
>
>      it throws an error that the directory is not exist, how can I define
> the its path ?
>      Any suggestion is appreciate !
>
> Thanks,
> Austin