@InterfaceAudience.Public @InterfaceStability.Evolving public final class CellUtil extends Object
Cell
instances.
Some methods below are for internal use only and are marked InterfaceAudience.Private at the
method level.Constructor and Description |
---|
CellUtil() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
cloneFamily(Cell cell) |
static byte[] |
cloneQualifier(Cell cell) |
static byte[] |
cloneRow(Cell cell)
get individual arrays for tests
|
static byte[] |
cloneValue(Cell cell) |
static int |
copyFamilyTo(Cell cell,
byte[] destination,
int destinationOffset) |
static int |
copyQualifierTo(Cell cell,
byte[] destination,
int destinationOffset) |
static int |
copyRowTo(Cell cell,
byte[] destination,
int destinationOffset)
copyTo
|
static int |
copyTagTo(Cell cell,
byte[] destination,
int destinationOffset)
Copies the tags info into the tag portion of the cell
|
static int |
copyValueTo(Cell cell,
byte[] destination,
int destinationOffset) |
static Cell |
createCell(byte[] row)
Create a Cell with specific row.
|
static Cell |
createCell(byte[] row,
byte[] value)
Create a Cell with specific row and value.
|
static Cell |
createCell(byte[] row,
byte[] family,
byte[] qualifier)
Create a Cell with specific row.
|
static Cell |
createCell(byte[] row,
byte[] family,
byte[] qualifier,
long timestamp,
byte type,
byte[] value) |
static Cell |
createCell(byte[] row,
byte[] family,
byte[] qualifier,
long timestamp,
byte type,
byte[] value,
byte[] tags,
long memstoreTS)
Marked as audience Private as of 1.2.0.
|
static Cell |
createCell(byte[] row,
byte[] family,
byte[] qualifier,
long timestamp,
byte type,
byte[] value,
long memstoreTS)
Marked as audience Private as of 1.2.0.
|
static Cell |
createCell(byte[] row,
byte[] family,
byte[] qualifier,
long timestamp,
KeyValue.Type type,
byte[] value,
byte[] tags)
Marked as audience Private as of 1.2.0.
|
static Cell |
createCell(byte[] rowArray,
int rowOffset,
int rowLength,
byte[] familyArray,
int familyOffset,
int familyLength,
byte[] qualifierArray,
int qualifierOffset,
int qualifierLength) |
static CellScanner |
createCellScanner(Cell[] cellArray) |
static CellScanner |
createCellScanner(Iterable<Cell> cellIterable) |
static CellScanner |
createCellScanner(Iterator<Cell> cells) |
static CellScanner |
createCellScanner(List<? extends CellScannable> cellScannerables) |
static CellScanner |
createCellScanner(NavigableMap<byte[],List<Cell>> map)
Flatten the map of cells out under the CellScanner
|
static boolean |
equals(Cell a,
Cell b)
equals
|
static long |
estimatedHeapSizeOf(Cell cell)
This is an estimate of the heap space occupied by a cell.
|
static long |
estimatedHeapSizeOfWithoutTags(Cell cell)
Deprecated.
|
static int |
estimatedSerializedSizeOf(Cell cell) |
static int |
estimatedSerializedSizeOfKey(Cell cell) |
static int |
estimatedSizeOf(Cell cell)
Deprecated.
please use estimatedSerializedSizeOf(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 String |
getCellKeyAsString(Cell cell) |
static byte[] |
getCellKeySerializedAsKeyValueKey(Cell cell)
This method exists just to encapsulate how we serialize keys.
|
static ByteBuffer |
getQualifierBufferShallowCopy(Cell cell) |
static byte |
getRowByte(Cell cell,
int index)
misc
|
private static int |
getSumOfCellElementLengths(Cell cell) |
private static int |
getSumOfCellKeyElementLengths(Cell cell) |
static byte[] |
getTagArray(Cell cell)
Returns tag value in a new byte array.
|
static ByteBuffer |
getValueBufferShallowCopy(Cell cell) |
static boolean |
isDelete(byte type) |
static boolean |
isDelete(Cell cell) |
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,
byte[] qual) |
static boolean |
matchingColumn(Cell left,
byte[] fam,
int foffset,
int flength,
byte[] qual,
int qoffset,
int qlength) |
static boolean |
matchingColumn(Cell left,
Cell right) |
static boolean |
matchingFamily(Cell left,
byte[] buf) |
static boolean |
matchingFamily(Cell left,
byte[] buf,
int offset,
int length) |
static boolean |
matchingFamily(Cell left,
Cell right) |
static boolean |
matchingQualifier(Cell left,
byte[] buf) |
static boolean |
matchingQualifier(Cell left,
byte[] buf,
int offset,
int length) |
static boolean |
matchingQualifier(Cell left,
Cell right) |
static boolean |
matchingRow(Cell left,
byte[] buf) |
static boolean |
matchingRow(Cell left,
byte[] buf,
int offset,
int length) |
static boolean |
matchingRow(Cell left,
Cell right) |
static boolean |
matchingTimestamp(Cell a,
Cell b) |
static boolean |
matchingType(Cell a,
Cell b) |
static boolean |
matchingValue(Cell left,
byte[] buf) |
static boolean |
matchingValue(Cell left,
Cell right) |
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 void |
setSequenceId(Cell cell,
long seqId)
Sets the given seqId to the cell.
|
static void |
setTimestamp(Cell cell,
byte[] ts,
int tsOffset)
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(byte[] tags,
int offset,
int length)
Util method to iterate through the tags
|
static String |
toString(Cell cell,
boolean verbose)
Returns a string representation of the cell
|
static boolean |
updateLatestStamp(Cell cell,
byte[] ts,
int tsOffset)
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 void |
writeFlatKey(Cell cell,
DataOutputStream out)
Writes the Cell's key part as it would have serialized in a KeyValue.
|
static void |
writeRowKeyExcludingCommon(Cell cell,
short rLen,
int commonPrefix,
DataOutputStream out)
Write rowkey excluding the common part.
|
public static byte[] cloneRow(Cell cell)
public static byte[] cloneFamily(Cell cell)
public static byte[] cloneQualifier(Cell cell)
public static byte[] cloneValue(Cell cell)
public static byte[] getTagArray(Cell cell)
Tag.getBuffer()
with appropriate Tag.getTagOffset()
and
Tag.getTagLength()
instead to save on allocations.cell
- public static int copyRowTo(Cell cell, byte[] destination, int destinationOffset)
public static int copyFamilyTo(Cell cell, byte[] destination, int destinationOffset)
public static int copyQualifierTo(Cell cell, byte[] destination, int destinationOffset)
public static int copyValueTo(Cell cell, byte[] destination, int destinationOffset)
public static int copyTagTo(Cell cell, byte[] destination, int destinationOffset)
cell
- destination
- destinationOffset
- public static byte getRowByte(Cell cell, int index)
public static ByteBuffer getValueBufferShallowCopy(Cell cell)
public static ByteBuffer getQualifierBufferShallowCopy(Cell cell)
public static Cell createCell(byte[] row, byte[] family, byte[] qualifier, long timestamp, byte type, byte[] value)
public static Cell createCell(byte[] rowArray, int rowOffset, int rowLength, byte[] familyArray, int familyOffset, int familyLength, byte[] qualifierArray, int qualifierOffset, int qualifierLength)
@InterfaceAudience.Private public static Cell createCell(byte[] row, byte[] family, byte[] qualifier, long timestamp, byte type, byte[] value, long memstoreTS)
@InterfaceAudience.Private public static Cell createCell(byte[] row, byte[] family, byte[] qualifier, long timestamp, byte type, byte[] value, byte[] tags, long memstoreTS)
@InterfaceAudience.Private public static Cell createCell(byte[] row, byte[] family, byte[] qualifier, long timestamp, KeyValue.Type type, byte[] value, byte[] tags)
public static Cell createCell(byte[] row)
row
- public static Cell createCell(byte[] row, byte[] value)
row
- value
- public static Cell createCell(byte[] row, byte[] family, byte[] qualifier)
row
- family
- qualifier
- public static CellScanner createCellScanner(List<? extends CellScannable> cellScannerables)
cellScannerables
- cellIterables
public static CellScanner createCellScanner(Iterable<Cell> cellIterable)
cellIterable
- cellIterable
public static CellScanner createCellScanner(Iterator<Cell> cells)
cells
- cellIterable
or null if cells
is
nullpublic static CellScanner createCellScanner(Cell[] cellArray)
cellArray
- cellArray
public static CellScanner createCellScanner(NavigableMap<byte[],List<Cell>> map)
map
- Map of Cell Lists; for example, the map of families to Cells that is used
inside Put, etc., keeping Cells organized by family.cellIterable
public static boolean matchingRow(Cell left, Cell right)
left
- right
- left
and right
Cells matchpublic static boolean matchingRow(Cell left, byte[] buf)
public static boolean matchingRow(Cell left, byte[] buf, int offset, int length)
public static boolean matchingFamily(Cell left, byte[] buf)
public static boolean matchingFamily(Cell left, byte[] buf, int offset, int length)
public static boolean matchingQualifier(Cell left, byte[] buf)
public static boolean matchingQualifier(Cell left, byte[] buf, int offset, int length)
public static boolean matchingColumn(Cell left, byte[] fam, byte[] qual)
public static boolean matchingColumn(Cell left, byte[] fam, int foffset, int flength, byte[] qual, int qoffset, int qlength)
public static boolean matchingValue(Cell left, byte[] buf)
public static boolean isDelete(Cell cell)
KeyValue.Type.Delete
or a
{KeyValue.Type#DeleteFamily} or a
KeyValue.Type.DeleteColumn
KeyValue type.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)
@Deprecated public static int estimatedSizeOf(Cell cell)
cell
- cell
size in bytes.public static int estimatedSerializedSizeOf(Cell cell)
cell
- cell
size in bytes.private static int getSumOfCellElementLengths(Cell cell)
cell
- private static int getSumOfCellKeyElementLengths(Cell cell)
cell
- public static int estimatedSerializedSizeOfKey(Cell cell)
public static long estimatedHeapSizeOf(Cell cell)
HeapSize
we call HeapSize.heapSize()
so cell can give a correct value. In other
cases we just consider the byte occupied by the cell components ie. row, CF, qualifier,
timestamp, type, value and tags.cell
- @Deprecated public static long estimatedHeapSizeOfWithoutTags(Cell cell)
public static Iterator<Tag> tagsIterator(byte[] tags, int offset, int length)
tags
- offset
- length
- public static boolean overlappingKeys(byte[] start1, byte[] end1, byte[] start2, byte[] end2)
@InterfaceAudience.Private public static void setSequenceId(Cell cell, long seqId) throws IOException
cell
- seqId
- IOException
- when the passed cell is not of type SettableSequenceId
public static void setTimestamp(Cell cell, long ts) throws IOException
cell
- ts
- IOException
- when the passed cell is not of type SettableTimestamp
public static void setTimestamp(Cell cell, byte[] ts, int tsOffset) throws IOException
cell
- ts
- buffer containing the timestamp valuetsOffset
- offset to the new timestampIOException
- when the passed cell is not of type SettableTimestamp
public static boolean updateLatestStamp(Cell cell, long ts) throws IOException
HConstants.LATEST_TIMESTAMP
.cell
- ts
- IOException
- when the passed cell is not of type SettableTimestamp
public static boolean updateLatestStamp(Cell cell, byte[] ts, int tsOffset) throws IOException
HConstants.LATEST_TIMESTAMP
.cell
- ts
- buffer containing the timestamp valuetsOffset
- offset to the new timestampIOException
- when the passed cell is not of type SettableTimestamp
public static void writeFlatKey(Cell cell, DataOutputStream out) throws IOException
cell
- out
- IOException
public static String getCellKeyAsString(Cell cell)
cell
- cell
as a String.public static byte[] getCellKeySerializedAsKeyValueKey(Cell cell)
cell
- cell
public static void writeRowKeyExcludingCommon(Cell cell, short rLen, int commonPrefix, DataOutputStream out) throws IOException
cell
- rLen
- commonPrefix
- out
- IOException
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 String toString(Cell cell, boolean verbose)
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.