org.apache.hadoop.hbase
Class HRegionInfo

java.lang.Object
  extended by org.apache.hadoop.io.VersionedWritable
      extended by org.apache.hadoop.hbase.HRegionInfo
All Implemented Interfaces:
Comparable<HRegionInfo>, org.apache.hadoop.io.Writable, org.apache.hadoop.io.WritableComparable<HRegionInfo>

public class HRegionInfo
extends org.apache.hadoop.io.VersionedWritable
implements org.apache.hadoop.io.WritableComparable<HRegionInfo>

HRegion information. Contains HRegion id, start and end keys, a reference to this HRegions' table descriptor, etc.


Field Summary
static int DELIMITER
          delimiter used between portions of a region name
static String ENCODED_REGION_NAME_REGEX
          A non-capture group so that this can be embedded.
static HRegionInfo FIRST_META_REGIONINFO
          HRegionInfo for first meta region
static int MD5_HEX_LENGTH
           
static String NO_HASH
           
static HRegionInfo ROOT_REGIONINFO
          HRegionInfo for root region
static byte VERSION
           
static byte VERSION_PRE_092
           
 
Constructor Summary
HRegionInfo()
          Default constructor - creates empty object
HRegionInfo(byte[] tableName)
           
HRegionInfo(byte[] tableName, byte[] startKey, byte[] endKey)
          Construct HRegionInfo with explicit parameters
HRegionInfo(byte[] tableName, byte[] startKey, byte[] endKey, boolean split)
          Construct HRegionInfo with explicit parameters
HRegionInfo(byte[] tableName, byte[] startKey, byte[] endKey, boolean split, long regionid)
          Construct HRegionInfo with explicit parameters
HRegionInfo(HRegionInfo other)
          Costruct a copy of another HRegionInfo
HRegionInfo(HRegionInfo090x other)
          Used only for migration
 
Method Summary
 int compareTo(HRegionInfo o)
           
 boolean containsRange(byte[] rangeStartKey, byte[] rangeEndKey)
          Returns true if the given inclusive range of rows is fully contained by this region.
 boolean containsRow(byte[] row)
          Return true if the given row falls in this region.
static byte[] createRegionName(byte[] tableName, byte[] startKey, byte[] id, boolean newFormat)
          Make a region name of passed parameters.
static byte[] createRegionName(byte[] tableName, byte[] startKey, long regionid, boolean newFormat)
          Make a region name of passed parameters.
static byte[] createRegionName(byte[] tableName, byte[] startKey, String id, boolean newFormat)
          Make a region name of passed parameters.
static String encodeRegionName(byte[] regionName)
           
 boolean equals(Object o)
           
 KeyValue.KVComparator getComparator()
           
 String getEncodedName()
           
 byte[] getEncodedNameAsBytes()
           
 byte[] getEndKey()
           
 long getRegionId()
           
 byte[] getRegionName()
           
 String getRegionNameAsString()
           
 byte[] getStartKey()
           
static byte[] getStartKey(byte[] regionName)
          Gets the start key from the specified region name.
 HTableDescriptor getTableDesc()
          Deprecated. Do not use; expensive call use HRegionInfo.getTableNameAsString() in place of HRegionInfo.getTableDesc().getNameAsString()
 byte[] getTableName()
          Get current table name of the region
static byte[] getTableName(byte[] regionName)
          Gets the table name from the specified region name.
 String getTableNameAsString()
          Get current table name as string
 byte getVersion()
           
 int hashCode()
           
 boolean isMetaRegion()
           
 boolean isMetaTable()
           
 boolean isOffline()
           
 boolean isRootRegion()
           
 boolean isSplit()
           
 boolean isSplitParent()
           
static byte[][] parseRegionName(byte[] regionName)
          Separate elements of a regionName.
