org.apache.hadoop.hbase
Class KeyValue

java.lang.Object
  extended by org.apache.hadoop.hbase.KeyValue
All Implemented Interfaces:
HeapSize, org.apache.hadoop.io.Writable

public class KeyValue
extends Object
implements org.apache.hadoop.io.Writable, HeapSize

An HBase Key/Value.

If being used client-side, the primary methods to access individual fields are getRow(), getFamily(), getQualifier(), getTimestamp(), and getValue(). These methods allocate new byte arrays and return copies so they should be avoided server-side.

Instances of this class are immutable. They are not comparable but Comparators are provided. Comparators change with context, whether user table or a catalog table comparison context. Its important that you use the appropriate comparator comparing rows in particular. There are Comparators for KeyValue instances and then for just the Key portion of a KeyValue used mostly in HFile.

KeyValue wraps a byte array and has offset and length for passed array at where to start interpreting the content as a KeyValue blob. The KeyValue blob format inside the byte array is: <keylength> <valuelength> <key> <value> Key is decomposed as: <rowlength> <row> <columnfamilylength> <columnfamily> <columnqualifier> <timestamp> <keytype> Rowlength maximum is Short.MAX_SIZE, column family length maximum is Byte.MAX_SIZE, and column qualifier + key length must be < Integer.MAX_SIZE. The column does not contain the family/qualifier delimiter.

TODO: Group Key-only comparators and operations into a Key class, just for neatness sake, if can figure what to call it.


Nested Class Summary
static class KeyValue.KeyComparator
          Compare key portion of a KeyValue.
static class KeyValue.KVComparator
          Compare KeyValues.
static class KeyValue.MetaComparator
          A KeyValue.KVComparator for .META. catalog table KeyValues.
static class KeyValue.MetaKeyComparator
          Compare key portion of a KeyValue for keys in .META. table.
static class KeyValue.RootComparator
          A KeyValue.KVComparator for -ROOT- catalog table KeyValues.
static class KeyValue.RootKeyComparator
          Compare key portion of a KeyValue for keys in -ROOT- table.
static class KeyValue.RowComparator
          Comparator that compares row component only of a KeyValue.
static class KeyValue.SplitKeyValue
          Utility class that splits a KeyValue buffer into separate byte arrays.
static class KeyValue.Type
          Key type.
 
Field Summary
static byte[] COLUMN_FAMILY_DELIM_ARRAY
           
static char COLUMN_FAMILY_DELIMITER
          Colon character in UTF-8
static KeyValue.KVComparator COMPARATOR
          Comparator for plain key/values; i.e.
static int FAMILY_LENGTH_SIZE
          Size of the family length field in bytes
static KeyValue.KeyComparator KEY_COMPARATOR
          Comparator for plain key; i.e.
static int KEY_INFRASTRUCTURE_SIZE
           
static int KEY_LENGTH_SIZE
          Size of the key length field in bytes
static int KEYVALUE_INFRASTRUCTURE_SIZE
           
static KeyValue LOWESTKEY
          Lowest possible key.
static KeyValue.KVComparator META_COMPARATOR
          A KeyValue.KVComparator for .META. catalog table KeyValues.
static KeyValue.KeyComparator META_KEY_COMPARATOR
          A KeyValue.KVComparator for .META. catalog table KeyValue keys.
static KeyValue.KVComparator ROOT_COMPARATOR
          A KeyValue.KVComparator for -ROOT- catalog table KeyValues.
static KeyValue.KeyComparator ROOT_KEY_COMPARATOR
          A KeyValue.KVComparator for -ROOT- catalog table KeyValue keys.
static int ROW_LENGTH_SIZE
          Size of the row length field in bytes
static int ROW_OFFSET
           
static int TIMESTAMP_SIZE
          Size of the timestamp field in bytes
static int TIMESTAMP_TYPE_SIZE
           
static int TYPE_SIZE
          Size of the key type field in bytes
 
Constructor Summary
KeyValue()
          Writable Constructor -- DO NOT USE
KeyValue(byte[] bytes)
          Creates a KeyValue from the start of the specified byte array.
KeyValue(byte[] row, byte[] family, byte[] qualifier)
          Constructs KeyValue structure filled with null value.
KeyValue(byte[] row, byte[] family, byte[] qualifier, byte[] value)
          Constructs KeyValue structure filled with null value.
