Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

HBASE INSERT json

avatar
Master Collaborator

Hi:

I need to insert every day 1 json into HBASE, there are any api to do it without schema???

Also i dont want to use HIVE.

Thanks

1 ACCEPTED SOLUTION

avatar
Master Mentor

you can treat each json as string then in HBase you would do the following where line is a json string. Full example here https://github.com/dbist/workshops/blob/master/hbase/HBaseJsonLoad/src/main/java/com/hortonworks/hba...

p.addColumn(CF, Bytes.toBytes("json"), Bytes.toBytes(line));

View solution in original post

5 REPLIES 5

avatar
Master Mentor

you can treat each json as string then in HBase you would do the following where line is a json string. Full example here https://github.com/dbist/workshops/blob/master/hbase/HBaseJsonLoad/src/main/java/com/hortonworks/hba...

p.addColumn(CF, Bytes.toBytes("json"), Bytes.toBytes(line));

avatar
Master Collaborator

Hi;

thanks, and them how can i get some keys from the json???

avatar
Master Mentor

You read the string, convert it up json obj and read it. Look at my example how I read the key to make it a row key, you will do the same after calling a Get.

avatar
Master Collaborator

Ok, thanks i saw the code, you are right,

and what about autoincrement id row from pig'

avatar
Master Mentor

I see you asked this question in a separate thread, that's the right approach to keep them separate.