Package org.apache.hadoop.hbase
Class CellUtil
java.lang.Object
org.apache.hadoop.hbase.CellUtil
Utility methods helpful for slinging
Cell
instances. Some methods below are for internal
use only and are marked InterfaceAudience.Private at the method level. Note that all such methods
have been marked deprecated in HBase-2.0 which will be subsequently removed in HBase-3.0-
Constructor Summary
ModifierConstructorDescriptionprivate
CellUtil()
Private constructor to keep this class from being instantiated. -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
cloneFamily
(Cell cell) static void
cloneIfNecessary
(ArrayList<Cell> cells) static Cell
cloneIfNecessary
(Cell cell) static byte[]
cloneQualifier
(Cell cell) static byte[]
get individual arrays for testsstatic byte[]
cloneValue
(Cell cell) static final int
compareColumns
(Cell left, byte[] right, int rfoffset, int rflength, int rqoffset, int rqlength) Compares the cell's column (family and qualifier) with the given byte[]static final int
compareFamilies
(Cell left, byte[] right, int roffset, int rlength) Compares the cell's family with the given byte[]static final int
compareQualifiers
(Cell left, byte[] right, int rOffset, int rLength) Compares the cell's qualifier with the given byte[]static int
copyFamilyTo
(Cell cell, byte[] destination, int destinationOffset) Copies the family to the given byte[]static int
copyFamilyTo
(Cell cell, ByteBuffer destination, int destinationOffset) Copies the family to the given bytebufferstatic int
copyQualifierTo
(Cell cell, byte[] destination, int destinationOffset) Copies the qualifier to the given byte[]static int
copyQualifierTo
(Cell cell, ByteBuffer destination, int destinationOffset) Copies the qualifier to the given bytebufferstatic byte[]
Copies the row to a new byte[]static int
Copies the row to the given byte[]static int
copyRowTo
(Cell cell, ByteBuffer destination, int destinationOffset) Copies the row to the given bytebufferstatic int
copyValueTo
(Cell cell, byte[] destination, int destinationOffset) Copies the value to the given byte[]static int
copyValueTo
(Cell cell, ByteBuffer destination, int destinationOffset) Copies the value to the given bytebufferstatic CellScanner
createCellScanner
(Iterable<Cell> cellIterable) Returns CellScanner interface overcellIterable
static CellScanner
createCellScanner
(Iterator<Cell> cells) Returns CellScanner interface overcellIterable
or null ifcells
is nullstatic CellScanner
createCellScanner
(List<? extends CellScannable> cellScannerables) Returns CellScanner interface overcellIterables
static CellScanner
createCellScanner
(NavigableMap<byte[], List<Cell>> map) Flatten the map of cells out under the CellScannerstatic CellScanner
createCellScanner
(Cell[] cellArray) Returns CellScanner interface overcellArray
static boolean
equalsstatic String
getCellKeyAsString
(Cell cell) Returns The Key portion of the passedcell
as a String.static String
getCellKeyAsString
(Cell cell, Function<Cell, String> rowConverter) Return the Key portion of the passedcell
as a String.static boolean
Return true if a delete type, aKeyValue.Type.Delete
or a {KeyValue.Type#DeleteFamily} or aKeyValue.Type.DeleteColumn
KeyValue type.static boolean
Returns True if this cell is a Put.static byte[]
makeColumn
(byte[] family, byte[] qualifier) Makes a column in family:qualifier form from separate byte arrays.static boolean
matchingColumn
(Cell left, byte[] fam, byte[] qual) private static boolean
matchingColumn
(Cell left, byte lFamLen, int lQualLength, Cell right, byte rFamLen, int rQualLength) static boolean
matchingColumn
(Cell left, Cell right) static boolean
matchingColumnFamilyAndQualifierPrefix
(Cell left, byte[] fam, byte[] qual) Returns True if matching column family and the qualifier starts withqual
static boolean
matchingFamily
(Cell left, byte[] buf) static boolean
matchingFamily
(Cell left, byte lfamlength, Cell right, byte rfamlength) static boolean
matchingFamily
(Cell left, Cell right) static boolean
matchingQualifier
(Cell left, byte[] buf) Finds if the qualifier part of the cell and the KV serialized byte[] are equal.private static boolean
matchingQualifier
(Cell left, int lqlength, Cell right, int rqlength) static boolean
matchingQualifier
(Cell left, Cell right) static boolean
matchingRow
(Cell left, byte[] buf, int offset, int length) static boolean
matchingRowColumn
(Cell left, Cell right) Compares the row and column of two keyvalues for equalitystatic boolean
matchingRowColumnBytes
(Cell left, Cell right) Compares the row and column of two keyvalues for equalitystatic boolean
matchingRows
(Cell left, byte[] buf) static boolean
matchingRows
(Cell left, short lrowlength, Cell right, short rrowlength) Compares the row of two keyvalues for equalitystatic boolean
matchingRows
(Cell left, Cell right) Compares the row of two keyvalues for equalitystatic boolean
matchingTags
(Cell left, Cell right) Deprecated.Since 3.0.0, will be removed in 4.0.0.static boolean
matchingTimestamp
(Cell a, Cell b) static boolean
matchingValue
(Cell left, byte[] buf) static boolean
matchingValue
(Cell left, Cell right) static boolean
matchingValue
(Cell left, Cell right, int lvlength, int rvlength) static byte[][]
parseColumn
(byte[] c) Splits a column infamily:qualifier
form into separate byte arrays.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 String
Returns a string representation of the cell
-
Constructor Details
-
CellUtil
private CellUtil()Private constructor to keep this class from being instantiated.
-
-
Method Details
-
cloneRow
get individual arrays for tests -
cloneFamily
-
cloneQualifier
-
cloneValue
-
makeColumn
Makes a column in family:qualifier form from separate byte arrays.Not recommended for usage as this is old-style API.
- Returns:
- family:qualifier
-
parseColumn
Splits a column infamily: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.
- Parameters:
c
- The column.- Returns:
- The parsed column.
-
copyRowTo
Copies the row to the given byte[]- Parameters:
cell
- the cell whose row has to be copieddestination
- the destination byte[] to which the row has to be copieddestinationOffset
- the offset in the destination byte[]- Returns:
- the offset of the byte[] after the copy has happened
-
copyRowTo
Copies the row to the given bytebuffer- Parameters:
cell
- cell the cell whose row has to be copieddestination
- the destination bytebuffer to which the row has to be copieddestinationOffset
- the offset in the destination byte[]- Returns:
- the offset of the bytebuffer after the copy has happened
-
copyRow
Copies the row to a new byte[]- Parameters:
cell
- the cell from which row has to copied- Returns:
- the byte[] containing the row
-
copyFamilyTo
Copies the family to the given byte[]- Parameters:
cell
- the cell whose family has to be copieddestination
- the destination byte[] to which the family has to be copieddestinationOffset
- the offset in the destination byte[]- Returns:
- the offset of the byte[] after the copy has happened
-
copyFamilyTo
Copies the family to the given bytebuffer- Parameters:
cell
- the cell whose family has to be copieddestination
- the destination bytebuffer to which the family has to be copieddestinationOffset
- the offset in the destination bytebuffer- Returns:
- the offset of the bytebuffer after the copy has happened
-
copyQualifierTo
Copies the qualifier to the given byte[]- Parameters:
cell
- the cell whose qualifier has to be copieddestination
- the destination byte[] to which the qualifier has to be copieddestinationOffset
- the offset in the destination byte[]- Returns:
- the offset of the byte[] after the copy has happened
-
copyQualifierTo
Copies the qualifier to the given bytebuffer- Parameters:
cell
- the cell whose qualifier has to be copieddestination
- the destination bytebuffer to which the qualifier has to be copieddestinationOffset
- the offset in the destination bytebuffer- Returns:
- the offset of the bytebuffer after the copy has happened
-
copyValueTo
Copies the value to the given byte[]- Parameters:
cell
- the cell whose value has to be copieddestination
- the destination byte[] to which the value has to be copieddestinationOffset
- the offset in the destination byte[]- Returns:
- the offset of the byte[] after the copy has happened
-
copyValueTo
Copies the value to the given bytebuffer- Parameters:
cell
- the cell whose value has to be copieddestination
- the destination bytebuffer to which the value has to be copieddestinationOffset
- the offset in the destination bytebuffer- Returns:
- the offset of the bytebuffer after the copy has happened
-
createCellScanner
Returns CellScanner interface overcellIterables
-
createCellScanner
Returns CellScanner interface overcellIterable
-
createCellScanner
Returns CellScanner interface overcellIterable
or null ifcells
is null -
createCellScanner
Returns CellScanner interface overcellArray
-
matchingRows
-
matchingRow
-
matchingFamily
-
matchingFamily
-
matchingFamily
-
matchingQualifier
-
matchingQualifier
-
matchingQualifier
Finds if the qualifier part of the cell and the KV serialized byte[] are equal.- Returns:
- true if the qualifier matches, false otherwise
-
matchingColumn
-
matchingColumnFamilyAndQualifierPrefix
Returns True if matching column family and the qualifier starts withqual
-
matchingColumn
-
matchingColumn
private static boolean matchingColumn(Cell left, byte lFamLen, int lQualLength, Cell right, byte rFamLen, int rQualLength) -
matchingValue
-
matchingValue
-
matchingValue
-
matchingTags
Deprecated.Since 3.0.0, will be removed in 4.0.0. Tags are now internal only, you should not try to check it through theCell
interface. -
isDelete
Return true if a delete type, aKeyValue.Type.Delete
or a {KeyValue.Type#DeleteFamily} or aKeyValue.Type.DeleteColumn
KeyValue type. -
isPut
Returns True if this cell is a Put. -
setTimestamp
@LimitedPrivate("Coprocesssor") public static void setTimestamp(Cell cell, long ts) throws IOException Sets the given timestamp to the cell. Note that this method is a LimitedPrivate API and may change between minor releases.- Throws:
IOException
- when the passed cell is not of typeExtendedCell
-
setTimestamp
@LimitedPrivate("Coprocesssor") public static void setTimestamp(Cell cell, byte[] ts, int tsOffset) throws IOException Sets the given timestamp to the cell. Note that this method is a LimitedPrivate API and may change between minor releases.- Throws:
IOException
- when the passed cell is not of typeExtendedCell
-
getCellKeyAsString
Returns The Key portion of the passedcell
as a String. -
getCellKeyAsString
Return the Key portion of the passedcell
as a String.- Parameters:
cell
- the cell to convertrowConverter
- used to convert the row of the cell to a string- Returns:
- The Key portion of the passed
cell
as a String.
-
toString
Returns a string representation of the cell -
equals
equals -
matchingTimestamp
-
matchingRows
Compares the row of two keyvalues for equality -
matchingRows
Compares the row of two keyvalues for equality -
matchingRowColumn
Compares the row and column of two keyvalues for equality -
matchingRowColumnBytes
Compares the row and column of two keyvalues for equality -
compareQualifiers
Compares the cell's qualifier with the given byte[]- Parameters:
left
- the cell for which the qualifier has to be comparedright
- the byte[] having the qualifierrOffset
- the offset of the qualifierrLength
- the length of the qualifier- Returns:
- greater than 0 if left cell's qualifier is bigger than byte[], lesser than 0 if left cell's qualifier is lesser than byte[] and 0 otherwise
-
compareFamilies
Compares the cell's family with the given byte[]- Parameters:
left
- the cell for which the family has to be comparedright
- the byte[] having the familyroffset
- the offset of the familyrlength
- the length of the family- Returns:
- greater than 0 if left cell's family is bigger than byte[], lesser than 0 if left cell's family is lesser than byte[] and 0 otherwise
-
compareColumns
public static final int compareColumns(Cell left, byte[] right, int rfoffset, int rflength, int rqoffset, int rqlength) Compares the cell's column (family and qualifier) with the given byte[]- Parameters:
left
- the cell for which the column has to be comparedright
- the byte[] having the columnrfoffset
- the offset of the familyrflength
- the length of the familyrqoffset
- the offset of the qualifierrqlength
- the length of the qualifier- Returns:
- greater than 0 if left cell's column is bigger than byte[], lesser than 0 if left cell's column is lesser than byte[] and 0 otherwise
-
cloneIfNecessary
-
cloneIfNecessary
-