KeyValue(byte[] row, byte[] family, byte[] qualifier, int qoffset, int qlength, long timestamp, KeyValue.Type type, byte[] value, int voffset, int vlength)
          Constructs KeyValue structure filled with specified values.
KeyValue(byte[] row, byte[] family, byte[] qualifier, long timestamp, byte[] value)
          Constructs KeyValue structure filled with specified values.
KeyValue(byte[] row, byte[] family, byte[] qualifier, long timestamp, KeyValue.Type type)
          Constructs KeyValue structure filled with specified values.
KeyValue(byte[] row, byte[] family, byte[] qualifier, long timestamp, KeyValue.Type type, byte[] value)
          Constructs KeyValue structure filled with specified values.
KeyValue(byte[] bytes, int offset)
          Creates a KeyValue from the specified byte array and offset.
KeyValue(byte[] bytes, int offset, int length)
          Creates a KeyValue from the specified byte array, starting at offset, and for length length.
KeyValue(byte[] row, int roffset, int rlength, byte[] family, int foffset, int flength, byte[] qualifier, int qoffset, int qlength, long timestamp, KeyValue.Type type, byte[] value, int voffset, int vlength)
          Constructs KeyValue structure filled with specified values.
KeyValue(byte[] row, long timestamp)
          Constructs KeyValue structure filled with null value.
KeyValue(byte[] row, long timestamp, KeyValue.Type type)
          Constructs KeyValue structure filled with null value.
 
Method Summary
 KeyValue clone()
          Clones a KeyValue.
 void convertToKeyOnly(boolean lenAsVal)
          Converts this KeyValue to only contain the key portion (the value is changed to be null).
static KeyValue createFirstOnRow(byte[] row)
          Create a KeyValue that is smaller than all other possible KeyValues for the given row.
static KeyValue createFirstOnRow(byte[] row, byte[] family, byte[] qualifier)
          Create a KeyValue for the specified row, family and qualifier that would be smaller than all other possible KeyValues that have the same row,family,qualifier.
static KeyValue createFirstOnRow(byte[] row, byte[] f, byte[] q, long ts)
           
static KeyValue createFirstOnRow(byte[] row, byte[] c, long ts)
          Deprecated.  
static KeyValue createFirstOnRow(byte[] row, int roffset, int rlength, byte[] family, int foffset, int flength, byte[] qualifier, int qoffset, int qlength)
          Create a KeyValue for the specified row, family and qualifier that would be smaller than all other possible KeyValues that have the same row, family, qualifier.
static KeyValue createFirstOnRow(byte[] row, long ts)
          Creates a KeyValue that is smaller than all other KeyValues that are older than the passed timestamp.
static KeyValue createKeyValueFromKey(byte[] b)
           
static KeyValue createKeyValueFromKey(byte[] b, int o, int l)
           
static KeyValue createKeyValueFromKey(ByteBuffer bb)
           
static KeyValue createLastOnRow(byte[] row)
          Creates a KeyValue that is last on the specified row id.
static KeyValue createLastOnRow(byte[] row, int roffset, int rlength, byte[] family, int foffset, int flength, byte[] qualifier, int qoffset, int qlength)
          Create a KeyValue for the specified row, family and qualifier that would be larger than or equal to all other possible KeyValues that have the same row, family, qualifier.
 boolean equals(Object other)
           
 byte[] getBuffer()
           
static int getDelimiter(byte[] b, int offset, int length, int delimiter)
           
static int getDelimiterInReverse(byte[] b, int offset, int length, int delimiter)
          Find index of passed delimiter walking from end of buffer backwards.
 byte[] getFamily()
          Primarily for use client-side.
static int getFamilyDelimiterIndex(byte[] b, int offset, int length)
           
 byte getFamilyLength()
           
 byte getFamilyLength(int foffset)
           
 int getFamilyOffset()
           
 int getFamilyOffset(int rlength)
           
 byte[] getKey()
          Do not use unless you have to.
 int getKeyLength()
           
 int getKeyOffset()
           
 String getKeyString()
           
 int getLength()
           
 long getMemstoreTS()
          Here be dragons
 int getOffset()
           
 byte[] getQualifier()
          Primarily for use client-side.
 int getQualifierLength()
           
 int getQualifierLength(int rlength, int flength)
           
 int getQualifierOffset()
           
 int getQualifierOffset(int foffset)
           
 byte[] getRow()
          Primarily for use client-side.
