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

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

public static class RegionSplitter.UniformSplit
extends java.lang.Object
implements RegionSplitter.SplitAlgorithm

A SplitAlgorithm that divides the space of possible keys evenly. Useful when the keys are approximately uniform random bytes (e.g. hashes). Rows are raw byte values in the range 00 => FF and are right-padded with zeros to keep the same memcmp() order. This is the natural algorithm to use for a byte[] environment and saves space, but is not necessarily the easiest for readability.


Constructor Summary
RegionSplitter.UniformSplit()
           
 
Method Summary
 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.
 java.lang.String rowToStr(byte[] row)
           
 java.lang.String separator()
           
 void setFirstRow(java.lang.String userInput)
          In HBase, the last row is represented by an empty byte array.
 void setLastRow(java.lang.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 numRegions)
          Split an entire table.
 byte[] strToRow(java.lang.String input)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RegionSplitter.UniformSplit

public RegionSplitter.UniformSplit()
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 numRegions)
Description copied from interface: RegionSplitter.SplitAlgorithm
Split an entire table.

Specified by:
split in interface RegionSplitter.SplitAlgorithm
Parameters:
numRegions - 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(java.lang.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(java.lang.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(java.lang.String input)
Specified by:
strToRow in interface RegionSplitter.SplitAlgorithm
Parameters:
input - user or file input for row
Returns:
byte array representation of this row for HBase

rowToStr

public java.lang.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 java.lang.String separator()
Specified by:
separator in interface RegionSplitter.SplitAlgorithm
Returns:
the separator character to use when storing / printing the row

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.