本文整理了Java中org.apache.hadoop.hbase.Cell.getRowLength()
方法的一些代码示例,展示了Cell.getRowLength()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cell.getRowLength()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.Cell
类名称:Cell
方法名:getRowLength
暂无
代码示例来源:origin: apache/hbase
public RowColBloomHashKey(Cell cell) {
super(cell);
rowLength = cell.getRowLength();
// We don't consider the family length for ROWCOL bloom. So subtract the famLen from the
// length calculation. Timestamp and type are of no relevance here
qualLength = cell.getQualifierLength();
}
代码示例来源:origin: apache/hbase
/**
* @param left
* @param right
* @return Result comparing rows.
*/
public int compareRows(final Cell left, final Cell right) {
return compareRows(left.getRowArray(),left.getRowOffset(), left.getRowLength(),
right.getRowArray(), right.getRowOffset(), right.getRowLength());
}
代码示例来源:origin: apache/hbase
public static boolean matchingRows(final Cell left, final byte[] buf, final int offset,
final int length) {
if (left instanceof ByteBufferExtendedCell) {
return ByteBufferUtils.equals(((ByteBufferExtendedCell) left).getRowByteBuffer(),
((ByteBufferExtendedCell) left).getRowPosition(), left.getRowLength(),
buf, offset, length);
}
return Bytes.equals(left.getRowArray(), left.getRowOffset(), left.getRowLength(), buf, offset,
length);
}
代码示例来源:origin: apache/hbase
private void writeKeyExcludingCommon(Cell cell, int commonPrefix, DataOutputStream out)
throws IOException {
short rLen = cell.getRowLength();
if (commonPrefix < rLen + KeyValue.ROW_LENGTH_SIZE) {
out.writeByte(fLen);
PrivateCellUtil.writeFamily(out, cell, fLen);
PrivateCellUtil.writeQualifier(out, cell, cell.getQualifierLength());
out.writeLong(cell.getTimestamp());
out.writeByte(cell.getTypeByte());
} else {
int qLen = cell.getQualifierLength();
int commonQualPrefix = Math.min(commonPrefix, qLen);
int qualPartLenToWrite = qLen - commonQualPrefix;
int commonTimestampPrefix = Math.min(commonPrefix, KeyValue.TIMESTAMP_SIZE);
if (commonTimestampPrefix < KeyValue.TIMESTAMP_SIZE) {
byte[] curTsBuf = Bytes.toBytes(cell.getTimestamp());
out.write(curTsBuf, commonTimestampPrefix, KeyValue.TIMESTAMP_SIZE
- commonTimestampPrefix);
out.writeLong(cell.getTimestamp());
out.writeByte(cell.getTypeByte());
代码示例来源:origin: apache/hbase
public static int appendKeyTo(final Cell cell, final byte[] output,
final int offset) {
int nextOffset = offset;
nextOffset = Bytes.putShort(output, nextOffset, cell.getRowLength());
nextOffset = CellUtil.copyRowTo(cell, output, nextOffset);
nextOffset = Bytes.putByte(output, nextOffset, cell.getFamilyLength());
nextOffset = CellUtil.copyFamilyTo(cell, output, nextOffset);
nextOffset = CellUtil.copyQualifierTo(cell, output, nextOffset);
nextOffset = Bytes.putLong(output, nextOffset, cell.getTimestamp());
nextOffset = Bytes.putByte(output, nextOffset, cell.getTypeByte());
return nextOffset;
}
代码示例来源:origin: apache/hbase
Cell nextCell = nextRowResult.rawCells()[0];
if (currentRow == null
|| !Bytes.equals(currentRow, 0, currentRow.length, nextCell.getRowArray(),
nextCell.getRowOffset(), nextCell.getRowLength())) {
代码示例来源:origin: apache/hbase
/********************* common prefixes *************************/
// Having this as static is fine but if META is having DBE then we should
// change this.
public static int compareCommonRowPrefix(Cell left, Cell right, int rowCommonPrefix) {
return Bytes.compareTo(left.getRowArray(), left.getRowOffset() + rowCommonPrefix,
left.getRowLength() - rowCommonPrefix, right.getRowArray(), right.getRowOffset()
+ rowCommonPrefix, right.getRowLength() - rowCommonPrefix);
}
代码示例来源:origin: apache/hbase
@Override
public int length() {
// For ROW_COL blooms we use bytes
// <RK length> (2 bytes) , <RK>, 0 (one byte CF length), <CQ>, <TS> (8 btes), <TYPE> ( 1 byte)
return KeyValue.ROW_LENGTH_SIZE + this.t.getRowLength() + KeyValue.FAMILY_LENGTH_SIZE
+ this.t.getQualifierLength() + KeyValue.TIMESTAMP_TYPE_SIZE;
}
}
代码示例来源:origin: apache/hbase
public static int appendKeyTo(Cell cell, ByteBuffer buf, int offset) {
offset = ByteBufferUtils.putShort(buf, offset, cell.getRowLength());// RK length
offset = CellUtil.copyRowTo(cell, buf, offset);// Row bytes
offset = ByteBufferUtils.putByte(buf, offset, cell.getFamilyLength());// CF length
offset = CellUtil.copyFamilyTo(cell, buf, offset);// CF bytes
offset = CellUtil.copyQualifierTo(cell, buf, offset);// Qualifier bytes
offset = ByteBufferUtils.putLong(buf, offset, cell.getTimestamp());// TS
offset = ByteBufferUtils.putByte(buf, offset, cell.getTypeByte());// Type
return offset;
}
代码示例来源:origin: apache/hbase
Result result = results.next();
Cell cell = result.rawCells()[0];
if (Bytes.equals(currentRow, 0, currentRow.length, cell.getRowArray(),
cell.getRowOffset(), cell.getRowLength())) {
代码示例来源:origin: apache/hbase
private static int findCommonPrefixInRowPart(Cell left, Cell right, int rowCommonPrefix) {
return Bytes.findCommonPrefix(left.getRowArray(), right.getRowArray(), left.getRowLength()
- rowCommonPrefix, right.getRowLength() - rowCommonPrefix, left.getRowOffset()
+ rowCommonPrefix, right.getRowOffset() + rowCommonPrefix);
}
代码示例来源:origin: apache/hbase
/**
* Calculates the serialized key size. We always serialize in the KeyValue's serialization format.
* @param cell the cell for which the key size has to be calculated.
* @return the key size
*/
public static int estimatedSerializedSizeOfKey(final Cell cell) {
if (cell instanceof KeyValue) return ((KeyValue) cell).getKeyLength();
return cell.getRowLength() + cell.getFamilyLength() + cell.getQualifierLength()
+ KeyValue.KEY_INFRASTRUCTURE_SIZE;
}
代码示例来源:origin: apache/hbase
public static Cell createFirstOnRowCol(final Cell cell) {
if (cell instanceof ByteBufferExtendedCell) {
return new FirstOnRowColByteBufferExtendedCell(
((ByteBufferExtendedCell) cell).getRowByteBuffer(),
((ByteBufferExtendedCell) cell).getRowPosition(), cell.getRowLength(),
HConstants.EMPTY_BYTE_BUFFER, 0, (byte) 0,
((ByteBufferExtendedCell) cell).getQualifierByteBuffer(),
((ByteBufferExtendedCell) cell).getQualifierPosition(), cell.getQualifierLength());
}
return new FirstOnRowColCell(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(),
HConstants.EMPTY_BYTE_ARRAY, 0, (byte) 0, cell.getQualifierArray(),
cell.getQualifierOffset(), cell.getQualifierLength());
}
代码示例来源:origin: apache/hbase
@Override
public int compareRows(final Cell left, final Cell right) {
return compareRows(left.getRowArray(), left.getRowOffset(), left.getRowLength(),
right.getRowArray(), right.getRowOffset(), right.getRowLength());
}
代码示例来源:origin: apache/hbase
/**
* Returns number of bytes this cell's key part would have been used if serialized as in
* {@link KeyValue}. Key includes rowkey, family, qualifier, timestamp and type.
* @param cell
* @return the key length
*/
public static int keyLength(final Cell cell) {
return keyLength(cell.getRowLength(), cell.getFamilyLength(), cell.getQualifierLength());
}
代码示例来源:origin: apache/hbase
public void hashResult(Result result) {
if (!batchStarted) {
throw new RuntimeException("Cannot add to batch that has not been started.");
}
for (Cell cell : result.rawCells()) {
int rowLength = cell.getRowLength();
int familyLength = cell.getFamilyLength();
int qualifierLength = cell.getQualifierLength();
int valueLength = cell.getValueLength();
digest.update(cell.getRowArray(), cell.getRowOffset(), rowLength);
digest.update(cell.getFamilyArray(), cell.getFamilyOffset(), familyLength);
digest.update(cell.getQualifierArray(), cell.getQualifierOffset(), qualifierLength);
long ts = cell.getTimestamp();
for (int i = 8; i > 0; i--) {
digest.update((byte) ts);
ts >>>= 8;
}
digest.update(cell.getValueArray(), cell.getValueOffset(), valueLength);
batchSize += rowLength + familyLength + qualifierLength + 8 + valueLength;
}
}
代码示例来源:origin: apache/hbase
/**
* Override the row key comparison to parse and compare the meta row key parts.
*/
@Override
protected int compareRowKey(final Cell l, final Cell r) {
byte[] left = l.getRowArray();
int loffset = l.getRowOffset();
int llength = l.getRowLength();
byte[] right = r.getRowArray();
int roffset = r.getRowOffset();
int rlength = r.getRowLength();
return compareRows(left, loffset, llength, right, roffset, rlength);
}
}
代码示例来源:origin: apache/hbase
/**
* Compares the row and column of two keyvalues for equality
* @param left
* @param right
* @return True if same row and column.
*/
public static boolean matchingRowColumn(final Cell left, final Cell right) {
if ((left.getRowLength() + left.getFamilyLength()
+ left.getQualifierLength()) != (right.getRowLength() + right.getFamilyLength()
+ right.getQualifierLength())) {
return false;
}
if (!matchingRows(left, right)) {
return false;
}
return matchingColumn(left, right);
}
代码示例来源:origin: apache/hbase
public static boolean matchingRowColumnBytes(final Cell left, final Cell right) {
int lrowlength = left.getRowLength();
int rrowlength = right.getRowLength();
int lfamlength = left.getFamilyLength();
int rfamlength = right.getFamilyLength();
int lqlength = left.getQualifierLength();
int rqlength = right.getQualifierLength();
// match length
if ((lrowlength + lfamlength + lqlength) !=
(rrowlength + rfamlength + rqlength)) {
return false;
}
// match row
if (!Bytes.equals(left.getRowArray(), left.getRowOffset(), lrowlength, right.getRowArray(),
right.getRowOffset(), rrowlength)) {
return false;
}
//match family
if (!Bytes.equals(left.getFamilyArray(), left.getFamilyOffset(), lfamlength,
right.getFamilyArray(), right.getFamilyOffset(), rfamlength)) {
return false;
}
//match qualifier
return Bytes.equals(left.getQualifierArray(), left.getQualifierOffset(),
lqlength, right.getQualifierArray(), right.getQualifierOffset(),
rqlength);
}
代码示例来源:origin: apache/hbase
@Override
public int compareRows(Cell left, byte[] right, int roffset, int rlength) {
return compareRows(left.getRowArray(), left.getRowOffset(), left.getRowLength(), right,
roffset, rlength);
}
内容来源于网络,如有侵权,请联系作者删除!