org.apache.hadoop.hbase
Class HStoreKey

java.lang.Object
  extended by org.apache.hadoop.hbase.HStoreKey
All Implemented Interfaces:
Comparable<HStoreKey>, HeapSize, org.apache.hadoop.io.Writable, org.apache.hadoop.io.WritableComparable<HStoreKey>
Direct Known Subclasses:
HStoreKey.BeforeThisStoreKey

public class HStoreKey
extends Object
implements org.apache.hadoop.io.WritableComparable<HStoreKey>, HeapSize

A Key for a stored row.


Nested Class Summary
static class HStoreKey.BeforeThisStoreKey
          Pass this class into MapFile.getClosest when searching for the key that comes BEFORE this one but NOT this one.
static class HStoreKey.HStoreKeyWritableComparator
          Passed as comparator for memcache and for store files.
 
Field Summary
static char COLUMN_FAMILY_DELIMITER
          Colon character in UTF-8
static int ESTIMATED_HEAP_TAX
          Estimated size tax paid for each instance of HSK.
 
Constructor Summary
HStoreKey()
          Default constructor used in conjunction with Writable interface
HStoreKey(byte[] row)
          Create an HStoreKey specifying only the row The column defaults to the empty string, the time stamp defaults to Long.MAX_VALUE and the table defaults to empty string
HStoreKey(byte[] row, byte[] column)
          Create an HStoreKey specifying the row and column names The timestamp defaults to LATEST_TIMESTAMP and table name defaults to the empty string
HStoreKey(byte[] row, byte[] column, HRegionInfo regionInfo)
          Create an HStoreKey specifying the row, column names and table name The timestamp defaults to LATEST_TIMESTAMP
HStoreKey(byte[] row, byte[] column, long timestamp)
          Create an HStoreKey specifying all the fields with unspecified table Does not make copies of the passed byte arrays.
HStoreKey(byte[] row, byte[] column, long timestamp, HRegionInfo regionInfo)
          Create an HStoreKey specifying all the fields with specified table Does not make copies of the passed byte arrays.
HStoreKey(byte[] row, HRegionInfo hri)
          Create an HStoreKey specifying the row and timestamp The column and table names default to the empty string
HStoreKey(byte[] row, long timestamp)
          Create an HStoreKey specifying the row and timestamp The column and table names default to the empty string
HStoreKey(byte[] row, long timestamp, HRegionInfo hri)
          Create an HStoreKey specifying the row and timestamp The column and table names default to the empty string
HStoreKey(HStoreKey other)
          Constructs a new HStoreKey from another
HStoreKey(String row)
          Create an HStoreKey specifying only the row The column defaults to the empty string, the time stamp defaults to Long.MAX_VALUE and the table defaults to empty string
HStoreKey(String row, long timestamp)
          Create an HStoreKey specifying the row and timestamp The column and table names default to the empty string
HStoreKey(String row, String column)
          Create an HStoreKey specifying the row and column names The timestamp defaults to LATEST_TIMESTAMP and table name defaults to the empty string
HStoreKey(String row, String column, long timestamp, HRegionInfo regionInfo)
          Create an HStoreKey specifying all the fields Does not make copies of the passed byte arrays.
 
Method Summary
static byte[] addDelimiter(byte[] family)
           
 int compareTo(HStoreKey o)
           
static int compareTwoRowKeys(HRegionInfo regionInfo, byte[] rowA, byte[] rowB)
          Utility method to compare two row keys.
 boolean equals(Object obj)
           
static boolean equalsTwoRowKeys(HRegionInfo regionInfo, byte[] rowA, byte[] rowB)
          Utility method to check if two row keys are equal.
static byte[] getBytes(HStoreKey hsk)
          Returns row and column bytes out of an HStoreKey.
 byte[] getColumn()
           
static byte[] getFamily(byte[] column)
           
static int getFamilyDelimiterIndex(byte[] b)
           
static Integer getFamilyMapKey(byte[] column)
           
 HRegionInfo getHRegionInfo()
           
static byte[] getQualifier(byte[] column)
           
 byte[] getRow()
           
 long getTimestamp()
           
 int hashCode()
           
 long heapSize()
           
 boolean matchesRowCol(HStoreKey other)
          Compares the row and column of two keys
 boolean matchesRowFamily(HStoreKey that)
          Compares the row and column family of two keys
 boolean matchesWithoutColumn(HStoreKey other)
          Compares the row and timestamp of two keys
