@InterfaceAudience.Private public class KeyValueUtil extends Object
Modifier and Type | Field and Description |
---|---|
private static org.slf4j.Logger |
LOG |
Constructor and Description |
---|
KeyValueUtil() |
Modifier and Type | Method and Description |
---|---|
static int |
appendKeyTo(Cell cell,
byte[] output,
int offset) |
static int |
appendKeyTo(Cell cell,
ByteBuffer buf,
int offset) |
static int |
appendTo(Cell cell,
ByteBuffer buf,
int offset,
boolean withTags)
Copy the Cell content into the passed buf in KeyValue serialization format.
|
static int |
appendToByteArray(Cell cell,
byte[] output,
int offset,
boolean withTags)
copy key and value
|
static void |
appendToByteBuffer(ByteBuffer bb,
KeyValue kv,
boolean includeMvccVersion) |
(package private) static String |
bytesToHex(byte[] buf,
int offset,
int length) |
(package private) static void |
checkKeyValueBytes(byte[] buf,
int offset,
int length,
boolean withTags) |
private static int |
checkKeyValueTagBytes(byte[] buf,
int offset,
int length,
int pos,
int endOffset) |
static ByteBuffer |
copyKeyToNewByteBuffer(Cell cell)
The position will be set to the beginning of the new ByteBuffer n * @return the Bytebuffer
containing the key part of the cell
|
static byte[] |
copyToNewByteArray(Cell cell) |
static KeyValue |
copyToNewKeyValue(Cell cell)
copy the cell to create a new keyvalue
|
static KeyValue |
create(DataInput in)
n * Where to read bytes from.
|
static KeyValue |
create(int length,
DataInput in)
Create a KeyValue reading
length from in nn * @return Created
KeyValue OR if we find a length of zero, we will return null which can be useful marking a
stream as done. |
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)
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,
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.
|
static KeyValue |
createKeyValueFromInputStream(InputStream in,
boolean withTags)
Create a KeyValue reading from the raw InputStream.
|
static KeyValue |
createKeyValueFromKey(byte[] b)
n * @return A KeyValue made of a byte array that holds the key-only part.
|
static KeyValue |
createKeyValueFromKey(byte[] b,
int o,
int l)
nnn * @return A KeyValue made of a byte array that holds the key-only part.
|
static KeyValue |
createKeyValueFromKey(ByteBuffer bb)
n * @return A KeyValue made of a byte buffer that holds the key-only part.
|
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.
|
static KeyValue |
ensureKeyValue(Cell cell)
Deprecated.
without any replacement.
|
static List<KeyValue> |
ensureKeyValues(List<Cell> cells)
Deprecated.
|
static int |
getSerializedSize(Cell cell,
boolean withTags) |
static int |
keyLength(Cell cell)
Returns number of bytes this cell's key part would have been used if serialized as in
KeyValue . |
private static int |
keyLength(short rlen,
byte flen,
int qlen) |
static int |
length(short rlen,
byte flen,
int qlen,
int vlen,
int tlen,
boolean withTags)
length
|
static int |
lengthWithMvccVersion(KeyValue kv,
boolean includeMvccVersion) |
static KeyValue |
nextShallowCopy(ByteBuffer bb,
boolean includesMvccVersion,
boolean includesTags)
Creates a new KeyValue object positioned in the supplied ByteBuffer and sets the ByteBuffer's
position to the start of the next KeyValue.
|
static int |
oswrite(Cell cell,
OutputStream out,
boolean withTags) |
static KeyValue |
previousKey(KeyValue in)
Decrement the timestamp.
|
static KeyValue |
toNewKeyCell(Cell cell)
Copies the key to a new KeyValue n * @return the KeyValue that consists only the key part of
the incoming cell
|
static int |
totalLengthWithMvccVersion(Iterable<? extends KeyValue> kvs,
boolean includeMvccVersion) |
static long |
write(KeyValue kv,
DataOutput out)
Write out a KeyValue in the manner in which we used to when KeyValue was a Writable.
|
private static final org.slf4j.Logger LOG
public KeyValueUtil()
public static int length(short rlen, byte flen, int qlen, int vlen, int tlen, boolean withTags)
public static int keyLength(Cell cell)
KeyValue
. Key includes rowkey, family, qualifier, timestamp and type. n * @return the
key lengthprivate static int keyLength(short rlen, byte flen, int qlen)
public static int lengthWithMvccVersion(KeyValue kv, boolean includeMvccVersion)
public static int totalLengthWithMvccVersion(Iterable<? extends KeyValue> kvs, boolean includeMvccVersion)
public static KeyValue copyToNewKeyValue(Cell cell)
public static ByteBuffer copyKeyToNewByteBuffer(Cell cell)
public static KeyValue toNewKeyCell(Cell cell)
public static byte[] copyToNewByteArray(Cell cell)
public static int appendKeyTo(Cell cell, byte[] output, int offset)
public static int appendToByteArray(Cell cell, byte[] output, int offset, boolean withTags)
public static int appendTo(Cell cell, ByteBuffer buf, int offset, boolean withTags)
public static int appendKeyTo(Cell cell, ByteBuffer buf, int offset)
public static void appendToByteBuffer(ByteBuffer bb, KeyValue kv, boolean includeMvccVersion)
public static KeyValue nextShallowCopy(ByteBuffer bb, boolean includesMvccVersion, boolean includesTags)
public static KeyValue previousKey(KeyValue in)
public static KeyValue createLastOnRow(byte[] row, int roffset, int rlength, byte[] family, int foffset, int flength, byte[] qualifier, int qoffset, int qlength)
public static KeyValue createFirstOnRow(byte[] row, int roffset, short rlength)
row
- - row key (arbitrary byte array)row
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, 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 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
@Deprecated public static KeyValue ensureKeyValue(Cell cell)
cell
if it is an object of class KeyValue
else we will return
a new KeyValue
instance made from cell
Note: Even if the cell is an object
of any of the subclass of KeyValue
, we will create a new KeyValue
object
wrapping same buffer. This API is used only with MR based tools which expect the type to be
exactly KeyValue. That is the reason for doing this way.@Deprecated public static List<KeyValue> ensureKeyValues(List<Cell> cells)
public static long write(KeyValue kv, DataOutput out) throws IOException
IOException
static String bytesToHex(byte[] buf, int offset, int length)
static void checkKeyValueBytes(byte[] buf, int offset, int length, boolean withTags)
private static int checkKeyValueTagBytes(byte[] buf, int offset, int length, int pos, int endOffset)
public static KeyValue createKeyValueFromInputStream(InputStream in, boolean withTags) throws IOException
createKeyValueFromInputStream
so doesn't clash with create(DataInput)
in
- inputStream to read.withTags
- whether the keyvalue should include tags are notIOException
public static KeyValue createKeyValueFromKey(byte[] b)
public static KeyValue createKeyValueFromKey(ByteBuffer bb)
public static KeyValue createKeyValueFromKey(byte[] b, int o, int l)
public static KeyValue create(DataInput in) throws IOException
in
OR if we find a length of zero,
we will return null which can be useful marking a stream as done. nIOException
public static KeyValue create(int length, DataInput in) throws IOException
length
from in
nn * @return Created
KeyValue OR if we find a length of zero, we will return null which can be useful marking a
stream as done. nIOException
public static int getSerializedSize(Cell cell, boolean withTags)
public static int oswrite(Cell cell, OutputStream out, boolean withTags) throws IOException
IOException
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.