static KeyValue.KeyComparator getRowComparator(byte[] tableName)
          Get the appropriate row comparator for the specified table.
 short getRowLength()
           
 int getRowOffset()
           
 long getTimestamp()
           
 int getTimestampOffset()
           
 int getTimestampOffset(int keylength)
           
 int getTotalColumnLength()
           
 int getTotalColumnLength(int rlength, int foffset)
           
 byte getType()
           
 byte[] getValue()
          Returns value in a new byte array.
 int getValueLength()
           
 int getValueOffset()
           
 int hashCode()
           
 long heapSize()
           
 boolean isDelete()
           
 boolean isDeleteColumnOrFamily()
           
 boolean isDeleteFamily()
           
 boolean isDeleteType()
           
 boolean isEmptyColumn()
           
 boolean isLatestTimestamp()
           
static String keyToString(byte[] k)
           
static String keyToString(byte[] b, int o, int l)
           
static byte[] makeColumn(byte[] family, byte[] qualifier)
          Makes a column in family:qualifier form from separate byte arrays.
 boolean matchingColumn(byte[] family, byte[] qualifier)
           
 boolean matchingColumnNoDelimiter(byte[] column)
           
 boolean matchingFamily(byte[] family)
           
 boolean matchingFamily(byte[] family, int offset, int length)
           
 boolean matchingFamily(KeyValue other)
           
 boolean matchingQualifier(byte[] qualifier)
           
 boolean matchingQualifier(byte[] qualifier, int offset, int length)
           
 boolean matchingQualifier(KeyValue other)
           
 boolean matchingRow(byte[] row)
           
 boolean matchingRow(byte[] row, int offset, int length)
           
 boolean matchingRow(KeyValue other)
           
 boolean nonNullRowAndColumn()
           
static byte[][] parseColumn(byte[] c)
          Splits a column in family:qualifier form into separate byte arrays.
 void readFields(DataInput in)
           
 void readFields(int length, DataInput in)
           
 void setMemstoreTS(long memstoreTS)
           
 KeyValue.SplitKeyValue split()
           
 String toString()
           
 Map<String,Object> toStringMap()
          Produces a string map for this key/value pair.
 boolean updateLatestStamp(byte[] now)
           
 void write(DataOutput out)
           
 
Methods inherited from class java.lang.Object
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

COLUMN_FAMILY_DELIM_ARRAY

public static final byte[] COLUMN_FAMILY_DELIM_ARRAY

COMPARATOR

public static KeyValue.KVComparator COMPARATOR
Comparator for plain key/values; i.e. non-catalog table key/values.


KEY_COMPARATOR

public static KeyValue.KeyComparator KEY_COMPARATOR
Comparator for plain key; i.e. non-catalog table key. Works on Key portion of KeyValue only.


META_COMPARATOR

public static KeyValue.KVComparator META_COMPARATOR
A KeyValue.KVComparator for .META. catalog table KeyValues.


META_KEY_COMPARATOR

public static KeyValue.KeyComparator META_KEY_COMPARATOR
A KeyValue.KVComparator for .META. catalog table KeyValue keys.


ROOT_COMPARATOR

public static KeyValue.KVComparator ROOT_COMPARATOR
A KeyValue.KVComparator for -ROOT- catalog table KeyValues.


ROOT_KEY_COMPARATOR

public static KeyValue.KeyComparator ROOT_KEY_COMPARATOR
A KeyValue.KVComparator for -ROOT- catalog table KeyValue keys.


KEY_LENGTH_SIZE

public static final int KEY_LENGTH_SIZE
Size of the key length field in bytes

See Also:
Constant Field Values

TYPE_SIZE

public static final int TYPE_SIZE
Size of the key type field in bytes

See Also:
Constant Field Values

ROW_LENGTH_SIZE

public static final int ROW_LENGTH_SIZE
Size of the row length field in bytes

See Also:
Constant Field Values

FAMILY_LENGTH_SIZE

public static final int FAMILY_LENGTH_SIZE
Size of the family length field in bytes

See Also:
Constant Field Values

TIMESTAMP_SIZE

public static final int TIMESTAMP_SIZE
Size of the timestamp field in bytes

See Also:
Constant Field Values

TIMESTAMP_TYPE_SIZE

