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 Stuart Sierra <ma...@stuartsierra.com> on 2008/05/22 22:54:33 UTC

Serialization format for structured data

Hello, I'm still getting my head around how Hadoop works.  A survey
question: what kind of serialization do you use to output structured
data from your map/reduce jobs?

When both key and value are primitive types, either TextOutputFormat
or SequenceFileOutputFormat is easy.  But what if you want to store a
more complex data structure as the value?

By "complex data structure," I mean some combination of lists/arrays,
dictionaries/hashes, and primitives (int, float, string, boolean,
null).

I've tried using JSON to store structured data in TextOutputFormat,
which works but is not very efficient.  Any better suggestions?

Thanks, all,
-Stuart

Re: Serialization format for structured data

Posted by Bryan Duxbury <br...@rapleaf.com>.
Personally I'm going down the Thrift road. It's terse, sparse,  
binary, and generated, which is pretty awesome in my book.

-Bryan

On May 22, 2008, at 1:54 PM, Stuart Sierra wrote:

> Hello, I'm still getting my head around how Hadoop works.  A survey
> question: what kind of serialization do you use to output structured
> data from your map/reduce jobs?
>
> When both key and value are primitive types, either TextOutputFormat
> or SequenceFileOutputFormat is easy.  But what if you want to store a
> more complex data structure as the value?
>
> By "complex data structure," I mean some combination of lists/arrays,
> dictionaries/hashes, and primitives (int, float, string, boolean,
> null).
>
> I've tried using JSON to store structured data in TextOutputFormat,
> which works but is not very efficient.  Any better suggestions?
>
> Thanks, all,
> -Stuart


RE: Serialization format for structured data

Posted by Vivek Ratan <vi...@yahoo-inc.com>.
It's a finished product in the sense that the functionality works and is
robust, and it is being used by some folks. You can find more examples
through the test cases (src\test\org\apache\hadoop\record) and some C++
examples at src\c++\librecordio\test.  

> -----Original Message-----
> From: the.stuart.sierra@gmail.com 
> [mailto:the.stuart.sierra@gmail.com] On Behalf Of Stuart Sierra
> Sent: Tuesday, May 27, 2008 1:06 AM
> To: core-user@hadoop.apache.org
> Subject: Re: Serialization format for structured data
> 
> Thanks, Vivak, I wasn't aware of Record I/O.  For the record 
> (no pun intended), I found the docs here:
> http://hadoop.apache.org/core/docs/r0.17.0/api/org/apache/hado
> op/record/package-summary.html
> 
> I don't recall seeing Record I/O in any tutorials or on the 
> wiki.  Is it a finished product, or more of an experimental 
> sub-project right now?
> 
> -Stuart
> 
> 
> On Sun, May 25, 2008 at 11:12 PM, Vivek Ratan 
> <vi...@yahoo-inc.com> wrote:
> > Am joining the conversation late, but another option is is Hadoop's 
> > own RecordIO. Like with Thrift, you need to use compiler-generated 
> > stubs to read and write records, but it also supports 
> schemas. You can 
> > de/serialize schemas separately from content, which gives 
> you lots of 
> > flexibility.
> >
> >> -----Original Message-----
> >> From: Bryan Duxbury [mailto:bryan@rapleaf.com]
> >> Sent: Saturday, May 24, 2008 12:13 AM
> >> To: core-user@hadoop.apache.org
> >> Subject: Re: Serialization format for structured data
> >>
> >>
> >> On May 23, 2008, at 9:51 AM, Ted Dunning wrote:
> >> > Relative to thrift, JSON has the advantage of not requiring
> >> a schema
> >> > as well as the disadvantage of not having a schema.  The
> >> advantage is
> >> > that the data is more fluid and I don't have to generate code to 
> >> > handle the records.  The disadvantage is that I lose some data 
> >> > completeness and typing guarantees.
> >> > On balance, I would like to use JSON-like data quite a bit
> >> in ad hoc
> >> > data streams and in logs where the producer and consumer of
> >> the data
> >> > are not visible to parts of the data processing chain.
> >>
> >> That about sums it up. If you want schema, Thrift is your 
> friend. If 
> >> you don't, JSON probably will do pretty well for you.
> >>
> >> -Bryan
> >>
> >
> 

Re: Serialization format for structured data

Posted by Stuart Sierra <ma...@stuartsierra.com>.
Thanks, Vivak, I wasn't aware of Record I/O.  For the record (no pun
intended), I found the docs here:
http://hadoop.apache.org/core/docs/r0.17.0/api/org/apache/hadoop/record/package-summary.html

