HBase does not support row key renaming

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

As far as I know, in HBase, the key of the row can not be changed. But if you really need a row key rename function, the best thing to do is to copy all the data one row to another row in HBase using JAVA.

e.g. I have existing row with key “key1”, and I want to create a row with key “key2” copied from “key1” row. It is simple:

 // lets say your already got the result from table.get(Bytes.toBytes("key1")) 
Put put = new Put(Bytes.toBytes("key2")); 
NavigableMap> familyQualifierMap = result.getNoVersionMap(); 
for (byte[] familyBytes : familyQualifierMap.keySet()) {
 NavigableMap qualifierMap = familyQualifierMap.get(familyBytes); 
for (byte[] qualifier : qualifierMap.keySet()) {
 put.add(familyBytes, qualifier, qualifierMap.get(qualifier)); } } 
table.put(put); 
table.flushCommits(); 
table.close();

Leave a Reply

Your email address will not be published. Required fields are marked *