public static final int TIMESTAMP_TYPE_SIZE
See Also:
Constant Field Values

KEY_INFRASTRUCTURE_SIZE

public static final int KEY_INFRASTRUCTURE_SIZE
See Also:
Constant Field Values

ROW_OFFSET

public static final int ROW_OFFSET
See Also:
Constant Field Values

KEYVALUE_INFRASTRUCTURE_SIZE

public static final int KEYVALUE_INFRASTRUCTURE_SIZE
See Also:
Constant Field Values

LOWESTKEY

public static final KeyValue LOWESTKEY
Lowest possible key. Makes a Key with highest possible Timestamp, empty row and column. No key can be equal or lower than this one in memstore or in store file.

Constructor Detail

KeyValue

public KeyValue()
Writable Constructor -- DO NOT USE


KeyValue

public KeyValue(byte[] bytes)
Creates a KeyValue from the start of the specified byte array. Presumes bytes content is formatted as a KeyValue blob.

Parameters:
bytes - byte array

KeyValue

public KeyValue(byte[] bytes,
                int offset)
Creates a KeyValue from the specified byte array and offset. Presumes bytes content starting at offset is formatted as a KeyValue blob.

Parameters:
bytes - byte array
offset - offset to start of KeyValue

KeyValue

public KeyValue(byte[] bytes,
                int offset,
                int length)
Creates a KeyValue from the specified byte array, starting at offset, and for length length.

Parameters:
bytes - byte array
offset - offset to start of the KeyValue
length - length of the KeyValue

KeyValue

public KeyValue(byte[] row,
                long timestamp)
Constructs KeyValue structure filled with null value. Sets type to KeyValue.Type.Maximum

Parameters:
row - - row key (arbitrary byte array)
timestamp -

KeyValue

public KeyValue(byte[] row,
                long timestamp,
                KeyValue.Type type)
Constructs KeyValue structure filled with null value.

Parameters:
row - - row key (arbitrary byte array)
timestamp -

KeyValue

public KeyValue(byte[] row,
                byte[] family,
                byte[] qualifier)
Constructs KeyValue structure filled with null value. Sets type to KeyValue.Type.Maximum

Parameters:
row - - row key (arbitrary byte array)
family - family name
qualifier - column qualifier

KeyValue

public KeyValue(byte[] row,
                byte[] family,
                byte[] qualifier,
                byte[] value)
Constructs KeyValue structure filled with null value.

Parameters:
row - - row key (arbitrary byte array)
family - family name
qualifier - column qualifier

KeyValue

public KeyValue(byte[] row,
                byte[] family,
                byte[] qualifier,
                long timestamp,
                KeyValue.Type type)
Constructs KeyValue structure filled with specified values.

Parameters:
row - row key
family - family name
qualifier - column qualifier
timestamp - version timestamp
type - key type
Throws:
IllegalArgumentException

KeyValue

public KeyValue(byte[] row,
                byte[] family,
                byte[] qualifier,
                long timestamp,
                byte[] value)
Constructs KeyValue structure filled with specified values.

Parameters:
row - row key
family - family name
qualifier - column qualifier
timestamp - version timestamp
value - column value
Throws:
IllegalArgumentException

KeyValue

public KeyValue(byte[] row,
                byte[] family,
                byte[] qualifier,
                long timestamp,
                KeyValue.Type type,
                byte[] value)
Constructs KeyValue structure filled with specified values.

Parameters:
row - row key
family - family name
qualifier - column qualifier
timestamp - version timestamp
type - key type
value - column value
Throws:
IllegalArgumentException

KeyValue

public KeyValue(byte[] row,
                byte[] family,
                byte[] qualifier,
                int qoffset,
                int qlength,
                long timestamp,
                KeyValue.Type type,
                byte[] value,
                int voffset,
                int vlength)
Constructs KeyValue structure filled with specified values.

Parameters:
row - row key
family - family name
qualifier - column qualifier
qoffset - qualifier offset
qlength - qualifier length
timestamp - version timestamp
type - key type
value - column value
voffset - value offset
vlength - value length
Throws:
IllegalArgumentException

KeyValue

public KeyValue(byte[] row,
                int roffset,
                int rlength,
                byte[] family,
                int foffset,
                int flength,
                byte[] qualifier,
                int qoffset,
                int qlength,
                long timestamp,
                KeyValue.Type type,
                byte[] value,
                int voffset,
                int vlength)