static String prettyPrint(String encodedRegionName)
          Use logging.
 void readFields(DataInput in)
           
 void setOffline(boolean offLine)
          The parent of a region split is offline while split daughters hold references to the parent.
 void setSplit(boolean split)
           
 void setTableDesc(HTableDescriptor newDesc)
          Deprecated. Do not use; expensive call
 String toString()
           
 void write(DataOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

VERSION_PRE_092

public static final byte VERSION_PRE_092
See Also:
Constant Field Values

VERSION

public static final byte VERSION
See Also:
Constant Field Values

MD5_HEX_LENGTH

public static final int MD5_HEX_LENGTH
See Also:
Constant Field Values

ENCODED_REGION_NAME_REGEX

public static final String ENCODED_REGION_NAME_REGEX
A non-capture group so that this can be embedded.

See Also:
Constant Field Values

DELIMITER

public static final int DELIMITER
delimiter used between portions of a region name

See Also:
Constant Field Values

ROOT_REGIONINFO

public static final HRegionInfo ROOT_REGIONINFO
HRegionInfo for root region


FIRST_META_REGIONINFO

public static final HRegionInfo FIRST_META_REGIONINFO
HRegionInfo for first meta region


NO_HASH

public static final String NO_HASH
Constructor Detail

HRegionInfo

public HRegionInfo()
Default constructor - creates empty object


HRegionInfo

public HRegionInfo(HRegionInfo090x other)
Used only for migration

Parameters:
other - HRegionInfoForMigration

HRegionInfo

public HRegionInfo(byte[] tableName)

HRegionInfo

public HRegionInfo(byte[] tableName,
                   byte[] startKey,
                   byte[] endKey)
            throws IllegalArgumentException
Construct HRegionInfo with explicit parameters

Parameters:
tableName - the table name
startKey - first key in region
endKey - end of key range
Throws:
IllegalArgumentException

HRegionInfo

public HRegionInfo(byte[] tableName,
                   byte[] startKey,
                   byte[] endKey,
                   boolean split)
            throws IllegalArgumentException
Construct HRegionInfo with explicit parameters

Parameters:
tableName - the table descriptor
startKey - first key in region
endKey - end of key range
split - true if this region has split and we have daughter regions regions that may or may not hold references to this region.
Throws:
IllegalArgumentException

HRegionInfo

public HRegionInfo(byte[] tableName,
                   byte[] startKey,
                   byte[] endKey,
                   boolean split,
                   long regionid)
            throws IllegalArgumentException
Construct HRegionInfo with explicit parameters

Parameters:
tableName - the table descriptor
startKey - first key in region
endKey - end of key range
split - true if this region has split and we have daughter regions regions that may or may not hold references to this region.
regionid - Region id to use.
Throws:
IllegalArgumentException

HRegionInfo

public HRegionInfo(HRegionInfo other)
Costruct a copy of another HRegionInfo

Parameters:
other -
Method Detail

encodeRegionName

public static String encodeRegionName(byte[] regionName)
Parameters:
regionName -
Returns:
the encodedName

prettyPrint

public static String prettyPrint(String encodedRegionName)
Use logging.

Parameters:
encodedRegionName - The encoded regionname.
Returns:
-ROOT- if passed 70236052 or .META. if passed 1028785192 else returns encodedRegionName

createRegionName

public static byte[] createRegionName(byte[] tableName,
                                      byte[] startKey,
                                      long regionid,
                                      boolean newFormat)
Make a region name of passed parameters.

Parameters:
tableName -
startKey - Can be null
regionid - Region id (Usually timestamp from when region was created).
newFormat - should we create the region name in the new format (such that it contains its encoded name?).
Returns:
Region name made of passed tableName, startKey and id

createRegionName

public static byte[] createRegionName(byte[] tableName,
                                      byte[] startKey,
                                      String id,
                                      boolean newFormat)
Make a region name of passed parameters.

Parameters:
tableName -
startKey - Can be null
id - Region id (Usually timestamp from when region was created).
newFormat - should we create the region name in the new format (such that it contains its encoded name?).
Returns:
Region name made of passed tableName, startKey and id

createRegionName

public static byte[] createRegionName(byte[] tableName,
                                      byte[] startKey,
                                      byte[] id,
                                      boolean newFormat)
Make a region name of passed parameters.

Parameters:
tableName -
startKey - Can be null
id - Region id (Usually timestamp from when region was created).
newFormat - should we create the region name in the new format (such that it contains its encoded name?).
Returns:
Region name made of passed tableName, startKey and id

getTableName

public static byte[] getTableName(byte[] regionName)
Gets the table name from the specified region name.

Parameters:
regionName -
Returns:
Table name.

getStartKey

public static byte[] getStartKey(byte[] regionName)
                          throws IOException
Gets the start key from the specified region name.

Parameters:
regionName -
Returns:
Start key.
Throws:
IOException

parseRegionName

public static byte[][] parseRegionName(byte[] regionName)
                                throws IOException
Separate elements of a regionName.

Parameters:
regionName -
Returns:
Array of byte[] containing tableName, startKey and id
Throws:
IOException

getRegionId

public long getRegionId()
Returns:
the regionId

getRegionName

public byte[] getRegionName()
Returns:
the regionName as an array of bytes.
See Also:
getRegionNameAsString()

getRegionNameAsString

public String getRegionNameAsString()
Returns:
Region name as a String for use in logging, etc.

getEncodedName

public String getEncodedName()
Returns:
the encoded region name

getEncodedNameAsBytes

public byte[] getEncodedNameAsBytes()

getStartKey

public byte[] getStartKey()
Returns:
the startKey

getEndKey

public byte[] getEndKey()
Returns:
the endKey

getTableName

public byte[] getTableName()
Get current table name of the region

Returns:
byte array of table name

getTableNameAsString

public String getTableNameAsString()
Get current table name as string

Returns:
string representation of current table

containsRange

public boolean containsRange(byte[] rangeStartKey,
                             byte[] rangeEndKey)
Returns true if the given inclusive range of rows is fully contained by this region. For example, if the region is foo,a,g and this is passed ["b","c"] or ["a","c"] it will return true, but if this is passed ["b","z"] it will return false.

Throws:
IllegalArgumentException - if the range passed is invalid (ie end < start)

containsRow

public boolean containsRow(byte[] row)
Return true if the given row falls in this region.


getTableDesc

@Deprecated
public HTableDescriptor getTableDesc()
Deprecated. Do not use; expensive call use HRegionInfo.getTableNameAsString() in place of HRegionInfo.getTableDesc().getNameAsString()

Returns:
the tableDesc

setTableDesc

@Deprecated
public void setTableDesc(HTableDescriptor newDesc)
Deprecated. Do not use; expensive call

Parameters:
newDesc - new table descriptor to use

isRootRegion

public boolean isRootRegion()
Returns:
true if this is the root region

isMetaTable

public boolean isMetaTable()
Returns:
true if this region is from a table that is a meta table, either .META. or -ROOT-

isMetaRegion

public boolean isMetaRegion()
Returns:
true if this region is a meta region

isSplit

public boolean isSplit()
Returns:
True if has been split and has daughters.

setSplit

public void setSplit(boolean split)
Parameters:
split - set split status

isOffline

public boolean isOffline()
Returns:
True if this region is offline.

setOffline

public void setOffline(boolean offLine)
The parent of a region split is offline while split daughters hold references to the parent. Offlined regions are closed.

Parameters:
offLine - Set online/offline status.

isSplitParent

public boolean isSplitParent()
Returns:
True if this is a split parent region.

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()

equals

public boolean equals(Object o)
Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class Object
See Also:
Object.hashCode()

getVersion

public byte getVersion()
Specified by:
getVersion in class org.apache.hadoop.io.VersionedWritable
Returns:
the object version number

write

public void write(DataOutput out)
           throws IOException
Specified by:
write in interface org.apache.hadoop.io.Writable
Overrides:
write in class org.apache.hadoop.io.VersionedWritable
Throws:
IOException

readFields

public void readFields(DataInput in)
                throws IOException
Specified by:
readFields in interface org.apache.hadoop.io.Writable
Overrides:
readFields in class org.apache.hadoop.io.VersionedWritable
Throws:
IOException

compareTo

public int compareTo(HRegionInfo o)
Specified by:
compareTo in interface Comparable<HRegionInfo>

getComparator

public KeyValue.KVComparator getComparator()
Returns:
Comparator to use comparing KeyValues.


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