Support Questions

Find answers, ask questions, and share your expertise

mapreduce job to update rowkeys in hbase table

New Contributor

I need to update an hbase table to update the row_keys to include a random prefix between 0 and 10. I was told the best way would be to do a mapreduce job which will be quicker but am unfamiliar with pig, hive etc.

So if I cannot update the rowkey itself then I would need to copy the data over to a new table and create the new key if it doesn't have a prefix. Could someone please assist with the best way to script this out?

 

hbase org.apache.hadoop.hbase.mapreduce.CopyTable \
-Dmapreduce.job.queuename=test \
--starttime=1591298402000 \
--peer.adr=hbase-development.local.net:2181:/hbase-unsecure \
--new.name=customers_dev:customers_prod_keys \
customers_prod:customers_prod_keys

 

So instead of starttime I would like to have records created before a time and those that do not have a prefix like this:

 

10_BestBuy_987654321
Target_123456

So find the second type and update like the first.

3 REPLIES 3

New Contributor

@JoeSmo wrote:

I need to update an hbase table to update the row_keys to include a random prefix between 0 and 10. I was told the best way would be to do a mapreduce job which will be quicker but am unfamiliar with pig, hive etc.

So if I cannot update the rowkey itself then I would need to copy the data over to a new table and create the new key if it doesn't have a prefix. Could someone please assist with the best way to script this out? MySubwayCard

 

 

hbase org.apache.hadoop.hbase.mapreduce.CopyTable \
-Dmapreduce.job.queuename=test \
--starttime=1591298402000 \
--peer.adr=hbase-development.local.net:2181:/hbase-unsecure \
--new.name=customers_dev:customers_prod_keys \
customers_prod:customers_prod_keys

 

 

So instead of starttime I would like to have records created before a time and those that do not have a prefix like this:

 

 

10_BestBuy_987654321
Target_123456

 

So find the second type and update like the first.


I think below steps helps you,

 

  1. Step 1: Instantiate the Configuration Class. Configuration class adds HBase configuration files to its object. ...
  2. Step 2: Instantiate the HTable Class. ...
  3. Step 3: Instantiate the Put Class. ...
  4. Step 4: Update an Existing Cell. ...
  5. Step 5: Save the Data in Table. ...
  6. Step 6: Close HTable Instance.

New Contributor

Sounds like the best way to do this is in java - perhaps?

New Contributor

it could be as far as I know

jigsaw puzzle

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.