Constructs KeyValue structure filled with specified values.

Column is split into two fields, family and qualifier.

Parameters:
row - row key
roffset - row offset
rlength - row length
family - family name
foffset - family offset
flength - family length
qualifier - column qualifier
qoffset - qualifier offset
qlength - qualifier length
timestamp - version timestamp
type - key type
value - column value
voffset - value offset
vlength - value length
Throws:
IllegalArgumentException
Method Detail

getRowComparator

public static KeyValue.KeyComparator getRowComparator(byte[] tableName)
Get the appropriate row comparator for the specified table. Hopefully we can get rid of this, I added this here because it's replacing something in HSK. We should move completely off of that.

Parameters:
tableName - The table name.
Returns:
The comparator.

getMemstoreTS

public long getMemstoreTS()
Here be dragons


setMemstoreTS

public void setMemstoreTS(long memstoreTS)

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

clone

public KeyValue clone()
Clones a KeyValue. This creates a copy, re-allocating the buffer.

Overrides:
clone in class Object
Returns:
Fully copied clone of this KeyValue

toString

public String toString()
Overrides:
toString in class Object

keyToString

public static String keyToString(byte[] k)
Parameters:
k - Key portion of a KeyValue.
Returns:
Key as a String.

toStringMap

public Map<String,Object> toStringMap()
Produces a string map for this key/value pair. Useful for programmatic use and manipulation of the data stored in an HLogKey, for example, printing as JSON. Values are left out due to their tendency to be large. If needed, they can be added manually.

Returns:
the Map containing data from this key

keyToString

public static String keyToString(byte[] b,
                                 int o,
                                 int l)

getBuffer

public byte[] getBuffer()
Returns:
The byte array backing this KeyValue.

getOffset

public int getOffset()
Returns:
Offset into getBuffer() at which this KeyValue starts.

getLength

public int getLength()
Returns:
Length of bytes this KeyValue occupies in getBuffer().

getKeyOffset

public int getKeyOffset()
Returns:
Key offset in backing buffer..

getKeyString

public String getKeyString()

getKeyLength

public int getKeyLength()

getValueOffset

public int getValueOffset()
Returns:
Value offset

getValueLength

public int getValueLength()
Returns:
Value length

getRowOffset

public int getRowOffset()
Returns:
Row offset

getRowLength

public short getRowLength()
Returns:
Row length

getFamilyOffset

public int getFamilyOffset()
Returns:
Family offset

getFamilyOffset

public int getFamilyOffset(int rlength)
Returns:
Family offset

getFamilyLength

public byte getFamilyLength()
Returns:
Family length

getFamilyLength

public byte getFamilyLength(int foffset)
Returns:
Family length

getQualifierOffset

public int getQualifierOffset()
Returns:
Qualifier offset

getQualifierOffset

public int getQualifierOffset(int foffset)
Returns:
Qualifier offset

getQualifierLength

public int getQualifierLength()
Returns:
Qualifier length

getQualifierLength

public int getQualifierLength(int rlength,
                              int flength)
Returns:
Qualifier length

getTotalColumnLength

public int getTotalColumnLength()
Returns:
Column (family + qualifier) length

getTotalColumnLength

public int getTotalColumnLength(int rlength,
                                int foffset)
Returns:
Column (family + qualifier) length

getTimestampOffset

public int getTimestampOffset()
Returns:
Timestamp offset

getTimestampOffset

public int getTimestampOffset(int keylength)
Parameters:
keylength - Pass if you have it to save on a int creation.
Returns:
Timestamp offset

isLatestTimestamp

public boolean isLatestTimestamp()
Returns:
True if this KeyValue has a LATEST_TIMESTAMP timestamp.

updateLatestStamp

public boolean updateLatestStamp(byte[] now)
Parameters:
now - Time to set into this IFF timestamp == HConstants.LATEST_TIMESTAMP (else, its a noop).
Returns:
True is we modified this.

getKey

public byte[] getKey()
Do not use unless you have to. Used internally for compacting and testing. Use getRow(), getFamily(), getQualifier(), and getValue() if accessing a KeyValue client-side.

Returns:
Copy of the key portion only.

getValue

public byte[] getValue()
Returns value in a new byte array. Primarily for use client-side. If server-side, use getBuffer() with appropriate offsets and lengths instead to save on allocations.