I don't recall seeing Record I/O in any tutorials or on the wiki.  Is
it a finished product, or more of an experimental sub-project right
now?

-Stuart


On Sun, May 25, 2008 at 11:12 PM, Vivek Ratan <vi...@yahoo-inc.com> wrote:
> Am joining the conversation late, but another option is is Hadoop's own
> RecordIO. Like with Thrift, you need to use compiler-generated stubs to
> read and write records, but it also supports schemas. You can
> de/serialize schemas separately from content, which gives you lots of
> flexibility.
>
>> -----Original Message-----
>> From: Bryan Duxbury [mailto:bryan@rapleaf.com]
>> Sent: Saturday, May 24, 2008 12:13 AM
>> To: core-user@hadoop.apache.org
>> Subject: Re: Serialization format for structured data
>>
>>
>> On May 23, 2008, at 9:51 AM, Ted Dunning wrote:
>> > Relative to thrift, JSON has the advantage of not requiring
>> a schema
>> > as well as the disadvantage of not having a schema.  The
>> advantage is
>> > that the data is more fluid and I don't have to generate code to
>> > handle the records.  The disadvantage is that I lose some data
>> > completeness and typing guarantees.
>> > On balance, I would like to use JSON-like data quite a bit
>> in ad hoc
>> > data streams and in logs where the producer and consumer of
>> the data
>> > are not visible to parts of the data processing chain.
>>
>> That about sums it up. If you want schema, Thrift is your
>> friend. If you don't, JSON probably will do pretty well for you.
>>
>> -Bryan
>>
>

RE: Serialization format for structured data

Posted by Vivek Ratan <vi...@yahoo-inc.com>.
Am joining the conversation late, but another option is is Hadoop's own
RecordIO. Like with Thrift, you need to use compiler-generated stubs to
read and write records, but it also supports schemas. You can
de/serialize schemas separately from content, which gives you lots of
flexibility. 

> -----Original Message-----
> From: Bryan Duxbury [mailto:bryan@rapleaf.com] 
> Sent: Saturday, May 24, 2008 12:13 AM
> To: core-user@hadoop.apache.org
> Subject: Re: Serialization format for structured data
> 
> 
> On May 23, 2008, at 9:51 AM, Ted Dunning wrote:
> > Relative to thrift, JSON has the advantage of not requiring 
> a schema 
> > as well as the disadvantage of not having a schema.  The 
> advantage is 
> > that the data is more fluid and I don't have to generate code to 
> > handle the records.  The disadvantage is that I lose some data 
> > completeness and typing guarantees.
> > On balance, I would like to use JSON-like data quite a bit 
> in ad hoc 
> > data streams and in logs where the producer and consumer of 
> the data 
> > are not visible to parts of the data processing chain.
> 
> That about sums it up. If you want schema, Thrift is your 
> friend. If you don't, JSON probably will do pretty well for you.
> 
> -Bryan
> 

Re: Serialization format for structured data

Posted by Bryan Duxbury <br...@rapleaf.com>.
On May 23, 2008, at 9:51 AM, Ted Dunning wrote:
> Relative to thrift, JSON has the advantage of not requiring a  
> schema as well
> as the disadvantage of not having a schema.  The advantage is that  
> the data
> is more fluid and I don't have to generate code to handle the  
> records.  The
> disadvantage is that I lose some data completeness and typing  
> guarantees.
> On balance, I would like to use JSON-like data quite a bit in ad  
> hoc data
> streams and in logs where the producer and consumer of the data are  
> not
> visible to parts of the data processing chain.

That about sums it up. If you want schema, Thrift is your friend. If  
you don't, JSON probably will do pretty well for you.

-Bryan

Re: Serialization format for structured data

Posted by Steve Loughran <st...@apache.org>.
Ted Dunning wrote:
> I asked because the IBM guys have some code to be released soon that will
> address some of these issues.
> 
> In particular, Kevin Breyer was at the HUG and we talked a bit about their
> format.  Some important characteristics are:
> 
> - it is pretty much a binary JSON implementation
> 
> - value parsing doesn't happen because it is a binary format.  That means
> that integers, doubles and dates can be read much more quickly.
> 
> - names are repeated in the data just as in JSON, but are easily compressed
> away with any compression technique you care to use.
> 
> - he says it is fast, but I haven't tried it yet.
> 
> So this will address the first point very directly, will indirectly address
> the second point, and the third point may be FUD.
> 
> Relative to thrift, JSON has the advantage of not requiring a schema as well
> as the disadvantage of not having a schema.  The advantage is that the data
> is more fluid and I don't have to generate code to handle the records.  The
> disadvantage is that I lose some data completeness and typing guarantees.
> On balance, I would like to use JSON-like data quite a bit in ad hoc data
> streams and in logs where the producer and consumer of the data are not
> visible to parts of the data processing chain.
> 

