hadoop-common-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aa...@buffalo.edu
Subject Object Serialization
Date Sun, 29 Nov 2009 22:10:16 GMT
Hello Everybody,
                 I have a question about object serialization in Hadoop. I have
an object A which I want to pass to every map function. Currently the code I am
using for this is as under. The problem is if I run my program, the code crashes
the first time with an error say that Java cannot deserialize the object list(
but no error when java tries to serialize it ) and then when I run the program
for the 2 time, without changing anything, the code works perfectly. 

I read on some blog post that the method I have used to serialize is not the
ideal way. But this also does not explain the weird results I am getting. 

                 try
                {
                        ByteArrayOutputStream baos= new ByteArrayOutputStream();
                        ObjectOutputStream oos= new ObjectOutputStream(baos);
                        oos.writeObject(list);
                        stock_list= encode.encode(baos.toByteArray()); 
                }
                catch(IOException e)
                {
                        e.printStackTrace();
                }

Thank You

Abhishek Agrawal

SUNY- Buffalo
(716-435-7122)




Mime
View raw message