static boolean matchingFamily(byte[] family, byte[] column)
           
static byte[][] parseColumn(byte[] c)
           
 void readFields(DataInput in)
           
 void set(HStoreKey k)
          Set the value of this HStoreKey from the supplied key
 void setColumn(byte[] c)
          Change the value of the column in this key
 void setHRegionInfo(HRegionInfo hri)
           
 void setRow(byte[] newrow)
          Change the value of the row key
 void setVersion(long timestamp)
          Change the value of the timestamp field
 String toString()
           
 void write(DataOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

COLUMN_FAMILY_DELIMITER

public static final char COLUMN_FAMILY_DELIMITER
Colon character in UTF-8

See Also:
Constant Field Values

ESTIMATED_HEAP_TAX

public static final int ESTIMATED_HEAP_TAX
Estimated size tax paid for each instance of HSK. Estimate based on study of jhat and jprofiler numbers.

See Also:
Constant Field Values
Constructor Detail

HStoreKey

public HStoreKey()
Default constructor used in conjunction with Writable interface


HStoreKey

public HStoreKey(byte[] row)
Create an HStoreKey specifying only the row The column defaults to the empty string, the time stamp defaults to Long.MAX_VALUE and the table defaults to empty string

Parameters:
row - - row key

HStoreKey

public HStoreKey(String row)
Create an HStoreKey specifying only the row The column defaults to the empty string, the time stamp defaults to Long.MAX_VALUE and the table defaults to empty string

Parameters:
row - - row key

HStoreKey

public HStoreKey(byte[] row,
                 HRegionInfo hri)
Create an HStoreKey specifying the row and timestamp The column and table names default to the empty string

Parameters:
row - row key
hri -

HStoreKey

public HStoreKey(byte[] row,
                 long timestamp,
                 HRegionInfo hri)
Create an HStoreKey specifying the row and timestamp The column and table names default to the empty string

Parameters:
row - row key
timestamp - timestamp value
hri - HRegionInfo

HStoreKey

public HStoreKey(byte[] row,
                 long timestamp)
Create an HStoreKey specifying the row and timestamp The column and table names default to the empty string

Parameters:
row - row key
timestamp - timestamp value

HStoreKey

public HStoreKey(String row,
                 long timestamp)
Create an HStoreKey specifying the row and timestamp The column and table names default to the empty string

Parameters:
row - row key
timestamp - timestamp value

HStoreKey

public HStoreKey(String row,
                 String column)
Create an HStoreKey specifying the row and column names The timestamp defaults to LATEST_TIMESTAMP and table name defaults to the empty string

Parameters:
row - row key
column - column key

HStoreKey

public HStoreKey(byte[] row,
                 byte[] column)
Create an HStoreKey specifying the row and column names The timestamp defaults to LATEST_TIMESTAMP and table name defaults to the empty string

Parameters:
row - row key
column - column key

HStoreKey

public HStoreKey(byte[] row,
                 byte[] column,
                 HRegionInfo regionInfo)
Create an HStoreKey specifying the row, column names and table name The timestamp defaults to LATEST_TIMESTAMP

Parameters:
row - row key
column - column key
regionInfo - region info

HStoreKey

public HStoreKey(String row,
                 String column,
                 long timestamp,
                 HRegionInfo regionInfo)
Create an HStoreKey specifying all the fields Does not make copies of the passed byte arrays. Presumes the passed arrays immutable.

Parameters:
row - row key
column - column key
timestamp - timestamp value
regionInfo - region info

HStoreKey

public HStoreKey(byte[] row,
                 byte[] column,
                 long timestamp)
Create an HStoreKey specifying all the fields with unspecified table Does not make copies of the passed byte arrays. Presumes the passed arrays immutable.

Parameters:
row - row key
column - column key
timestamp - timestamp value

HStoreKey

public HStoreKey(byte[] row,
                 byte[] column,
                 long timestamp,
                 HRegionInfo regionInfo)
Create an HStoreKey specifying all the fields with specified table Does not make copies of the passed byte arrays. Presumes the passed arrays immutable.

Parameters:
row - row key
column - column key
timestamp - timestamp value
regionInfo - region info

HStoreKey

public HStoreKey(HStoreKey other)
Constructs a new HStoreKey from another

Parameters:
other - the source key
Method Detail

setRow

public void setRow(byte[] newrow)
Change the value of the row key

Parameters:
newrow - new row key value

setColumn

public void setColumn(byte[] c)
Change the value of the column in this key

Parameters:
c - new column family value

setVersion

public void setVersion(long timestamp)
Change the value of the timestamp field

Parameters:
timestamp - new timestamp value

set

public void set(HStoreKey k)
Set the value of this HStoreKey from the supplied key

Parameters:
k - key value to copy

getRow

public byte[] getRow()
Returns:
value of row key

getColumn

public byte[] getColumn()
Returns:
value of column

getTimestamp

public long getTimestamp()
Returns:
value of timestamp

getHRegionInfo

public HRegionInfo getHRegionInfo()
Returns:
value of regioninfo

setHRegionInfo

public void setHRegionInfo(HRegionInfo hri)
Parameters:
hri -

matchesRowCol

public boolean matchesRowCol(HStoreKey other)
Compares the row and column of two keys

Parameters:
other - Key to compare against. Compares row and column.
Returns:
True if same row and column.
See Also:
matchesWithoutColumn(HStoreKey), matchesRowFamily(HStoreKey)

matchesWithoutColumn

public boolean matchesWithoutColumn(HStoreKey other)
Compares the row and timestamp of two keys

Parameters:
other - Key to copmare against. Compares row and timestamp.
Returns:
True if same row and timestamp is greater than other
See Also:
matchesRowCol(HStoreKey), matchesRowFamily(HStoreKey)

matchesRowFamily

public boolean matchesRowFamily(HStoreKey that)
Compares the row and column family of two keys

Parameters:
that - Key to compare against. Compares row and column family
Returns:
true if same row and column family
See Also:
matchesRowCol(HStoreKey), matchesWithoutColumn(HStoreKey)

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

compareTo

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

getFamily

public static byte[] getFamily(byte[] column)
                        throws ColumnNameParseException
Parameters:
column -
Returns:
New byte array that holds column family prefix only (Does not include the colon DELIMITER).
Throws:
ColumnNameParseException
See Also:
parseColumn(byte[])

getFamilyMapKey

public static Integer getFamilyMapKey(byte[] column)
Parameters:
column -
Returns:
Return hash of family portion of passed column.

matchingFamily

public static boolean matchingFamily(byte[] family,
                                     byte[] column)
Parameters:
family -
column -
Returns:
True if column has a family of family.

addDelimiter

public static byte[] addDelimiter(byte[] family)
Parameters:
family -
Returns:
Return family plus the family delimiter.

getQualifier

public static byte[] getQualifier(byte[] column)
Parameters:
column -
Returns:
New byte array that holds column qualifier suffix.
See Also:
parseColumn(byte[])

parseColumn

public static byte[][] parseColumn(byte[] c)
                            throws ColumnNameParseException
Parameters:
c - Column name
Returns:
Return array of size two whose first element has the family prefix of passed column c and whose second element is the column qualifier.
Throws:
ColumnNameParseException

getFamilyDelimiterIndex

public static int getFamilyDelimiterIndex(byte[] b)
Parameters:
b -
Returns:
Index of the family-qualifier colon delimiter character in passed buffer.

getBytes

public static byte[] getBytes(HStoreKey hsk)
Returns row and column bytes out of an HStoreKey.

Parameters:
hsk - Store key.
Returns:
byte array encoding of HStoreKey

compareTwoRowKeys

public static int compareTwoRowKeys(HRegionInfo regionInfo,
                                    byte[] rowA,
                                    byte[] rowB)
Utility method to compare two row keys. This is required because of the meta delimiters. This is a hack.

Parameters:
regionInfo -
rowA -
rowB -
Returns:
value of the comparison

equalsTwoRowKeys

public static boolean equalsTwoRowKeys(HRegionInfo regionInfo,
                                       byte[] rowA,
                                       byte[] rowB)
Utility method to check if two row keys are equal. This is required because of the meta delimiters This is a hack

Parameters:
regionInfo -
rowA -
rowB -
Returns:
if it's equal

write

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

readFields

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

heapSize

public long heapSize()
Specified by:
heapSize in interface HeapSize
Returns:
Approximate 'exclusive deep size' of implementing object. Includes count of payload and hosting object sizings.


Copyright © 2008 The Apache Software Foundation