You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mapreduce-user@hadoop.apache.org by unmesha sreeveni <un...@gmail.com> on 2013/12/30 11:45:55 UTC

Write an object into hadoop hdfs issue

I am trying to write an object into hdfs .


public static Split *currentsplit *= new Split();

*Split currentsplit = new Split();*
*Path p = new Path("C45/mysavedobject");*
*ObjectOutputStream oos = new ObjectOutputStream(fs.create(p));*
*oos.writeObject(currentsplit);*
*oos.close();*

But I am not able to get the exact object value.

*Path p = new Path("C45/mysavedobject");*
*Split curntsplit = null;*
*ObjectInputStream ois = new ObjectInputStream(fs.open(p));*
*try {*
*    curntsplit = (Split) ois.readObject();*
*} catch (ClassNotFoundException e) {*
*    // TODO Auto-generated catch block*
*    e.printStackTrace();*
*}*
* ois.close();*

Showing duplicate objects value.

In driver i am getting :

*objjjjjjj in driver pck.Split@14da173c*

After writing the object into file and reading back within driver itself I
am getting an alternate object value.

*objjjjjj in mysavedobject pck.Split@62eade0*


I want the driver object along my Mapper code.

Why is it so?

-- 
*Thanks & Regards*

Unmesha Sreeveni U.B

Re: Write an object into hadoop hdfs issue

Posted by unmesha sreeveni <un...@gmail.com>.
Is there a way to store the same object?


On Mon, Dec 30, 2013 at 7:05 PM, Chris Mawata <ch...@gmail.com>wrote:

> Not unique to hdfs. The same thing would happen on your local file system
> or anywhere and any way you store the state of the object outside of the
> JVM.  That is why singletons should not be serializable.
> Chris
> On Dec 30, 2013 5:46 AM, "unmesha sreeveni" <un...@gmail.com> wrote:
>
>> I am trying to write an object into hdfs .
>>
>>
>> public static Split *currentsplit *= new Split();
>>
>> *Split currentsplit = new Split();*
>> *Path p = new Path("C45/mysavedobject");*
>> *ObjectOutputStream oos = new ObjectOutputStream(fs.create(p));*
>> *oos.writeObject(currentsplit);*
>> *oos.close();*
>>
>> But I am not able to get the exact object value.
>>
>> *Path p = new Path("C45/mysavedobject");*
>> *Split curntsplit = null;*
>> *ObjectInputStream ois = new ObjectInputStream(fs.open(p));*
>> *try {*
>> *    curntsplit = (Split) ois.readObject();*
>> *} catch (ClassNotFoundException e) {*
>> *    // TODO Auto-generated catch block*
>> *    e.printStackTrace();*
>> *}*
>> * ois.close();*
>>
>> Showing duplicate objects value.
>>
>> In driver i am getting :
>>
>> *objjjjjjj in driver pck.Split@14da173c*
>>
>> After writing the object into file and reading back within driver itself
>> I am getting an alternate object value.
>>
>> *objjjjjj in mysavedobject pck.Split@62eade0*
>>
>>
>> I want the driver object along my Mapper code.
>>
>> Why is it so?
>>
>> --
>> *Thanks & Regards*
>>
>> Unmesha Sreeveni U.B
>>
>>


-- 
*Thanks & Regards*

Unmesha Sreeveni U.B

*Junior Developer*
http://www.unmeshasreeveni.blogspot.in/

Re: Write an object into hadoop hdfs issue

Posted by unmesha sreeveni <un...@gmail.com>.
Is there a way to store the same object?


On Mon, Dec 30, 2013 at 7:05 PM, Chris Mawata <ch...@gmail.com>wrote:

> Not unique to hdfs. The same thing would happen on your local file system
> or anywhere and any way you store the state of the object outside of the
> JVM.  That is why singletons should not be serializable.
> Chris
> On Dec 30, 2013 5:46 AM, "unmesha sreeveni" <un...@gmail.com> wrote:
>
>> I am trying to write an object into hdfs .
>>
>>
>> public static Split *currentsplit *= new Split();
>>
>> *Split currentsplit = new Split();*
>> *Path p = new Path("C45/mysavedobject");*
>> *ObjectOutputStream oos = new ObjectOutputStream(fs.create(p));*
>> *oos.writeObject(currentsplit);*
>> *oos.close();*
>>
>> But I am not able to get the exact object value.
>>
>> *Path p = new Path("C45/mysavedobject");*
>> *Split curntsplit = null;*
>> *ObjectInputStream ois = new ObjectInputStream(fs.open(p));*
>> *try {*
>> *    curntsplit = (Split) ois.readObject();*
>> *} catch (ClassNotFoundException e) {*
>> *    // TODO Auto-generated catch block*
>> *    e.printStackTrace();*
>> *}*
>> * ois.close();*
>>
>> Showing duplicate objects value.
>>
>> In driver i am getting :
>>
>> *objjjjjjj in driver pck.Split@14da173c*
>>
>> After writing the object into file and reading back within driver itself
>> I am getting an alternate object value.
>>
>> *objjjjjj in mysavedobject pck.Split@62eade0*
>>
>>
>> I want the driver object along my Mapper code.
>>
>> Why is it so?
>>
>> --
>> *Thanks & Regards*
>>
>> Unmesha Sreeveni U.B
>>
>>


-- 
*Thanks & Regards*

Unmesha Sreeveni U.B

*Junior Developer*
http://www.unmeshasreeveni.blogspot.in/

Re: Write an object into hadoop hdfs issue

Posted by unmesha sreeveni <un...@gmail.com>.
Is there a way to store the same object?


On Mon, Dec 30, 2013 at 7:05 PM, Chris Mawata <ch...@gmail.com>wrote:

> Not unique to hdfs. The same thing would happen on your local file system
> or anywhere and any way you store the state of the object outside of the
> JVM.  That is why singletons should not be serializable.
> Chris
> On Dec 30, 2013 5:46 AM, "unmesha sreeveni" <un...@gmail.com> wrote:
>
>> I am trying to write an object into hdfs .
>>
>>
>> public static Split *currentsplit *= new Split();
>>
>> *Split currentsplit = new Split();*
>> *Path p = new Path("C45/mysavedobject");*
>> *ObjectOutputStream oos = new ObjectOutputStream(fs.create(p));*
>> *oos.writeObject(currentsplit);*
>> *oos.close();*
>>
>> But I am not able to get the exact object value.
>>
>> *Path p = new Path("C45/mysavedobject");*
>> *Split curntsplit = null;*
>> *ObjectInputStream ois = new ObjectInputStream(fs.open(p));*
>> *try {*
>> *    curntsplit = (Split) ois.readObject();*
>> *} catch (ClassNotFoundException e) {*
>> *    // TODO Auto-generated catch block*
>> *    e.printStackTrace();*
>> *}*
>> * ois.close();*
>>
>> Showing duplicate objects value.
>>
>> In driver i am getting :
>>
>> *objjjjjjj in driver pck.Split@14da173c*
>>
>> After writing the object into file and reading back within driver itself
>> I am getting an alternate object value.
>>
>> *objjjjjj in mysavedobject pck.Split@62eade0*
>>
>>
>> I want the driver object along my Mapper code.
>>
>> Why is it so?
>>
>> --
>> *Thanks & Regards*
>>
>> Unmesha Sreeveni U.B
>>
>>


-- 
*Thanks & Regards*

Unmesha Sreeveni U.B

*Junior Developer*
http://www.unmeshasreeveni.blogspot.in/

Re: Write an object into hadoop hdfs issue

Posted by unmesha sreeveni <un...@gmail.com>.
Is there a way to store the same object?


On Mon, Dec 30, 2013 at 7:05 PM, Chris Mawata <ch...@gmail.com>wrote:

> Not unique to hdfs. The same thing would happen on your local file system
> or anywhere and any way you store the state of the object outside of the
> JVM.  That is why singletons should not be serializable.
> Chris
> On Dec 30, 2013 5:46 AM, "unmesha sreeveni" <un...@gmail.com> wrote:
>
>> I am trying to write an object into hdfs .
>>
>>
>> public static Split *currentsplit *= new Split();
>>
>> *Split currentsplit = new Split();*
>> *Path p = new Path("C45/mysavedobject");*
>> *ObjectOutputStream oos = new ObjectOutputStream(fs.create(p));*
>> *oos.writeObject(currentsplit);*
>> *oos.close();*
>>
>> But I am not able to get the exact object value.
>>
>> *Path p = new Path("C45/mysavedobject");*
>> *Split curntsplit = null;*
>> *ObjectInputStream ois = new ObjectInputStream(fs.open(p));*
>> *try {*
>> *    curntsplit = (Split) ois.readObject();*
>> *} catch (ClassNotFoundException e) {*
>> *    // TODO Auto-generated catch block*
>> *    e.printStackTrace();*
>> *}*
>> * ois.close();*
>>
>> Showing duplicate objects value.
>>
>> In driver i am getting :
>>
>> *objjjjjjj in driver pck.Split@14da173c*
>>
>> After writing the object into file and reading back within driver itself
>> I am getting an alternate object value.
>>
>> *objjjjjj in mysavedobject pck.Split@62eade0*
>>
>>
>> I want the driver object along my Mapper code.
>>
>> Why is it so?
>>
>> --
>> *Thanks & Regards*
>>
>> Unmesha Sreeveni U.B
>>
>>


-- 
*Thanks & Regards*

Unmesha Sreeveni U.B

*Junior Developer*
http://www.unmeshasreeveni.blogspot.in/

Re: Write an object into hadoop hdfs issue

Posted by Chris Mawata <ch...@gmail.com>.
Not unique to hdfs. The same thing would happen on your local file system
or anywhere and any way you store the state of the object outside of the
JVM.  That is why singletons should not be serializable.
Chris
On Dec 30, 2013 5:46 AM, "unmesha sreeveni" <un...@gmail.com> wrote:

> I am trying to write an object into hdfs .
>
>
> public static Split *currentsplit *= new Split();
>
> *Split currentsplit = new Split();*
> *Path p = new Path("C45/mysavedobject");*
> *ObjectOutputStream oos = new ObjectOutputStream(fs.create(p));*
> *oos.writeObject(currentsplit);*
> *oos.close();*
>
> But I am not able to get the exact object value.
>
> *Path p = new Path("C45/mysavedobject");*
> *Split curntsplit = null;*
> *ObjectInputStream ois = new ObjectInputStream(fs.open(p));*
> *try {*
> *    curntsplit = (Split) ois.readObject();*
> *} catch (ClassNotFoundException e) {*
> *    // TODO Auto-generated catch block*
> *    e.printStackTrace();*
> *}*
> * ois.close();*
>
> Showing duplicate objects value.
>
> In driver i am getting :
>
> *objjjjjjj in driver pck.Split@14da173c*
>
> After writing the object into file and reading back within driver itself I
> am getting an alternate object value.
>
> *objjjjjj in mysavedobject pck.Split@62eade0*
>
>
> I want the driver object along my Mapper code.
>
> Why is it so?
>
> --
> *Thanks & Regards*
>
> Unmesha Sreeveni U.B
>
>

Re: Write an object into hadoop hdfs issue

Posted by Chris Mawata <ch...@gmail.com>.
Not unique to hdfs. The same thing would happen on your local file system
or anywhere and any way you store the state of the object outside of the
JVM.  That is why singletons should not be serializable.
Chris
On Dec 30, 2013 5:46 AM, "unmesha sreeveni" <un...@gmail.com> wrote:

> I am trying to write an object into hdfs .
>
>
> public static Split *currentsplit *= new Split();
>
> *Split currentsplit = new Split();*
> *Path p = new Path("C45/mysavedobject");*
> *ObjectOutputStream oos = new ObjectOutputStream(fs.create(p));*
> *oos.writeObject(currentsplit);*
> *oos.close();*
>
> But I am not able to get the exact object value.
>
> *Path p = new Path("C45/mysavedobject");*
> *Split curntsplit = null;*
> *ObjectInputStream ois = new ObjectInputStream(fs.open(p));*
> *try {*
> *    curntsplit = (Split) ois.readObject();*
> *} catch (ClassNotFoundException e) {*
> *    // TODO Auto-generated catch block*
> *    e.printStackTrace();*
> *}*
> * ois.close();*
>
> Showing duplicate objects value.
>
> In driver i am getting :
>
> *objjjjjjj in driver pck.Split@14da173c*
>
> After writing the object into file and reading back within driver itself I
> am getting an alternate object value.
>
> *objjjjjj in mysavedobject pck.Split@62eade0*
>
>
> I want the driver object along my Mapper code.
>
> Why is it so?
>
> --
> *Thanks & Regards*
>
> Unmesha Sreeveni U.B
>
>

Re: Write an object into hadoop hdfs issue

Posted by Chris Mawata <ch...@gmail.com>.
Not unique to hdfs. The same thing would happen on your local file system
or anywhere and any way you store the state of the object outside of the
JVM.  That is why singletons should not be serializable.
Chris
On Dec 30, 2013 5:46 AM, "unmesha sreeveni" <un...@gmail.com> wrote:

> I am trying to write an object into hdfs .
>
>
> public static Split *currentsplit *= new Split();
>
> *Split currentsplit = new Split();*
> *Path p = new Path("C45/mysavedobject");*
> *ObjectOutputStream oos = new ObjectOutputStream(fs.create(p));*
> *oos.writeObject(currentsplit);*
> *oos.close();*
>
> But I am not able to get the exact object value.
>
> *Path p = new Path("C45/mysavedobject");*
> *Split curntsplit = null;*
> *ObjectInputStream ois = new ObjectInputStream(fs.open(p));*
> *try {*
> *    curntsplit = (Split) ois.readObject();*
> *} catch (ClassNotFoundException e) {*
> *    // TODO Auto-generated catch block*
> *    e.printStackTrace();*
> *}*
> * ois.close();*
>
> Showing duplicate objects value.
>
> In driver i am getting :
>
> *objjjjjjj in driver pck.Split@14da173c*
>
> After writing the object into file and reading back within driver itself I
> am getting an alternate object value.
>
> *objjjjjj in mysavedobject pck.Split@62eade0*
>
>
> I want the driver object along my Mapper code.
>
> Why is it so?
>
> --
> *Thanks & Regards*
>
> Unmesha Sreeveni U.B
>
>

Re: Write an object into hadoop hdfs issue

Posted by Chris Mawata <ch...@gmail.com>.
Not unique to hdfs. The same thing would happen on your local file system
or anywhere and any way you store the state of the object outside of the
JVM.  That is why singletons should not be serializable.
Chris
On Dec 30, 2013 5:46 AM, "unmesha sreeveni" <un...@gmail.com> wrote:

> I am trying to write an object into hdfs .
>
>
> public static Split *currentsplit *= new Split();
>
> *Split currentsplit = new Split();*
> *Path p = new Path("C45/mysavedobject");*
> *ObjectOutputStream oos = new ObjectOutputStream(fs.create(p));*
> *oos.writeObject(currentsplit);*
> *oos.close();*
>
> But I am not able to get the exact object value.
>
> *Path p = new Path("C45/mysavedobject");*
> *Split curntsplit = null;*
> *ObjectInputStream ois = new ObjectInputStream(fs.open(p));*
> *try {*
> *    curntsplit = (Split) ois.readObject();*
> *} catch (ClassNotFoundException e) {*
> *    // TODO Auto-generated catch block*
> *    e.printStackTrace();*
> *}*
> * ois.close();*
>
> Showing duplicate objects value.
>
> In driver i am getting :
>
> *objjjjjjj in driver pck.Split@14da173c*
>
> After writing the object into file and reading back within driver itself I
> am getting an alternate object value.
>
> *objjjjjj in mysavedobject pck.Split@62eade0*
>
>
> I want the driver object along my Mapper code.
>
> Why is it so?
>
> --
> *Thanks & Regards*
>
> Unmesha Sreeveni U.B
>
>