Thanks Dave!
It really makes sense. It all depends on how you want to process the data
later.

I guess I'm going to persist the Map instead of a String to leverage the
filters having to parse the JSON.

Pablo




On Mon, Jan 31, 2011 at 5:20 PM, Buttler, David <[email protected]> wrote:

> How you serialize your objects to hbase depends on how you want to use your
> objects later.  Assuming that you have a good serialization to json already,
> and all you want to do is put and get the items, then just convert your json
> string to a byte array and put it in a column qualifier (e.g. Table name:
> 'Person'; Column Family name: 'a'; Column Qualifier name: 'json').
>
> However, if you want to scan your table and only pull out rows with certain
> attribute conditions (say, person names starting with 'A'), you may want to
> push the filter to the server and not have to pull out every single json
> object to your client, deserialize it, and then check the condition.  In
> that case, you may want to have each of your objects fields be a Column
> Qualifier (maybe in addition to the json, maybe as an alternative
> serialization).
>
> Does that make sense?
> Dave
>
>
> -----Original Message-----
> From: Pablo Molnar [mailto:[email protected]]
> Sent: Monday, January 31, 2011 12:09 PM
> To: [email protected]
> Subject: Re: Persist JSON into HBase
>
> Thanks for the feedback Stack!
> So you suggest to just serialize the JSON represent as a String or as a
> Map?
>
>
> Something like this:
>
> (supposing item is a String or a Map)
>
> Put row = new Put(Bytes.toBytes(item.id))
> row.add(Bytes.toBytes("json"), Bytes.toBytes("1"), Bytes.toBytes(item))
> table.put(row)
>
> What should I use as qualifier in this case?
> Is this way the json efficiently persisted?
> HBase does not offer a Map serializer? Should I use
> myObjectOutputStream.writeObject(map) ?
>
> Thanks again,
> Pablo
>
>
> On Mon, Jan 31, 2011 at 4:48 PM, Stack <[email protected]> wrote:
>
> > Don't use MapWritable.
> >
> > In the layer above HBase, inside whatever is hosting the HBase client,
> > serialize the JSON to bytes and then write that to an HBase cell.  In
> > the same layer, reading, do the deserializations.
> >
> > HBase only does byte arrays.
> >
> > St.Ack
> >
> >
> > On Mon, Jan 31, 2011 at 11:30 AM, Pablo Molnar <[email protected]>
> > wrote:
> > > Hi everyone,
> > >
> > > In my company we are experimenting with HBase and I'd like to know the
> > best
> > > way to persist a semi-structured complex (3 levels) entity represented
> as
> > > JSON to HBase.
> > > I've already done successfully a Java client that persist rows in a
> table
> > > and now my target is persist this JSON.
> > >
> > > I've looked through the api and found a MapWritable class that could be
> > > usefull because for me is very easy to convert the JSON enitity into a
> > Map
> > > and then persist it.
> > >
> > > I really appreciate some example how I could implement this
> > > If this is possible my next concerns would be how about if I want to
> > create
> > > and index by a key (of the Map)?
> > >
> > > Thanks in advance,
> > > Pablo Molnar
> > >
> >
>

Reply via email to