Returns:
Value in a new byte array.

getRow

public byte[] getRow()
Primarily for use client-side. Returns the row of this KeyValue in a new byte array.

If server-side, use getBuffer() with appropriate offsets and lengths instead.

Returns:
Row in a new byte array.

getTimestamp

public long getTimestamp()

getType

public byte getType()
Returns:
Type of this KeyValue.

isDelete

public boolean isDelete()
Returns:
True if a delete type, a KeyValue.Type.Delete or a {KeyValue.Type#DeleteFamily} or a KeyValue.Type.DeleteColumn KeyValue type.

isDeleteType

public boolean isDeleteType()
Returns:
True if this KV is a KeyValue.Type.Delete type.

isDeleteFamily

public boolean isDeleteFamily()
Returns:
True if this KV is a delete family type.

isDeleteColumnOrFamily

public boolean isDeleteColumnOrFamily()
Returns:
True if this KV is a delete family or column type.

getFamily

public byte[] getFamily()
Primarily for use client-side. Returns the family of this KeyValue in a new byte array.

If server-side, use getBuffer() with appropriate offsets and lengths instead.

Returns:
Returns family. Makes a copy.

getQualifier

public byte[] getQualifier()
Primarily for use client-side. Returns the column qualifier of this KeyValue in a new byte array.

If server-side, use getBuffer() with appropriate offsets and lengths instead. Use getBuffer() with appropriate offsets and lengths instead.

Returns:
Returns qualifier. Makes a copy.

split

public KeyValue.SplitKeyValue split()

matchingFamily

public boolean matchingFamily(byte[] family)
Parameters:
family -
Returns:
True if matching families.

matchingFamily

public boolean matchingFamily(byte[] family,
                              int offset,
                              int length)

matchingFamily

public boolean matchingFamily(KeyValue other)

matchingQualifier

public boolean matchingQualifier(byte[] qualifier)
Parameters:
qualifier -
Returns:
True if matching qualifiers.

matchingQualifier

public boolean matchingQualifier(byte[] qualifier,
                                 int offset,
                                 int length)

matchingQualifier

public boolean matchingQualifier(KeyValue other)

matchingRow

public boolean matchingRow(byte[] row)

matchingRow

public boolean matchingRow(byte[] row,
                           int offset,
                           int length)

matchingRow

public boolean matchingRow(KeyValue other)

matchingColumnNoDelimiter

public boolean matchingColumnNoDelimiter(byte[] column)
Parameters:
column - Column minus its delimiter
Returns:
True if column matches.

matchingColumn

public boolean matchingColumn(byte[] family,
                              byte[] qualifier)
Parameters:
family - column family
qualifier - column qualifier
Returns:
True if column matches

nonNullRowAndColumn

public boolean nonNullRowAndColumn()
Returns:
True if non-null row and column.

isEmptyColumn

public boolean isEmptyColumn()
Returns:
True if column is empty.

convertToKeyOnly

public void convertToKeyOnly(boolean lenAsVal)
Converts this KeyValue to only contain the key portion (the value is changed to be null). This method does a full copy of the backing byte array and does not modify the original byte array of this KeyValue.

This method is used by KeyOnlyFilter and is an advanced feature of KeyValue, proceed with caution.

Parameters:
lenAsVal - replace value with the actual value length (false=empty)

parseColumn

public static byte[][] parseColumn(byte[] c)
Splits a column in family:qualifier form into separate byte arrays.

Not recommend to be used as this is old-style API.

Parameters:
c - The column.
Returns:
The parsed column.

makeColumn

public static byte[] makeColumn(byte[] family,
                                byte[] qualifier)
Makes a column in family:qualifier form from separate byte arrays.

Not recommended for usage as this is old-style API.

Parameters:
family -
qualifier -
Returns:
family:qualifier

getFamilyDelimiterIndex

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

getDelimiter

public static int getDelimiter(byte[] b,
                               int offset,
                               int length,
                               int delimiter)
Parameters:
b -
delimiter -
Returns:
Index of delimiter having started from start of b moving rightward.

getDelimiterInReverse

public static int getDelimiterInReverse(byte[] b,
                                        int offset,
                                        int length,
                                        int delimiter)
Find index of passed delimiter walking from end of buffer backwards.

Parameters:
b -
delimiter -
Returns:
Index of delimiter

createLastOnRow

public static KeyValue createLastOnRow(byte[] row)
Creates a KeyValue that is last on the specified row id. That is, every other possible KeyValue for the given row would compareTo() less than the result of this call.

Parameters:
row - row key
Returns:
Last possible KeyValue on passed row

createFirstOnRow

public static KeyValue createFirstOnRow(byte[] row)
Create a KeyValue that is smaller than all other possible KeyValues for the given row. That is any (valid) KeyValue on 'row' would sort _after_ the result.

Parameters:
row - - row key (arbitrary byte array)
Returns:
First possible KeyValue on passed row

createFirstOnRow

public static KeyValue createFirstOnRow(byte[] row,
                                        long ts)
Creates a KeyValue that is smaller than all other KeyValues that are older than the passed timestamp.

Parameters:
row - - row key (arbitrary byte array)
ts - - timestamp
Returns:
First possible key on passed row and timestamp.

createFirstOnRow

public static KeyValue createFirstOnRow(byte[] row,
                                        byte[] c,
                                        long ts)
Deprecated. 

Parameters:
row - - row key (arbitrary byte array)
c - column - parseColumn(byte[]) is called to split the column.
ts - - timestamp
Returns:
First possible key on passed row, column and timestamp

createFirstOnRow

public static KeyValue createFirstOnRow(byte[] row,
                                        byte[] family,
                                        byte[] qualifier)
Create a KeyValue for the specified row, family and qualifier that would be smaller than all other possible KeyValues that have the same row,family,qualifier. Used for seeking.

Parameters:
row - - row key (arbitrary byte array)
family - - family name
qualifier - - column qualifier
Returns:
First possible key on passed row, and column.

createFirstOnRow

public static KeyValue createFirstOnRow(byte[] row,
                                        byte[] f,
                                        byte[] q,
                                        long ts)
Parameters:
row - - row key (arbitrary byte array)
f - - family name
q - - column qualifier
ts - - timestamp
Returns:
First possible key on passed row, column and timestamp

createFirstOnRow

public static KeyValue createFirstOnRow(byte[] row,
                                        int roffset,
                                        int rlength,
                                        byte[] family,
                                        int foffset,
                                        int flength,
                                        byte[] qualifier,
                                        int qoffset,
                                        int qlength)
Create a KeyValue for the specified row, family and qualifier that would be smaller than all other possible KeyValues that have the same row, family, qualifier. Used for seeking.

Parameters:
row - row key
roffset - row offset
rlength - row length
family - family name
foffset - family offset
flength - family length
qualifier - column qualifier
qoffset - qualifier offset
qlength - qualifier length
Returns:
First possible key on passed Row, Family, Qualifier.

createLastOnRow

public static KeyValue createLastOnRow(byte[] row,
                                       int roffset,
                                       int rlength,
                                       byte[] family,
                                       int foffset,
                                       int flength,
                                       byte[] qualifier,
                                       int qoffset,
                                       int qlength)
Create a KeyValue for the specified row, family and qualifier that would be larger than or equal to all other possible KeyValues that have the same row, family, qualifier. Used for reseeking.

Parameters:
row - row key
roffset - row offset
rlength - row length
family - family name
foffset - family offset
flength - family length
qualifier - column qualifier
qoffset - qualifier offset
qlength - qualifier length
Returns:
Last possible key on passed row, family, qualifier.

createKeyValueFromKey

public static KeyValue createKeyValueFromKey(byte[] b)
Parameters:
b -
Returns:
A KeyValue made of a byte array that holds the key-only part. Needed to convert hfile index members to KeyValues.

createKeyValueFromKey

public static KeyValue createKeyValueFromKey(ByteBuffer bb)
Parameters:
bb -
Returns:
A KeyValue made of a byte buffer that holds the key-only part. Needed to convert hfile index members to KeyValues.

createKeyValueFromKey

public static KeyValue createKeyValueFromKey(byte[] b,
                                             int o,
                                             int l)
Parameters:
b -
o -
l -
Returns:
A KeyValue made of a byte array that holds the key-only part. Needed to convert hfile index members to KeyValues.

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.

readFields

public void readFields(int length,
                       DataInput in)
                throws IOException
Throws:
IOException

readFields

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

write

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


Copyright © 2013 Cloudera. All Rights Reserved.