For some reason I'm reminded of all the binary-SOAP-fixes-your-problems 
stories. I will wait and see what comes out, but given my experiences of 
SOAP, I'm already nervous. I just hope we dont see WSDL-for-JSON or 
something similar.

Re: Serialization format for structured data

Posted by Ted Dunning <td...@veoh.com>.
I asked because the IBM guys have some code to be released soon that will
address some of these issues.

In particular, Kevin Breyer was at the HUG and we talked a bit about their
format.  Some important characteristics are:

- it is pretty much a binary JSON implementation

- value parsing doesn't happen because it is a binary format.  That means
that integers, doubles and dates can be read much more quickly.

- names are repeated in the data just as in JSON, but are easily compressed
away with any compression technique you care to use.

- he says it is fast, but I haven't tried it yet.

So this will address the first point very directly, will indirectly address
the second point, and the third point may be FUD.

Relative to thrift, JSON has the advantage of not requiring a schema as well
as the disadvantage of not having a schema.  The advantage is that the data
is more fluid and I don't have to generate code to handle the records.  The
disadvantage is that I lose some data completeness and typing guarantees.
On balance, I would like to use JSON-like data quite a bit in ad hoc data
streams and in logs where the producer and consumer of the data are not
visible to parts of the data processing chain.

I am very excited to see the IBM code.

On 5/23/08 6:37 AM, "Stuart Sierra" <ma...@stuartsierra.com> wrote:

> On 5/22/08 1:54 PM, "Stuart Sierra" <ma...@stuartsierra.com> wrote:
>> I've tried using JSON to store structured data in TextOutputFormat,
>> which works but is not very efficient.  Any better suggestions?
> 
> On Thu, May 22, 2008 at 5:21 PM, Ted Dunning <td...@veoh.com> wrote:
>> What is it that makes you not think JSON has to be inefficient?
>> ? Repeated value parsing ?
>> ? Redundant redundant data labels ?
>> ? Generic "parsing must be slow" prejudice ?
> 
> All three :) but it's not a strong prejudice.  I was just wondering if
> there's a better way.  Is it worthwhile, for example, to write my own
> record class that implements Writable?
> 
> -Stuart


Re: Serialization format for structured data

Posted by Stuart Sierra <ma...@stuartsierra.com>.
On 5/22/08 1:54 PM, "Stuart Sierra" <ma...@stuartsierra.com> wrote:
> I've tried using JSON to store structured data in TextOutputFormat,
> which works but is not very efficient.  Any better suggestions?

On Thu, May 22, 2008 at 5:21 PM, Ted Dunning <td...@veoh.com> wrote:
> What is it that makes you not think JSON has to be inefficient?
> ? Repeated value parsing ?
> ? Redundant redundant data labels ?
> ? Generic "parsing must be slow" prejudice ?

All three :) but it's not a strong prejudice.  I was just wondering if
there's a better way.  Is it worthwhile, for example, to write my own
record class that implements Writable?

-Stuart

Re: Serialization format for structured data

Posted by Ted Dunning <td...@veoh.com>.
What is it that makes you not think JSON has to be inefficient?

? Repeated value parsing ?

? Redundant redundant data labels ?

? Generic "parsing must be slow" prejudice ?


On 5/22/08 1:54 PM, "Stuart Sierra" <ma...@stuartsierra.com> wrote:

> Hello, I'm still getting my head around how Hadoop works.  A survey
> question: what kind of serialization do you use to output structured
> data from your map/reduce jobs?
> 
> When both key and value are primitive types, either TextOutputFormat
> or SequenceFileOutputFormat is easy.  But what if you want to store a
> more complex data structure as the value?
> 
> By "complex data structure," I mean some combination of lists/arrays,
> dictionaries/hashes, and primitives (int, float, string, boolean,
> null).
> 
> I've tried using JSON to store structured data in TextOutputFormat,
> which works but is not very efficient.  Any better suggestions?
> 
> Thanks, all,
> -Stuart