Advertisement
Guest User

Hbase table split

a guest
Jun 12th, 2012
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. import org.apache.commons.lang.ArrayUtils;
  2. import org.apache.hadoop.hbase.util.Bytes;
  3.  
  4. public class RegionSplitTool {
  5.    
  6.     public static void main(String[] args) {
  7.         int numRegions = 32;
  8.         int keylength = 1;
  9.         byte[] end = new byte[keylength];
  10.         end[0] = (byte) 0xFF;
  11.        
  12.         byte[][] split = split(ArrayUtils.EMPTY_BYTE_ARRAY, end, numRegions);
  13.         for (byte[] cs : split) {
  14.             System.out.println(Bytes.toStringBinary(cs));
  15.         }
  16.     }
  17.  
  18.     public static byte[][] split(byte[] firstRowBytes, byte[] lastRowBytes, int numRegions) {
  19.         byte[][] splitKeysPlusEndpoints = Bytes.split(firstRowBytes, lastRowBytes, numRegions - 1);
  20.         byte[][] splitAtKeys = new byte[splitKeysPlusEndpoints.length - 2][];
  21.         System.arraycopy(splitKeysPlusEndpoints, 1, splitAtKeys, 0, splitKeysPlusEndpoints.length - 2);
  22.         return splitAtKeys;
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement