org.apache.hadoop.hbase.util
Class RegionSplitter.HexStringSplit

java.lang.Object
  extended by org.apache.hadoop.hbase.util.RegionSplitter.HexStringSplit
All Implemented Interfaces:
RegionSplitter.SplitAlgorithm
Enclosing class:
RegionSplitter

public static class RegionSplitter.HexStringSplit
extends Object
implements RegionSplitter.SplitAlgorithm

HexStringSplit is a well-known RegionSplitter.SplitAlgorithm for choosing region boundaries. The format of a HexStringSplit region boundary is the ASCII representation of an MD5 checksum, or any other uniformly distributed hexadecimal value. Row are hex-encoded long values in the range "00000000" => "FFFFFFFF" and are left-padded with zeros to keep the same order lexicographically as if they were binary. Since this split algorithm uses hex strings as keys, it is easy to read & write in the shell but takes up more space and may be non-intuitive.


Constructor Summary
RegionSplitter.HexStringSplit()
           
 
Method Summary
 BigInteger convertToBigInteger(byte[] row)
          Returns the BigInteger represented by the byte array
 byte[] convertToByte(BigInteger bigInteger)
          Returns the bytes corresponding to the BigInteger
static byte[] convertToByte(BigInteger bigInteger, int pad)
          Returns the bytes corresponding to the BigInteger
 byte[][] convertToBytes(BigInteger[] bigIntegers)
          Returns an array of bytes corresponding to an array of BigIntegers
 byte[] firstRow()
          In HBase, the first row is represented by an empty byte array.
 byte[] lastRow()
          In HBase, the last row is represented by an empty byte array.
 String rowToStr(byte[] row)
           
 String separator()
           
 void setFirstRow(byte[] userInput)
          Set the first row
 void setFirstRow(String userInput)
          In HBase, the last row is represented by an empty byte array.
 void setLastRow(byte[] userInput)
          Set the last row
 void setLastRow(String userInput)
          In HBase, the last row is represented by an empty byte array.
 byte[] split(byte[] start, byte[] end)
          Split a pre-existing region into 2 regions.
 byte[][] split(int n)
          Split an entire table.
 BigInteger split2(BigInteger a, BigInteger b)
          Divide 2 numbers in half (for split algorithm)
 byte[] strToRow(String in)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RegionSplitter.HexStringSplit

public RegionSplitter.HexStringSplit()
Method Detail

split

public byte[] split(byte[] start,
                    byte[] end)
Description copied from interface: RegionSplitter.SplitAlgorithm
Split a pre-existing region into 2 regions.

Specified by:
split in interface RegionSplitter.SplitAlgorithm
Parameters:
start - first row (inclusive)
end - last row (exclusive)
Returns:
the split row to use

split

public byte[][] split(int n)
Description copied from interface: RegionSplitter.SplitAlgorithm
Split an entire table.

Specified by:
split in interface RegionSplitter.SplitAlgorithm
Parameters:
n - number of regions to split the table into
Returns:
array of split keys for the initial regions of the table. The length of the returned array should be numRegions-1.

firstRow

public byte[] firstRow()
Description copied from interface: RegionSplitter.SplitAlgorithm
In HBase, the first row is represented by an empty byte array. This might cause problems with your split algorithm or row printing. All your APIs will be passed firstRow() instead of empty array.

Specified by:
firstRow in interface RegionSplitter.SplitAlgorithm
Returns:
your representation of your first row

lastRow

public byte[] lastRow()
Description copied from interface: RegionSplitter.SplitAlgorithm
In HBase, the last row is represented by an empty byte array. This might cause problems with your split algorithm or row printing. All your APIs will be passed firstRow() instead of empty array.

Specified by:
lastRow in interface RegionSplitter.SplitAlgorithm
Returns:
your representation of your last row

setFirstRow

public void setFirstRow(String userInput)
Description copied from interface: RegionSplitter.SplitAlgorithm
In HBase, the last row is represented by an empty byte array. Set this value to help the split code understand how to evenly divide the first region.

Specified by:
setFirstRow in interface RegionSplitter.SplitAlgorithm
Parameters:
userInput - raw user input (may throw RuntimeException on parse failure)

setLastRow

public void setLastRow(String userInput)
Description copied from interface: RegionSplitter.SplitAlgorithm
In HBase, the last row is represented by an empty byte array. Set this value to help the split code understand how to evenly divide the last region. Note that this last row is inclusive for all rows sharing the same prefix.

Specified by:
setLastRow in interface RegionSplitter.SplitAlgorithm
Parameters:
userInput - raw user input (may throw RuntimeException on parse failure)

strToRow

public byte[] strToRow(String in)
Specified by:
strToRow in interface RegionSplitter.SplitAlgorithm
Parameters:
in - user or file input for row
Returns:
byte array representation of this row for HBase

rowToStr

public String rowToStr(byte[] row)
Specified by:
rowToStr in interface RegionSplitter.SplitAlgorithm
Parameters:
row - byte array representing a row in HBase
Returns:
String to use for debug & file printing

separator

public String separator()
Specified by:
separator in interface RegionSplitter.SplitAlgorithm
Returns:
the separator character to use when storing / printing the row

setFirstRow

public void setFirstRow(byte[] userInput)
Description copied from interface: RegionSplitter.SplitAlgorithm
Set the first row

Specified by:
setFirstRow in interface RegionSplitter.SplitAlgorithm
Parameters:
userInput - byte array of the row key.

setLastRow

public void setLastRow(byte[] userInput)
Description copied from interface: RegionSplitter.SplitAlgorithm
Set the last row

Specified by:
setLastRow in interface RegionSplitter.SplitAlgorithm
Parameters:
userInput - byte array of the row key.

split2

public BigInteger split2(BigInteger a,
                         BigInteger b)
Divide 2 numbers in half (for split algorithm)

Parameters:
a - number #1
b - number #2
Returns:
the midpoint of the 2 numbers

convertToBytes

public byte[][] convertToBytes(BigInteger[] bigIntegers)
Returns an array of bytes corresponding to an array of BigIntegers

Parameters:
bigIntegers - numbers to convert
Returns:
bytes corresponding to the bigIntegers

convertToByte

public static byte[] convertToByte(BigInteger bigInteger,
                                   int pad)
Returns the bytes corresponding to the BigInteger

Parameters:
bigInteger - number to convert
pad - padding length
Returns:
byte corresponding to input BigInteger

convertToByte

public byte[] convertToByte(BigInteger bigInteger)
Returns the bytes corresponding to the BigInteger

Parameters:
bigInteger - number to convert
Returns:
corresponding bytes

convertToBigInteger

public BigInteger convertToBigInteger(byte[] row)
Returns the BigInteger represented by the byte array

Parameters:
row - byte array representing row
Returns:
the corresponding BigInteger

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2007-2016 The Apache Software Foundation. All Rights Reserved.