@InterfaceAudience.Private public class KeyValue extends Object implements Cell, HeapSize, Cloneable
HBase applications and users should use the Cell interface and avoid directly using KeyValue and member functions not defined in Cell.
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. Avoid their use server-side.
Instances of this class are immutable. They do not implement Comparable but Comparators are provided. Comparators change with context, whether user table or a catalog table comparison. Its critical you use the appropriate comparator. There are Comparators for normal HFiles, Meta's Hfiles, and bloom filter keys.
KeyValue wraps a byte array and takes offsets and lengths into passed array at where to start
interpreting the content as KeyValue. The KeyValue format inside a byte array is:
<keylength> <valuelength> <key> <value>
Key is further decomposed as:
<rowlength> <row> <columnfamilylength> <columnfamily> <columnqualifier>
<timestamp> <keytype>
The 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,
COLUMN_FAMILY_DELIMITER
KeyValue can optionally contain Tags. When it contains tags, it is added in the byte array after
the value part. The format for this part is: <tagslength><tagsbytes>
.
tagslength
maximum is Short.MAX_SIZE
. The tagsbytes
contain one or more tags where as each tag is of the form
<taglength><tagtype><tagbytes>
. tagtype
is one byte and
taglength
maximum is Short.MAX_SIZE
and it includes 1 byte type length
and actual tag bytes length.
Modifier and Type | Class and Description |
---|---|
static class |
KeyValue.KVComparator
Compare KeyValues.
|
static class |
KeyValue.MetaComparator
|
static class |
KeyValue.RawBytesComparator
This is a TEST only Comparator used in TestSeekTo and TestReseekTo.
|
static class |
KeyValue.RowOnlyComparator
Comparator that compares row component only of a KeyValue.
|
static interface |
KeyValue.SamePrefixComparator<T>
Avoids redundant comparisons for better performance.
|
static class |
KeyValue.Type
Key type.
|
Modifier and Type | Field and Description |
---|---|
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 int |
KEY_INFRASTRUCTURE_SIZE |
static int |
KEY_LENGTH_SIZE
Size of the key length field in bytes
|
static int |
KEYVALUE_INFRASTRUCTURE_SIZE |
static int |
KEYVALUE_WITH_TAGS_INFRASTRUCTURE_SIZE |
static KeyValue |
LOWESTKEY
Lowest possible key.
|
static KeyValue.KVComparator |
META_COMPARATOR
|
static KeyValue.KVComparator |
RAW_COMPARATOR
Needed for Bloom Filters.
|
static int |
ROW_LENGTH_SIZE
Size of the row length field in bytes
|
static int |
ROW_OFFSET |
static int |
TAGS_LENGTH_SIZE
Size of the tags length field in bytes
|
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 and Description |
---|
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,
byte[] tags) |
KeyValue(byte[] row,
byte[] family,
byte[] qualifier,
int qoffset,
int qlength,
long timestamp,
KeyValue.Type type,
byte[] value,
int voffset,
int vlength,
List<Tag> tags)
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,
byte[] value,
List<Tag> tags)
Constructs KeyValue structure filled with specified values.
|
KeyValue(byte[] row,
byte[] family,
byte[] qualifier,
long timestamp,
byte[] value,
Tag[] tags)
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[] row,
byte[] family,
byte[] qualifier,
long timestamp,
KeyValue.Type type,
byte[] value,
byte[] tags)
Constructs KeyValue structure filled with specified values.
|
KeyValue(byte[] row,
byte[] family,
byte[] qualifier,
long timestamp,
KeyValue.Type type,
byte[] value,
List<Tag> tags)
Constructs KeyValue structure filled with specified values.
|
KeyValue(byte[] bytes,
int offset)
Creates a KeyValue from the specified byte array and offset.
|
KeyValue(byte[] buffer,
int boffset,
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,
Tag[] tags)
Constructs KeyValue structure filled with specified values.
|
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,
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,
byte[] tags,
int tagsOffset,
int tagsLength) |
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,
List<Tag> tags)
Constructs KeyValue structure filled with specified values.
|
KeyValue(byte[] row,
int roffset,
int rlength,
byte[] family,
int foffset,
int flength,
ByteBuffer qualifier,
long ts,
KeyValue.Type type,
ByteBuffer value,
List<Tag> tags) |
KeyValue(byte[] bytes,
int offset,
int length,
long ts)
Creates a KeyValue from the specified byte array, starting at offset, and
for length
length . |
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.
|
KeyValue(Cell c) |
KeyValue(int rlength,
int flength,
int qlength,
long timestamp,
KeyValue.Type type,
int vlength)
Constructs an empty KeyValue structure, with specified sizes.
|
KeyValue(int rlength,
int flength,
int qlength,
long timestamp,
KeyValue.Type type,
int vlength,
int tagsLength)
Constructs an empty KeyValue structure, with specified sizes.
|
Modifier and Type | Method and Description |
---|---|
KeyValue |
clone()
Clones a KeyValue.
|
static KeyValue |
cloneAndAddTags(Cell c,
List<Tag> newTags)
Create a new KeyValue by copying existing cell and adding new tags
|
static KeyValue |
create(DataInput in) |
static KeyValue |
create(int length,
DataInput in)
Create a KeyValue reading
length from in |
static KeyValue |
createFirstDeleteFamilyOnRow(byte[] row,
byte[] family)
Create a Delete Family KeyValue for the specified row and family that would
be smaller than all other possible Delete Family KeyValues that have the
same row and family.
|
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[] buffer,
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[] buffer,
int boffset,
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,
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,
int roffset,
short rlength)
Create a KeyValue that is smaller than all other possible KeyValues
for the given row.
|
static KeyValue |
createFirstOnRow(byte[] row,
long ts)
Creates a KeyValue that is smaller than all other KeyValues that
are older than the passed timestamp.
|
KeyValue |
createFirstOnRowColTS(long ts)
Creates the first KV with the row/family/qualifier of this KV and the
given timestamp.
|
KeyValue |
createKeyOnly(boolean lenAsVal)
Creates a new KeyValue that only contains the key portion (the value is
set to be null).
|
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.
|
KeyValue |
createLastOnRowCol()
Similar to
createLastOnRow(byte[], int, int, byte[], int, int,
byte[], int, int) but creates the last key on the row/column of this KV
(the value part of the returned KV is always empty). |
boolean |
equals(Object other)
Needed doing 'contains' on List.
|
byte[] |
getBuffer()
Deprecated.
Since 0.98.0. Use Cell Interface instead. Do not presume single backing buffer.
|
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()
Deprecated.
|
byte[] |
getFamilyArray()
Contiguous bytes composed of legal HDFS filename characters which may start at any index in the
containing array.
|
byte |
getFamilyLength() |
byte |
getFamilyLength(int foffset) |
int |
getFamilyOffset() |
byte[] |
getKey()
Do not use unless you have to.
|
static long |
getKeyDataStructureSize(int rlength,
int flength,
int qlength)
Computes the number of bytes that a
KeyValue instance with the provided
characteristics would take up in its underlying data structure for the key. |
int |
getKeyLength() |
int |
getKeyOffset() |
String |
getKeyString() |
static long |
getKeyValueDataStructureSize(int klength,
int vlength,
int tagsLength)
Computes the number of bytes that a
KeyValue instance with the provided
characteristics would take up for its underlying data structure. |
static long |
getKeyValueDataStructureSize(int rlength,
int flength,
int qlength,
int vlength)
Computes the number of bytes that a
KeyValue instance with the provided
characteristics would take up for its underlying data structure. |
static long |
getKeyValueDataStructureSize(int rlength,
int flength,
int qlength,
int vlength,
int tagsLength)
Computes the number of bytes that a
KeyValue instance with the provided
characteristics would take up for its underlying data structure. |
int |
getLength() |
long |
getMvccVersion()
Here be dragons
|
int |
getOffset() |
byte[] |
getQualifier()
Deprecated.
|
byte[] |
getQualifierArray()
Contiguous raw bytes that may start at any index in the containing array.
|
int |
getQualifierLength() |
int |
getQualifierOffset() |
byte[] |
getRow()
Deprecated.
|
byte[] |
getRowArray()
Contiguous raw bytes that may start at any index in the containing array.
|
short |
getRowLength() |
int |
getRowOffset() |
List<Tag> |
getTags()
Returns any tags embedded in the KeyValue.
|
byte[] |
getTagsArray() |
short |
getTagsLength()
Deprecated.
|
int |
getTagsLengthUnsigned()
Deprecated.
|
int |
getTagsOffset()
This returns the offset where the tag actually starts.
|
long |
getTimestamp() |
int |
getTimestampOffset() |
byte |
getType()
Deprecated.
|
byte |
getTypeByte() |
byte[] |
getValue()
Deprecated.
|
byte[] |
getValueArray()
Contiguous raw bytes that may start at any index in the containing array.
|
int |
getValueLength() |
int |
getValueOffset() |
int |
hashCode() |
long |
heapSize()
HeapSize implementation
We do not count the bytes in the rowCache because it should be empty for a KeyValue in the
MemStore.
|
static String |
humanReadableTimestamp(long timestamp) |
static KeyValue |
iscreate(InputStream in)
Create a KeyValue reading from the raw InputStream.
|
boolean |
isDelete()
Deprecated.
|
static boolean |
isDelete(byte t) |
boolean |
isDeleteColumnOrFamily() |
boolean |
isDeleteFamily() |
boolean |
isDeleteFamilyVersion() |
boolean |
isDeleteType() |
boolean |
isLatestTimestamp() |
static String |
keyToString(byte[] k) |
static String |
keyToString(byte[] b,
int o,
int l)
Use for logging.
|
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 |
matchingColumn(byte[] family,
int foffset,
int flength,
byte[] qualifier,
int qoffset,
int qlength)
Checks if column matches.
|
boolean |
matchingFamily(byte[] family) |
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) |
static long |
oswrite(KeyValue kv,
OutputStream out)
Deprecated.
|
static long |
oswrite(KeyValue kv,
OutputStream out,
boolean withTags)
Write out a KeyValue in the manner in which we used to when KeyValue was a Writable but do
not require a
DataOutput , just take plain OutputStream
Named oswrite so does not clash with write(KeyValue, DataOutput) |
static byte[][] |
parseColumn(byte[] c)
Splits a column in
family:qualifier form into separate byte arrays. |
void |
setMvccVersion(long mvccVersion) |
KeyValue |
shallowCopy()
Creates a shallow copy of this KeyValue, reusing the data byte buffer.
|
String |
toString() |
Map<String,Object> |
toStringMap()
Produces a string map for this key/value pair.
|
boolean |
updateLatestStamp(byte[] now) |
static long |
write(KeyValue kv,
DataOutput out)
Write out a KeyValue in the manner in which we used to when KeyValue was a Writable.
|
public static final char COLUMN_FAMILY_DELIMITER
public static final byte[] COLUMN_FAMILY_DELIM_ARRAY
public static final KeyValue.KVComparator COMPARATOR
public static final KeyValue.KVComparator META_COMPARATOR
public static final KeyValue.KVComparator RAW_COMPARATOR
public static final int KEY_LENGTH_SIZE
public static final int TYPE_SIZE
public static final int ROW_LENGTH_SIZE
public static final int FAMILY_LENGTH_SIZE
public static final int TIMESTAMP_SIZE
public static final int TIMESTAMP_TYPE_SIZE
public static final int KEY_INFRASTRUCTURE_SIZE
public static final int ROW_OFFSET
public static final int KEYVALUE_INFRASTRUCTURE_SIZE
public static final int TAGS_LENGTH_SIZE
public static final int KEYVALUE_WITH_TAGS_INFRASTRUCTURE_SIZE
public static final KeyValue LOWESTKEY
public KeyValue()
public KeyValue(byte[] bytes)
bytes
content is formatted as a KeyValue blob.bytes
- byte arraypublic KeyValue(byte[] bytes, int offset)
bytes
content starting at offset
is
formatted as a KeyValue blob.bytes
- byte arrayoffset
- offset to start of KeyValuepublic KeyValue(byte[] bytes, int offset, int length)
length
.bytes
- byte arrayoffset
- offset to start of the KeyValuelength
- length of the KeyValuepublic KeyValue(byte[] bytes, int offset, int length, long ts)
length
.bytes
- byte arrayoffset
- offset to start of the KeyValuelength
- length of the KeyValuets
- public KeyValue(byte[] row, long timestamp)
KeyValue.Type.Maximum
row
- - row key (arbitrary byte array)timestamp
- public KeyValue(byte[] row, long timestamp, KeyValue.Type type)
row
- - row key (arbitrary byte array)timestamp
- public KeyValue(byte[] row, byte[] family, byte[] qualifier)
KeyValue.Type.Maximum
row
- - row key (arbitrary byte array)family
- family namequalifier
- column qualifierpublic KeyValue(byte[] row, byte[] family, byte[] qualifier, byte[] value)
row
- - row key (arbitrary byte array)family
- family namequalifier
- column qualifierpublic KeyValue(byte[] row, byte[] family, byte[] qualifier, long timestamp, KeyValue.Type type)
row
- row keyfamily
- family namequalifier
- column qualifiertimestamp
- version timestamptype
- key typeIllegalArgumentException
public KeyValue(byte[] row, byte[] family, byte[] qualifier, long timestamp, byte[] value)
row
- row keyfamily
- family namequalifier
- column qualifiertimestamp
- version timestampvalue
- column valueIllegalArgumentException
public KeyValue(byte[] row, byte[] family, byte[] qualifier, long timestamp, byte[] value, Tag[] tags)
row
- row keyfamily
- family namequalifier
- column qualifiertimestamp
- version timestampvalue
- column valuetags
- tagsIllegalArgumentException
public KeyValue(byte[] row, byte[] family, byte[] qualifier, long timestamp, byte[] value, List<Tag> tags)
row
- row keyfamily
- family namequalifier
- column qualifiertimestamp
- version timestampvalue
- column valuetags
- tags non-empty list of tags or nullIllegalArgumentException
public KeyValue(byte[] row, byte[] family, byte[] qualifier, long timestamp, KeyValue.Type type, byte[] value)
row
- row keyfamily
- family namequalifier
- column qualifiertimestamp
- version timestamptype
- key typevalue
- column valueIllegalArgumentException
public KeyValue(byte[] row, byte[] family, byte[] qualifier, long timestamp, KeyValue.Type type, byte[] value, List<Tag> tags)
Column is split into two fields, family and qualifier.
row
- row keyfamily
- family namequalifier
- column qualifiertimestamp
- version timestamptype
- key typevalue
- column valueIllegalArgumentException
public KeyValue(byte[] row, byte[] family, byte[] qualifier, long timestamp, KeyValue.Type type, byte[] value, byte[] tags)
row
- row keyfamily
- family namequalifier
- column qualifiertimestamp
- version timestamptype
- key typevalue
- column valueIllegalArgumentException
public KeyValue(byte[] row, byte[] family, byte[] qualifier, int qoffset, int qlength, long timestamp, KeyValue.Type type, byte[] value, int voffset, int vlength, List<Tag> tags)
row
- row keyfamily
- family namequalifier
- column qualifierqoffset
- qualifier offsetqlength
- qualifier lengthtimestamp
- version timestamptype
- key typevalue
- column valuevoffset
- value offsetvlength
- value lengthIllegalArgumentException
public KeyValue(byte[] row, byte[] family, byte[] qualifier, int qoffset, int qlength, long timestamp, KeyValue.Type type, byte[] value, int voffset, int vlength, byte[] tags)
row
- family
- qualifier
- qoffset
- qlength
- timestamp
- type
- value
- voffset
- vlength
- tags
- 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)
Column is split into two fields, family and qualifier.
row
- row keyIllegalArgumentException
public KeyValue(byte[] buffer, int boffset, 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, Tag[] tags)
Column is split into two fields, family and qualifier.
buffer
- the bytes buffer to useboffset
- buffer offsetrow
- row keyroffset
- row offsetrlength
- row lengthfamily
- family namefoffset
- family offsetflength
- family lengthqualifier
- column qualifierqoffset
- qualifier offsetqlength
- qualifier lengthtimestamp
- version timestamptype
- key typevalue
- column valuevoffset
- value offsetvlength
- value lengthtags
- non-empty list of tags or nullIllegalArgumentException
- an illegal value was passed or there is insufficient space
remaining in the bufferpublic 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, List<Tag> tags)
Column is split into two fields, family and qualifier.
row
- row keyroffset
- row offsetrlength
- row lengthfamily
- family namefoffset
- family offsetflength
- family lengthqualifier
- column qualifierqoffset
- qualifier offsetqlength
- qualifier lengthtimestamp
- version timestamptype
- key typevalue
- column valuevoffset
- value offsetvlength
- value lengthtags
- tagsIllegalArgumentException
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, byte[] tags, int tagsOffset, int tagsLength)
row
- roffset
- rlength
- family
- foffset
- flength
- qualifier
- qoffset
- qlength
- timestamp
- type
- value
- voffset
- vlength
- tags
- public KeyValue(int rlength, int flength, int qlength, long timestamp, KeyValue.Type type, int vlength)
Column is split into two fields, family and qualifier.
rlength
- row lengthflength
- family lengthqlength
- qualifier lengthtimestamp
- version timestamptype
- key typevlength
- value lengthIllegalArgumentException
public KeyValue(int rlength, int flength, int qlength, long timestamp, KeyValue.Type type, int vlength, int tagsLength)
Column is split into two fields, family and qualifier.
rlength
- row lengthflength
- family lengthqlength
- qualifier lengthtimestamp
- version timestamptype
- key typevlength
- value lengthtagsLength
- IllegalArgumentException
public KeyValue(byte[] row, int roffset, int rlength, byte[] family, int foffset, int flength, ByteBuffer qualifier, long ts, KeyValue.Type type, ByteBuffer value, List<Tag> tags)
public KeyValue(Cell c)
public static long getKeyValueDataStructureSize(int rlength, int flength, int qlength, int vlength)
KeyValue
instance with the provided
characteristics would take up for its underlying data structure.rlength
- row lengthflength
- family lengthqlength
- qualifier lengthvlength
- value lengthKeyValue
data structure lengthpublic static long getKeyValueDataStructureSize(int rlength, int flength, int qlength, int vlength, int tagsLength)
KeyValue
instance with the provided
characteristics would take up for its underlying data structure.rlength
- row lengthflength
- family lengthqlength
- qualifier lengthvlength
- value lengthtagsLength
- total length of the tagsKeyValue
data structure lengthpublic static long getKeyValueDataStructureSize(int klength, int vlength, int tagsLength)
KeyValue
instance with the provided
characteristics would take up for its underlying data structure.klength
- key lengthvlength
- value lengthtagsLength
- total length of the tagsKeyValue
data structure lengthpublic static long getKeyDataStructureSize(int rlength, int flength, int qlength)
KeyValue
instance with the provided
characteristics would take up in its underlying data structure for the key.rlength
- row lengthflength
- family lengthqlength
- qualifier lengthpublic static boolean isDelete(byte t)
KeyValue.Type.Delete
or
a {KeyValue.Type#DeleteFamily} or a KeyValue.Type.DeleteColumn
KeyValue type.public long getMvccVersion()
getMvccVersion
in interface Cell
public void setMvccVersion(long mvccVersion)
public boolean equals(Object other)
public KeyValue clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
public KeyValue shallowCopy()
public static String keyToString(byte[] k)
k
- Key portion of a KeyValue.public Map<String,Object> toStringMap()
public static String keyToString(byte[] b, int o, int l)
b
- Key portion of a KeyValue.o
- Offset to start of keyl
- Length of key.public static String humanReadableTimestamp(long timestamp)
@Deprecated public byte[] getBuffer()
public int getOffset()
getBuffer()
at which this KeyValue starts.public int getLength()
getBuffer()
.public int getKeyOffset()
public String getKeyString()
public int getKeyLength()
public byte[] getValueArray()
Cell
getValueArray
in interface Cell
public int getValueOffset()
getValueOffset
in interface Cell
public int getValueLength()
getValueLength
in interface Cell
public byte[] getRowArray()
Cell
getRowArray
in interface Cell
public int getRowOffset()
getRowOffset
in interface Cell
public short getRowLength()
getRowLength
in interface Cell
public byte[] getFamilyArray()
Cell
getFamilyArray
in interface Cell
public int getFamilyOffset()
getFamilyOffset
in interface Cell
public byte getFamilyLength()
getFamilyLength
in interface Cell
public byte getFamilyLength(int foffset)
public byte[] getQualifierArray()
Cell
getQualifierArray
in interface Cell
public int getQualifierOffset()
getQualifierOffset
in interface Cell
public int getQualifierLength()
getQualifierLength
in interface Cell
public int getTimestampOffset()
public boolean isLatestTimestamp()
public boolean updateLatestStamp(byte[] now)
now
- Time to set into this
IFF timestamp ==
HConstants.LATEST_TIMESTAMP
(else, its a noop).public byte[] getKey()
getRow()
, getFamily()
, getQualifier()
, and
getValue()
if accessing a KeyValue client-side.@Deprecated public byte[] getValue()
getBuffer()
with appropriate offsets and lengths instead to
save on allocations.@Deprecated public byte[] getRow()
If server-side, use getBuffer()
with appropriate offsets and
lengths instead.
public long getTimestamp()
getTimestamp
in interface Cell
@Deprecated public byte getType()
public byte getTypeByte()
getTypeByte
in interface Cell
@Deprecated public boolean isDelete()
KeyValue.Type.Delete
or
a {KeyValue.Type#DeleteFamily} or a KeyValue.Type.DeleteColumn
KeyValue type.public boolean isDeleteType()
KeyValue.Type.Delete
type.public boolean isDeleteFamily()
public boolean isDeleteFamilyVersion()
public boolean isDeleteColumnOrFamily()
@Deprecated public byte[] getFamily()
If server-side, use getBuffer()
with appropriate offsets and
lengths instead.
@Deprecated public byte[] getQualifier()
If server-side, use getBuffer()
with appropriate offsets and
lengths instead.
Use getBuffer()
with appropriate offsets and lengths instead.
getQualifier
in interface Cell
public int getTagsOffset()
getTagsOffset
in interface Cell
@Deprecated public int getTagsLengthUnsigned()
getTagsLengthUnsigned
in interface Cell
@Deprecated public short getTagsLength()
getTagsLength
in interface Cell
public List<Tag> getTags()
public byte[] getTagsArray()
getTagsArray
in interface Cell
public boolean matchingFamily(byte[] family)
family
- public boolean matchingQualifier(byte[] qualifier)
qualifier
- public boolean matchingQualifier(byte[] qualifier, int offset, int length)
public boolean matchingQualifier(KeyValue other)
public boolean matchingRow(byte[] row)
public boolean matchingRow(byte[] row, int offset, int length)
public boolean matchingRow(KeyValue other)
public boolean matchingColumn(byte[] family, byte[] qualifier)
family
- column familyqualifier
- column qualifierpublic boolean matchingColumn(byte[] family, int foffset, int flength, byte[] qualifier, int qoffset, int qlength)
family
- family namefoffset
- family offsetflength
- family lengthqualifier
- column qualifierqoffset
- qualifier offsetqlength
- qualifier lengthpublic KeyValue createKeyOnly(boolean lenAsVal)
lenAsVal
- replace value with the actual value length (false=empty)public static byte[][] parseColumn(byte[] c)
family:qualifier
form into separate byte arrays. An empty qualifier
(ie, fam:
) is parsed as { fam, EMPTY_BYTE_ARRAY }
while no delimiter (ie,
fam
) is parsed as an array of one element, { fam }
.
Don't forget, HBase DOES support empty qualifiers. (see HBASE-9549)
Not recommend to be used as this is old-style API.
c
- The column.public static byte[] makeColumn(byte[] family, byte[] qualifier)
Not recommended for usage as this is old-style API.
family
- qualifier
- public static int getDelimiter(byte[] b, int offset, int length, int delimiter)
b
- delimiter
- b
moving rightward.public static int getDelimiterInReverse(byte[] b, int offset, int length, int delimiter)
b
- delimiter
- public static KeyValue createLastOnRow(byte[] row)
row
- row keyrow
public static KeyValue createFirstOnRow(byte[] row)
row
- - row key (arbitrary byte array)row
public static KeyValue createFirstOnRow(byte[] row, int roffset, short rlength)
row
- - row key (arbitrary byte array)row
public static KeyValue createFirstOnRow(byte[] row, long ts)
row
- - row key (arbitrary byte array)ts
- - timestamprow
and timestamp.public static KeyValue createFirstOnRow(byte[] row, byte[] family, byte[] qualifier)
row
- - row key (arbitrary byte array)family
- - family namequalifier
- - column qualifierrow
, and column.public static KeyValue createFirstDeleteFamilyOnRow(byte[] row, byte[] family)
row
- - row key (arbitrary byte array)family
- - family namerow
.public static KeyValue createFirstOnRow(byte[] row, byte[] f, byte[] q, long ts)
row
- - row key (arbitrary byte array)f
- - family nameq
- - column qualifierts
- - timestamprow
, column and timestamppublic static KeyValue createFirstOnRow(byte[] row, int roffset, int rlength, byte[] family, int foffset, int flength, byte[] qualifier, int qoffset, int qlength)
row
- row keyroffset
- row offsetrlength
- row lengthfamily
- family namefoffset
- family offsetflength
- family lengthqualifier
- column qualifierqoffset
- qualifier offsetqlength
- qualifier lengthpublic static KeyValue createFirstOnRow(byte[] buffer, byte[] row, byte[] family, byte[] qualifier) throws IllegalArgumentException
buffer
- the buffer to use for the new KeyValue
objectrow
- the value keyfamily
- family namequalifier
- column qualifierIllegalArgumentException
- The resulting KeyValue
object would be larger
than the provided buffer or than Integer.MAX_VALUE
public static KeyValue createFirstOnRow(byte[] buffer, int boffset, byte[] row, int roffset, int rlength, byte[] family, int foffset, int flength, byte[] qualifier, int qoffset, int qlength) throws IllegalArgumentException
buffer
- the buffer to use for the new KeyValue
objectboffset
- buffer offsetrow
- the value keyroffset
- row offsetrlength
- row lengthfamily
- family namefoffset
- family offsetflength
- family lengthqualifier
- column qualifierqoffset
- qualifier offsetqlength
- qualifier lengthIllegalArgumentException
- The resulting KeyValue
object would be larger
than the provided buffer or than Integer.MAX_VALUE
public static KeyValue createLastOnRow(byte[] row, int roffset, int rlength, byte[] family, int foffset, int flength, byte[] qualifier, int qoffset, int qlength)
row
- row keyroffset
- row offsetrlength
- row lengthfamily
- family namefoffset
- family offsetflength
- family lengthqualifier
- column qualifierqoffset
- qualifier offsetqlength
- qualifier lengthpublic KeyValue createLastOnRowCol()
createLastOnRow(byte[], int, int, byte[], int, int,
byte[], int, int)
but creates the last key on the row/column of this KV
(the value part of the returned KV is always empty). Used in creating
"fake keys" for the multi-column Bloom filter optimization to skip the
row/column we already know is not in the file.public KeyValue createFirstOnRowColTS(long ts)
public static KeyValue createKeyValueFromKey(byte[] b)
b
- public static KeyValue createKeyValueFromKey(ByteBuffer bb)
bb
- public static KeyValue createKeyValueFromKey(byte[] b, int o, int l)
b
- o
- l
- public static KeyValue create(DataInput in) throws IOException
in
- Where to read bytes from. Creates a byte array to hold the KeyValue
backing bytes copied from the steam.in
OR if we find a length
of zero, we will return null which can be useful marking a stream as done.IOException
public static KeyValue create(int length, DataInput in) throws IOException
length
from in
length
- in
- IOException
public static KeyValue cloneAndAddTags(Cell c, List<Tag> newTags)
c
- newTags
- public static KeyValue iscreate(InputStream in) throws IOException
iscreate
so doesn't clash with create(DataInput)
in
- IOException
public static long write(KeyValue kv, DataOutput out) throws IOException
kv
- out
- IOException
for the inverse function
@Deprecated public static long oswrite(KeyValue kv, OutputStream out) throws IOException
DataOutput
, just take plain OutputStream
Named oswrite
so does not clash with write(KeyValue, DataOutput)
kv
- out
- IOException
for the inverse function
,
write(KeyValue, DataOutput)
public static long oswrite(KeyValue kv, OutputStream out, boolean withTags) throws IOException
DataOutput
, just take plain OutputStream
Named oswrite
so does not clash with write(KeyValue, DataOutput)
kv
- out
- withTags
- IOException
for the inverse function
,
write(KeyValue, DataOutput)
public long heapSize()
Copyright © 2014 The Apache Software Foundation. All Rights Reserved.