org.apache.hadoop.hbase
Class HStoreKey

java.lang.Object
  extended by org.apache.hadoop.hbase.HStoreKey
All Implemented Interfaces:
Comparable, Writable, WritableComparable

public class HStoreKey
extends Object
implements WritableComparable

A Key for a stored row


Constructor Summary
HStoreKey()
          Default constructor used in conjunction with Writable interface
HStoreKey(HStoreKey other)
          Constructs a new HStoreKey from another
HStoreKey(Text row)
          Create an HStoreKey specifying only the row The column defaults to the empty string and the time stamp defaults to Long.MAX_VALUE
HStoreKey(Text row, long timestamp)
          Create an HStoreKey specifying the row and timestamp The column name defaults to the empty string
HStoreKey(Text row, Text column)
          Create an HStoreKey specifying the row and column names The timestamp defaults to Long.MAX_VALUE
HStoreKey(Text row, Text column, long timestamp)
          Create an HStoreKey specifying all the fields
 
Method Summary
 int compareTo(Object o)
          
 boolean equals(Object obj)
          
static Text extractFamily(Text col)
          Extracts the column family name from a column For example, returns 'info' if the specified column was 'info:server'
static Text extractFamily(Text col, boolean withColon)
          Extracts the column family name from a column For example, returns 'info' if the specified column was 'info:server'
static Text extractQualifier(Text col)
          Extracts the column qualifier, the portion that follows the colon (':') family/qualifier separator.
static byte[] getBytes(HStoreKey hsk)
          Returns row and column bytes out of an HStoreKey.
 Text getColumn()
           
 Text getRow()
           
 long getSize()
           
 long getTimestamp()
           
 int hashCode()
          
 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
 void readFields(DataInput in)
          Deserialize the fields of this object from in.
 void set(HStoreKey k)
          Set the value of this HStoreKey from the supplied key
 void setColumn(Text newcol)
          Change the value of the column key
 void setRow(Text 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)
          Serialize the fields of this object to out.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HStoreKey

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


HStoreKey

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

Parameters:
row - - row key

HStoreKey

public HStoreKey(Text row,
                 long timestamp)
Create an HStoreKey specifying the row and timestamp The column name defaults to the empty string

Parameters:
row - row key
timestamp - timestamp value

HStoreKey

public HStoreKey(Text row,
                 Text column)
Create an HStoreKey specifying the row and column names The timestamp defaults to Long.MAX_VALUE

Parameters:
row - row key
column - column key

HStoreKey

public HStoreKey(Text row,
                 Text column,
                 long timestamp)
Create an HStoreKey specifying all the fields

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

HStoreKey

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

Parameters:
other - the source key
Method Detail

extractFamily

public static Text extractFamily(Text col)
                          throws InvalidColumnNameException
Extracts the column family name from a column For example, returns 'info' if the specified column was 'info:server'

Parameters:
col - name of column
Returns:
column family name
Throws:
InvalidColumnNameException

extractFamily

public static Text extractFamily(Text col,
                                 boolean withColon)
                          throws InvalidColumnNameException
Extracts the column family name from a column For example, returns 'info' if the specified column was 'info:server'

Parameters:
col - name of column
withColon - if returned family name should include the ':' suffix.
Returns:
column family name
Throws:
InvalidColumnNameException

extractQualifier

public static Text extractQualifier(Text col)
                             throws InvalidColumnNameException
Extracts the column qualifier, the portion that follows the colon (':') family/qualifier separator. For example, returns 'server' if the specified column was 'info:server'

Parameters:
col - name of column
Returns:
column qualifier or null if there is no qualifier.
Throws:
InvalidColumnNameException

getBytes

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

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

getSize

public long getSize()
Returns:
Approximate size in bytes of this key.

setRow

public void setRow(Text newrow)
Change the value of the row key

Parameters:
newrow - new row key value

setColumn

public void setColumn(Text newcol)
Change the value of the column key

Parameters:
newcol - new column key 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 Text getRow()
Returns:
value of row key

getColumn

public Text getColumn()
Returns:
value of column key

getTimestamp

public long getTimestamp()
Returns:
value of timestamp

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)
                         throws InvalidColumnNameException
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
Throws:
InvalidColumnNameException
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(Object o)

Specified by:
compareTo in interface Comparable

write

public void write(DataOutput out)
           throws IOException
Serialize the fields of this object to out.

Specified by:
write in interface Writable
Parameters:
out - DataOuput to serialize this object into.
Throws:
IOException

readFields

public void readFields(DataInput in)
                throws IOException
Deserialize the fields of this object from in.

For efficiency, implementations should attempt to re-use storage in the existing object where possible.

Specified by:
readFields in interface Writable
Parameters:
in - DataInput to deseriablize this object from.
Throws:
IOException


Copyright © 2006 The Apache Software Foundation