@InterfaceAudience.Private public final class PrivateCellUtil extends Object
Modifier and Type | Class and Description |
---|---|
private static class |
PrivateCellUtil.EmptyByteBufferExtendedCell
These cells are used in reseeks/seeks to improve the read performance.
|
private static class |
PrivateCellUtil.EmptyCell
These cells are used in reseeks/seeks to improve the read performance.
|
private static class |
PrivateCellUtil.FirstOnRowByteBufferExtendedCell |
private static class |
PrivateCellUtil.FirstOnRowCell |
private static class |
PrivateCellUtil.FirstOnRowColByteBufferExtendedCell |
private static class |
PrivateCellUtil.FirstOnRowColCell |
private static class |
PrivateCellUtil.FirstOnRowColTSByteBufferExtendedCell |
private static class |
PrivateCellUtil.FirstOnRowColTSCell |
private static class |
PrivateCellUtil.FirstOnRowDeleteFamilyCell |
private static class |
PrivateCellUtil.LastOnRowByteBufferExtendedCell |
private static class |
PrivateCellUtil.LastOnRowCell |
private static class |
PrivateCellUtil.LastOnRowColByteBufferExtendedCell |
private static class |
PrivateCellUtil.LastOnRowColCell |
(package private) static class |
PrivateCellUtil.TagRewriteByteBufferExtendedCell |
(package private) static class |
PrivateCellUtil.TagRewriteCell
This can be used when a Cell has to change with addition/removal of one or more tags.
|
(package private) static class |
PrivateCellUtil.ValueAndTagRewriteByteBufferExtendedCell |
(package private) static class |
PrivateCellUtil.ValueAndTagRewriteCell |
Modifier | Constructor and Description |
---|---|
private |
PrivateCellUtil()
Private constructor to keep this class from being instantiated.
|
Modifier and Type | Method and Description |
---|---|
static byte[] |
cloneTags(Cell cell) |
static int |
compare(CellComparator comparator,
Cell left,
byte[] key,
int offset,
int length)
Used when a cell needs to be compared with a key byte[] such as cases of finding the index from
the index block, bloom keys from the bloom blocks This byte[] is expected to be serialized in
the KeyValue serialization format If the KeyValue (Cell's) serialization format changes this
method cannot be used.
|
static int |
compareFamily(Cell cell,
ByteArrayComparable comparator)
Compare cell's column family against given comparator
|
static int |
compareKeyBasedOnColHint(CellComparator comparator,
Cell nextIndexedCell,
Cell currentCell,
int foff,
int flen,
byte[] colHint,
int coff,
int clen,
long ts,
byte type)
Used to compare two cells based on the column hint provided.
|
static int |
compareKeyIgnoresMvcc(CellComparator comparator,
Cell left,
Cell right)
Compares only the key portion of a cell.
|
static int |
compareQualifier(Cell cell,
ByteArrayComparable comparator)
Compare cell's qualifier against given comparator
|
static int |
compareRow(Cell cell,
ByteArrayComparable comparator)
Compare cell's row against given comparator
|
static int |
compareValue(Cell cell,
ByteArrayComparable comparator)
Compare cell's value against given comparator
|
(package private) static int |
compareWithoutRow(CellComparator comparator,
Cell left,
byte[] right,
int roffset,
int rlength,
short rowlength)
Compare columnFamily, qualifier, timestamp, and key type (everything except the row).
|
static void |
compressFamily(OutputStream out,
Cell cell,
Dictionary dict) |
static void |
compressQualifier(OutputStream out,
Cell cell,
Dictionary dict) |
static void |
compressRow(OutputStream out,
Cell cell,
Dictionary dict) |
static void |
compressTags(OutputStream out,
Cell cell,
TagCompressionContext tagCompressionContext)
Compresses the tags to the given outputstream using the TagcompressionContext
|
static int |
copyTagsTo(Cell cell,
byte[] destination,
int destinationOffset)
Copies the tags info into the tag portion of the cell
|
static int |
copyTagsTo(Cell cell,
ByteBuffer destination,
int destinationOffset)
Copies the tags info into the tag portion of the cell
|
static Cell |
createCell(Cell cell,
byte[] tags) |
static Cell |
createCell(Cell cell,
byte[] value,
byte[] tags) |
static Cell |
createCell(Cell cell,
List<Tag> tags) |
static Cell |
createFirstDeleteFamilyCellOnRow(byte[] row,
byte[] fam)
Create a Delete Family Cell 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 Cell |
createFirstOnNextRow(Cell cell) |
static Cell |
createFirstOnRow(byte[] row) |
static Cell |
createFirstOnRow(byte[] row,
byte[] family,
byte[] col) |
static Cell |
createFirstOnRow(byte[] row,
int roffset,
short rlength) |
static Cell |
createFirstOnRow(byte[] row,
int roffset,
short rlength,
byte[] family,
int foffset,
byte flength,
byte[] col,
int coffset,
int clength) |
static Cell |
createFirstOnRow(Cell cell)
Create a Cell that is smaller than all other possible Cells for the given Cell's row.
|
static Cell |
createFirstOnRowCol(Cell cell) |
static Cell |
createFirstOnRowCol(Cell cell,
byte[] qArray,
int qoffest,
int qlength)
Create a Cell that is smaller than all other possible Cells for the given Cell's rk:cf and
passed qualifier.
|
static Cell |
createFirstOnRowColTS(Cell cell,
long ts)
Creates the first cell with the row/family/qualifier of this cell and the given timestamp.
|
static Cell |
createFirstOnRowFamily(Cell cell,
byte[] fArray,
int foff,
int flen) |
static Cell |
createLastOnRow(byte[] row) |
static Cell |
createLastOnRow(Cell cell)
Create a Cell that is larger than all other possible Cells for the given Cell's row.
|
static Cell |
createLastOnRowCol(Cell cell)
Create a Cell that is larger than all other possible Cells for the given Cell's rk:cf:q.
|
static Cell |
createNextOnRowCol(Cell cell) |
(package private) static Cell |
createNextOnRowCol(Cell cell,
long ts,
byte type) |
static Cell |
deepClone(Cell cell)
Deep clones the given cell if the cell supports deep cloning
|
static boolean |
equalsIgnoreMvccVersion(Cell a,
Cell b)
special case for Cell.equals
|
static int |
estimatedSerializedSizeOf(Cell cell)
Estimate based on keyvalue's serialization format in the RPC layer.
|
static int |
estimatedSerializedSizeOfKey(Cell cell)
Calculates the serialized key size.
|
static long |
estimatedSizeOfCell(Cell cell)
This is an estimate of the heap space occupied by a cell.
|
static ByteRange |
fillFamilyRange(Cell cell,
ByteRange range) |
static ByteRange |
fillQualifierRange(Cell cell,
ByteRange range) |
static ByteRange |
fillRowRange(Cell cell,
ByteRange range)
ByteRange
|
static ByteRange |
fillTagRange(Cell cell,
ByteRange range) |
static ByteRange |
fillValueRange(Cell cell,
ByteRange range) |
static int |
findCommonPrefixInFlatKey(Cell c1,
Cell c2,
boolean bypassFamilyCheck,
boolean withTsType)
Find length of common prefix in keys of the cells, considering key as byte[] if serialized in
KeyValue . |
static byte[] |
getCellKeySerializedAsKeyValueKey(Cell cell)
This method exists just to encapsulate how we serialize keys.
|
static byte |
getQualifierByte(Cell cell,
int index) |
static int |
getRowAsInt(Cell cell)
Converts the rowkey bytes of the given cell into an int value
|
static byte |
getRowByte(Cell cell,
int index)
misc
|
private static int |
getSumOfCellElementLengths(Cell cell) |
private static int |
getSumOfCellKeyElementLengths(Cell cell) |
static Optional<Tag> |
getTag(Cell cell,
byte type)
Retrieve Cell's first tag, matching the passed in type
|
static List<Tag> |
getTags(Cell cell) |
static BigDecimal |
getValueAsBigDecimal(Cell cell)
Converts the value bytes of the given cell into a BigDecimal
|
static double |
getValueAsDouble(Cell cell)
Converts the value bytes of the given cell into a double value
|
static int |
getValueAsInt(Cell cell)
Converts the value bytes of the given cell into a int value
|
static long |
getValueAsLong(Cell cell)
Converts the value bytes of the given cell into a long value
|
static ByteBuffer |
getValueBufferShallowCopy(Cell cell) |
static boolean |
isDelete(byte type) |
static boolean |
isDeleteColumnOrFamily(Cell cell) |
static boolean |
isDeleteColumns(Cell cell) |
static boolean |
isDeleteColumnVersion(Cell cell) |
static boolean |
isDeleteFamily(Cell cell) |
static boolean |
isDeleteFamilyVersion(Cell cell) |
static boolean |
isDeleteType(Cell cell) |
static boolean |
matchingColumn(Cell left,
byte[] fam,
int foffset,
int flength,
byte[] qual,
int qoffset,
int qlength) |
static boolean |
matchingFamily(Cell left,
byte[] buf,
int offset,
int length) |
static boolean |
matchingQualifier(Cell left,
byte[] buf,
int offset,
int length)
Finds if the qualifier part of the cell and the KV serialized byte[] are equal
|
static boolean |
matchingRows(Cell left,
byte[] buf,
int offset,
int length) |
static boolean |
matchingType(Cell a,
Cell b) |
static boolean |
matchingValue(Cell left,
Cell right,
int lvlength,
int rvlength) |
static boolean |
overlappingKeys(byte[] start1,
byte[] end1,
byte[] start2,
byte[] end2)
Returns true if the first range start1...end1 overlaps with the second range start2...end2,
assuming the byte arrays represent row keys
|
static boolean |
qualifierStartsWith(Cell left,
byte[] startsWith)
Finds if the start of the qualifier part of the Cell matches
buf |
static void |
setSequenceId(Cell cell,
long seqId)
Sets the given seqId to the cell.
|
static void |
setTimestamp(Cell cell,
byte[] ts)
Sets the given timestamp to the cell.
|
static void |
setTimestamp(Cell cell,
long ts)
Sets the given timestamp to the cell.
|
static Iterator<Tag> |
tagsIterator(ByteBuffer tags,
int offset,
int length) |
static Iterator<Tag> |
tagsIterator(Cell cell)
Util method to iterate through the tags in the given cell.
|
static Cell.Type |
toType(byte type) |
static KeyValue.Type |
toTypeByte(Cell.Type type) |
static boolean |
updateLatestStamp(Cell cell,
byte[] ts)
Sets the given timestamp to the cell iff current timestamp is
HConstants.LATEST_TIMESTAMP . |
static boolean |
updateLatestStamp(Cell cell,
long ts)
Sets the given timestamp to the cell iff current timestamp is
HConstants.LATEST_TIMESTAMP . |
static int |
writeCell(Cell cell,
OutputStream out,
boolean withTags)
Writes the cell to the given OutputStream
|
static void |
writeCellToBuffer(Cell cell,
ByteBuffer buf,
int offset)
Writes a cell to the buffer at the given offset
|
static void |
writeFamily(OutputStream out,
Cell cell,
byte flength)
Writes the family from the given cell to the output stream
|
static void |
writeFlatKey(Cell cell,
DataOutput out)
Writes the Cell's key part as it would have serialized in a KeyValue.
|
static int |
writeFlatKey(Cell cell,
OutputStream out) |
static void |
writeQualifier(OutputStream out,
Cell cell,
int qlength)
Writes the qualifier from the given cell to the output stream
|
static void |
writeQualifierSkippingBytes(DataOutputStream out,
Cell cell,
int qlength,
int commonPrefix)
Writes the qualifier from the given cell to the output stream excluding the common prefix
|
static void |
writeRow(OutputStream out,
Cell cell,
short rlength)
Writes the row from the given cell to the output stream
|
static void |
writeRowKeyExcludingCommon(Cell cell,
short rLen,
int commonPrefix,
DataOutputStream out)
Write rowkey excluding the common part.
|
static void |
writeRowSkippingBytes(DataOutputStream out,
Cell cell,
short rlength,
int commonPrefix)
Writes the row from the given cell to the output stream excluding the common prefix
|
static void |
writeTags(OutputStream out,
Cell cell,
int tagsLength)
Writes the tag from the given cell to the output stream
|
static void |
writeValue(OutputStream out,
Cell cell,
int vlength)
Writes the value from the given cell to the output stream
|
private PrivateCellUtil()
public static ByteRange fillRowRange(Cell cell, ByteRange range)
public static ByteRange fillFamilyRange(Cell cell, ByteRange range)
public static ByteRange fillQualifierRange(Cell cell, ByteRange range)
public static ByteRange fillValueRange(Cell cell, ByteRange range)
public static ByteRange fillTagRange(Cell cell, ByteRange range)
public static byte getRowByte(Cell cell, int index)
public static byte getQualifierByte(Cell cell, int index)
public static ByteBuffer getValueBufferShallowCopy(Cell cell)
public static Cell createCell(Cell cell, List<Tag> tags)
public static Cell createCell(Cell cell, byte[] tags)
public static Cell createCell(Cell cell, byte[] value, byte[] tags)
public static boolean matchingRows(Cell left, byte[] buf, int offset, int length)
public static boolean matchingFamily(Cell left, byte[] buf, int offset, int length)
public static boolean matchingQualifier(Cell left, byte[] buf, int offset, int length)
left
- the cell with which we need to match the qualifierbuf
- the serialized keyvalue format byte[]offset
- the offset of the qualifier in the byte[]length
- the length of the qualifier in the byte[]public static boolean qualifierStartsWith(Cell left, byte[] startsWith)
buf
left
- the cell with which we need to match the qualifierstartsWith
- the serialized keyvalue format byte[]public static boolean matchingColumn(Cell left, byte[] fam, int foffset, int flength, byte[] qual, int qoffset, int qlength)
public static boolean matchingValue(Cell left, Cell right, int lvlength, int rvlength)
public static boolean matchingType(Cell a, Cell b)
public static boolean isDelete(byte type)
KeyValue.Type.Delete
or a {KeyValue.Type#DeleteFamily}
or a KeyValue.Type.DeleteColumn
KeyValue type.public static boolean isDeleteType(Cell cell)
KeyValue.Type.Delete
type.public static boolean isDeleteFamily(Cell cell)
public static boolean isDeleteFamilyVersion(Cell cell)
public static boolean isDeleteColumns(Cell cell)
public static boolean isDeleteColumnVersion(Cell cell)
public static boolean isDeleteColumnOrFamily(Cell cell)
public static int copyTagsTo(Cell cell, byte[] destination, int destinationOffset)
cell
- destination
- destinationOffset
- public static int copyTagsTo(Cell cell, ByteBuffer destination, int destinationOffset)
cell
- destination
- destinationOffset
- public static List<Tag> getTags(Cell cell)
cell
- The Cellpublic static Optional<Tag> getTag(Cell cell, byte type)
cell
- The Celltype
- Type of the Tag to retrievepublic static Iterator<Tag> tagsIterator(Cell cell)
cell
- The Cell over which tags iterator is needed.public static Iterator<Tag> tagsIterator(ByteBuffer tags, int offset, int length)
public static boolean overlappingKeys(byte[] start1, byte[] end1, byte[] start2, byte[] end2)
public static void writeRowKeyExcludingCommon(Cell cell, short rLen, int commonPrefix, DataOutputStream out) throws IOException
cell
- rLen
- commonPrefix
- out
- IOException
public static void writeRowSkippingBytes(DataOutputStream out, Cell cell, short rlength, int commonPrefix) throws IOException
out
- The dataoutputstream to which the data has to be writtencell
- The cell whose contents has to be writtenrlength
- the row lengthIOException
public static int findCommonPrefixInFlatKey(Cell c1, Cell c2, boolean bypassFamilyCheck, boolean withTsType)
KeyValue
. The key format is <2 bytes rk len><rk><1 byte cf
len><cf><qualifier><8 bytes timestamp><1 byte type>c1
- the cellc2
- the cellbypassFamilyCheck
- when true assume the family bytes same in both cells. Pass it as true
when dealing with Cells in same CF so as to avoid some checkswithTsType
- when true check timestamp and type bytes also.public static final int compareKeyBasedOnColHint(CellComparator comparator, Cell nextIndexedCell, Cell currentCell, int foff, int flen, byte[] colHint, int coff, int clen, long ts, byte type)
nextIndexedCell
- the next indexed cellcurrentCell
- the cell to be comparedfoff
- the family offset of the currentCellflen
- the family length of the currentCellcolHint
- the column hint provided - could be nullcoff
- the offset of the column hint if provided, if not offset of the currentCell's
qualifierclen
- the length of the column hint if provided, if not length of the currentCell's
qualifierts
- the timestamp to be seekedtype
- the type to be seekedpublic static final int compareKeyIgnoresMvcc(CellComparator comparator, Cell left, Cell right)
left
- right
- public static int compareRow(Cell cell, ByteArrayComparable comparator)
cell
- the cell to use for comparisoncomparator
- the CellComparator
to use for comparisonpublic static int compareFamily(Cell cell, ByteArrayComparable comparator)
cell
- the cell to use for comparisoncomparator
- the CellComparator
to use for comparisonpublic static int compareQualifier(Cell cell, ByteArrayComparable comparator)
cell
- the cell to use for comparisoncomparator
- the CellComparator
to use for comparisonpublic static KeyValue.Type toTypeByte(Cell.Type type)
public static int compareValue(Cell cell, ByteArrayComparable comparator)
cell
- the cell to use for comparisoncomparator
- the CellComparator
to use for comparisonpublic static void writeFlatKey(Cell cell, DataOutput out) throws IOException
cell
- out
- IOException
public static Cell deepClone(Cell cell) throws CloneNotSupportedException
cell
- the cell to be clonedCloneNotSupportedException
public static int writeCell(Cell cell, OutputStream out, boolean withTags) throws IOException
cell
- the cell to be writtenout
- the outputstreamwithTags
- if tags are to be written or notIOException
public static void writeCellToBuffer(Cell cell, ByteBuffer buf, int offset)
cell
- the cell to be writtenbuf
- the buffer to which the cell has to be wrritenoffset
- the offset at which the cell should be writtenpublic static int writeFlatKey(Cell cell, OutputStream out) throws IOException
IOException
public static void setSequenceId(Cell cell, long seqId) throws IOException
cell
- seqId
- IOException
- when the passed cell is not of type ExtendedCell
public static void setTimestamp(Cell cell, long ts) throws IOException
cell
- ts
- IOException
- when the passed cell is not of type ExtendedCell
public static void setTimestamp(Cell cell, byte[] ts) throws IOException
cell
- ts
- buffer containing the timestamp valueIOException
- when the passed cell is not of type ExtendedCell
public static boolean updateLatestStamp(Cell cell, long ts) throws IOException
HConstants.LATEST_TIMESTAMP
.cell
- ts
- IOException
- when the passed cell is not of type ExtendedCell
public static boolean updateLatestStamp(Cell cell, byte[] ts) throws IOException
HConstants.LATEST_TIMESTAMP
.cell
- ts
- buffer containing the timestamp valueIOException
- when the passed cell is not of type ExtendedCell
public static void writeRow(OutputStream out, Cell cell, short rlength) throws IOException
out
- The outputstream to which the data has to be writtencell
- The cell whose contents has to be writtenrlength
- the row lengthIOException
public static void writeFamily(OutputStream out, Cell cell, byte flength) throws IOException
out
- The outputstream to which the data has to be writtencell
- The cell whose contents has to be writtenflength
- the family lengthIOException
public static void writeQualifier(OutputStream out, Cell cell, int qlength) throws IOException
out
- The outputstream to which the data has to be writtencell
- The cell whose contents has to be writtenqlength
- the qualifier lengthIOException
public static void writeQualifierSkippingBytes(DataOutputStream out, Cell cell, int qlength, int commonPrefix) throws IOException
out
- The dataoutputstream to which the data has to be writtencell
- The cell whose contents has to be writtenqlength
- the qualifier lengthIOException
public static void writeValue(OutputStream out, Cell cell, int vlength) throws IOException
out
- The outputstream to which the data has to be writtencell
- The cell whose contents has to be writtenvlength
- the value lengthIOException
public static void writeTags(OutputStream out, Cell cell, int tagsLength) throws IOException
out
- The outputstream to which the data has to be writtencell
- The cell whose contents has to be writtentagsLength
- the tag lengthIOException
public static boolean equalsIgnoreMvccVersion(Cell a, Cell b)
public static int getRowAsInt(Cell cell)
cell
- public static long getValueAsLong(Cell cell)
cell
- public static int getValueAsInt(Cell cell)
cell
- public static double getValueAsDouble(Cell cell)
cell
- public static BigDecimal getValueAsBigDecimal(Cell cell)
cell
- public static void compressTags(OutputStream out, Cell cell, TagCompressionContext tagCompressionContext) throws IOException
out
- the outputstream to which the compression should happencell
- the cell which has tagstagCompressionContext
- the TagCompressionContextIOException
- can throw IOException if the compression encounters issuepublic static void compressRow(OutputStream out, Cell cell, Dictionary dict) throws IOException
IOException
public static void compressFamily(OutputStream out, Cell cell, Dictionary dict) throws IOException
IOException
public static void compressQualifier(OutputStream out, Cell cell, Dictionary dict) throws IOException
IOException
public static final int compare(CellComparator comparator, Cell left, byte[] key, int offset, int length)
comparator
- the CellComparator
to use for comparisonleft
- the cell to be comparedkey
- the serialized key part of a KeyValueoffset
- the offset in the key byte[]length
- the length of the key byte[]static final int compareWithoutRow(CellComparator comparator, Cell left, byte[] right, int roffset, int rlength, short rowlength)
comparator
- the CellComparator
to use for comparisonleft
- the cell to be comparedright
- the serialized key part of a key-valueroffset
- the offset in the key byte[]rlength
- the length of the key byte[]rowlength
- the row lengthpublic static Cell createNextOnRowCol(Cell cell)
static Cell createNextOnRowCol(Cell cell, long ts, byte type)
public static int estimatedSerializedSizeOf(Cell cell)
cell
- cell
size in bytes plus an extra SIZEOF_INT indicating the
actual cell length.private static int getSumOfCellElementLengths(Cell cell)
cell
- private static int getSumOfCellKeyElementLengths(Cell cell)
cell
- public static int estimatedSerializedSizeOfKey(Cell cell)
cell
- the cell for which the key size has to be calculated.public static long estimatedSizeOfCell(Cell cell)
HeapSize
we call HeapSize.heapSize()
so cell can give a correct value. In other
cases we just consider the bytes occupied by the cell components ie. row, CF, qualifier,
timestamp, type, value and tags.
Note that this can be the JVM heap space (on-heap) or the OS heap (off-heap)cell
- public static byte[] getCellKeySerializedAsKeyValueKey(Cell cell)
cell
- cell
public static Cell createFirstOnRow(Cell cell)
cell
- public static Cell createFirstOnRow(byte[] row, int roffset, short rlength)
public static Cell createFirstOnRow(byte[] row, byte[] family, byte[] col)
public static Cell createFirstOnRow(byte[] row, int roffset, short rlength, byte[] family, int foffset, byte flength, byte[] col, int coffset, int clength)
public static Cell createFirstOnRow(byte[] row)
public static Cell createFirstOnRowFamily(Cell cell, byte[] fArray, int foff, int flen)
public static Cell createFirstOnRowCol(Cell cell)
public static Cell createFirstOnNextRow(Cell cell)
public static Cell createFirstOnRowCol(Cell cell, byte[] qArray, int qoffest, int qlength)
cell
- qArray
- qoffest
- qlength
- public static Cell createFirstOnRowColTS(Cell cell, long ts)
cell
- - cellts
- public static Cell createLastOnRow(Cell cell)
cell
- public static Cell createLastOnRow(byte[] row)
public static Cell createLastOnRowCol(Cell cell)
cell
- public static Cell createFirstDeleteFamilyCellOnRow(byte[] row, byte[] fam)
row
- - row key (arbitrary byte array)fam
- - family namerow
.Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.