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
ConstructorsModifierConstructorDescriptionprivateCellUtil()Private constructor to keep this class from being instantiated. -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]cloneFamily(Cell cell) static voidcloneIfNecessary(ArrayList<Cell> cells) static CellcloneIfNecessary(Cell cell) static byte[]cloneQualifier(Cell cell) static byte[]get individual arrays for testsstatic byte[]cloneValue(Cell cell) static final intcompareColumns(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 intcompareFamilies(Cell left, byte[] right, int roffset, int rlength) Compares the cell's family with the given byte[]static final intcompareQualifiers(Cell left, byte[] right, int rOffset, int rLength) Compares the cell's qualifier with the given byte[]static intcopyFamilyTo(Cell cell, byte[] destination, int destinationOffset) Copies the family to the given byte[]static intcopyFamilyTo(Cell cell, ByteBuffer destination, int destinationOffset) Copies the family to the given bytebufferstatic intcopyQualifierTo(Cell cell, byte[] destination, int destinationOffset) Copies the qualifier to the given byte[]static intcopyQualifierTo(Cell cell, ByteBuffer destination, int destinationOffset) Copies the qualifier to the given bytebufferstatic byte[]Copies the row to a new byte[]static intCopies the row to the given byte[]static intcopyRowTo(Cell cell, ByteBuffer destination, int destinationOffset) Copies the row to the given bytebufferstatic intcopyValueTo(Cell cell, byte[] destination, int destinationOffset) Copies the value to the given byte[]static intcopyValueTo(Cell cell, ByteBuffer destination, int destinationOffset) Copies the value to the given bytebufferstatic CellScannercreateCellScanner(Iterable<Cell> cellIterable) Returns CellScanner interface overcellIterablestatic CellScannercreateCellScanner(Iterator<Cell> cells) Returns CellScanner interface overcellIterableor null ifcellsis nullstatic CellScannercreateCellScanner(List<? extends CellScannable> cellScannerables) Returns CellScanner interface overcellIterablesstatic CellScannercreateCellScanner(NavigableMap<byte[], List<Cell>> map) Flatten the map of cells out under the CellScannerstatic CellScannercreateCellScanner(Cell[] cellArray) Returns CellScanner interface overcellArraystatic booleanequalsstatic StringgetCellKeyAsString(Cell cell) Returns The Key portion of the passedcellas a String.static StringgetCellKeyAsString(Cell cell, Function<Cell, String> rowConverter) Return the Key portion of the passedcellas a String.static booleanReturn true if a delete type, aKeyValue.Type.Deleteor a {KeyValue.Type#DeleteFamily} or aKeyValue.Type.DeleteColumnKeyValue type.static booleanReturns 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 booleanmatchingColumn(Cell left, byte[] fam, byte[] qual) private static booleanmatchingColumn(Cell left, byte lFamLen, int lQualLength, Cell right, byte rFamLen, int rQualLength) static booleanmatchingColumn(Cell left, Cell right) static booleanmatchingColumnFamilyAndQualifierPrefix(Cell left, byte[] fam, byte[] qual) Returns True if matching column family and the qualifier starts withqualstatic booleanmatchingFamily(Cell left, byte[] buf) static booleanmatchingFamily(Cell left, byte lfamlength, Cell right, byte rfamlength) static booleanmatchingFamily(Cell left, Cell right) static booleanmatchingQualifier(Cell left, byte[] buf) Finds if the qualifier part of the cell and the KV serialized byte[] are equal.private static booleanmatchingQualifier(Cell left, int lqlength, Cell right, int rqlength) static booleanmatchingQualifier(Cell left, Cell right) static booleanmatchingRow(Cell left, byte[] buf, int offset, int length) static booleanmatchingRowColumn(Cell left, Cell right) Compares the row and column of two keyvalues for equalitystatic booleanmatchingRowColumnBytes(Cell left, Cell right) Compares the row and column of two keyvalues for equalitystatic booleanmatchingRows(Cell left, byte[] buf) static booleanmatchingRows(Cell left, short lrowlength, Cell right, short rrowlength) Compares the row of two keyvalues for equalitystatic booleanmatchingRows(Cell left, Cell right) Compares the row of two keyvalues for equalitystatic booleanmatchingTags(Cell left, Cell right) Deprecated.Since 3.0.0, will be removed in 4.0.0.static booleanmatchingTimestamp(Cell a, Cell b) static booleanmatchingValue(Cell left, byte[] buf) static booleanmatchingValue(Cell left, Cell right) static booleanmatchingValue(Cell left, Cell right, int lvlength, int rvlength) static byte[][]parseColumn(byte[] c) Splits a column infamily:qualifierform into separate byte arrays.static voidsetTimestamp(Cell cell, byte[] ts, int tsOffset) Sets the given timestamp to the cell.static voidsetTimestamp(Cell cell, long ts) Sets the given timestamp to the cell.static StringReturns 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:qualifierform 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 overcellIterableor null ifcellsis 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 theCellinterface. -
isDelete
Return true if a delete type, aKeyValue.Type.Deleteor a {KeyValue.Type#DeleteFamily} or aKeyValue.Type.DeleteColumnKeyValue 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 passedcellas a String. -
getCellKeyAsString
Return the Key portion of the passedcellas 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
cellas 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
-