Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

HBASE INSERT json

Solved Go to solution

HBASE INSERT json

Super 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

Accepted Solutions
Highlighted

Re: HBASE INSERT json

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
Highlighted

Re: HBASE INSERT json

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

Highlighted

Re: HBASE INSERT json

Super Collaborator

Hi;

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

Highlighted

Re: HBASE INSERT json

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.

Highlighted

Re: HBASE INSERT json

Super Collaborator

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

and what about autoincrement id row from pig'

Highlighted

Re: HBASE INSERT json

Mentor

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

Don't have an account?
Coming from Hortonworks? Activate your account here