Friday, January 9, 2015

Major compact an row key in HBase

Getting an row key via hbase-shell per scan:
hbase (main):0001:0 > scan ‘your_table',{LIMIT => 5}

see what the row contains:
hbase (main):0002:0 > get ‘your_table’,"\x00\x01"

To start the compaction based on the row key use this few lines and replace <row_key> and <your_table> with the findings above:
hbase (main):0003:0 > configuration = org.apache.hadoop.hbase.HBaseConfiguration.create table =, '<your_table>') regionLocation = table.getRegionLocation("<row key>”) regionLocation.getRegionInfo().getRegionName() admin = admin.majorCompact(regionLocation.getRegionInfo().getRegionName())