Source:
private static int compareBBKV(final ByteBufferKeyValue left, final ByteBufferKeyValue right) { int diff; int leftRowLength = left.getRowLength(); int rightRowLength = right.getRowLength(); diff = ByteBufferUtils.compareTo(left.getRowByteBuffer(), left.getRowPosition(), leftRowLength, right.getRowByteBuffer(), right.getRowPosition(), rightRowLength); if (diff != 0) { return diff; } int leftFamilyLengthPosition = left.getFamilyLengthPosition(leftRowLength); int leftFamilyLength = left.getFamilyLength(leftFamilyLengthPosition); int leftKeyLength = left.getKeyLength(); int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); byte leftType = left.getTypeByte(leftKeyLength); if (leftFamilyLength + leftQualifierLength == 0 && leftType == KeyValue.Type.Minimum.getCode()) { return 1; } int rightFamilyLengthPosition = right.getFamilyLengthPosition(rightRowLength); int rightFamilyLength = right.getFamilyLength(rightFamilyLengthPosition); int rightKeyLength = right.getKeyLength(); int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); byte rightType = right.getTypeByte(rightKeyLength); if (rightFamilyLength + rightQualifierLength == 0 && rightType == KeyValue.Type.Minimum.getCode()) { return -1; } int leftFamilyPosition = left.getFamilyPosition(leftFamilyLengthPosition); int rightFamilyPosition = right.getFamilyPosition(rightFamilyLengthPosition); diff = ByteBufferUtils.compareTo(left.getFamilyByteBuffer(), leftFamilyPosition, leftFamilyLength, right.getFamilyByteBuffer(), rightFamilyPosition, rightFamilyLength); if (diff != 0) { return diff; } diff = ByteBufferUtils.compareTo(left.getQualifierByteBuffer(), left.getQualifierPosition(leftFamilyPosition, leftFamilyLength), leftQualifierLength, right.getQualifierByteBuffer(), right.getQualifierPosition(rightFamilyPosition, rightFamilyLength), rightQualifierLength); if (diff != 0) { return diff; } ENDING order. diff = Long.compare(right.getTimestamp(rightKeyLength), left.getTimestamp(leftKeyLength)); if (diff != 0) { return diff; } return (0xff & rightType) - (0xff & leftType); }

Target:
private static int compareBBKV(final ByteBufferKeyValue left, final ByteBufferKeyValue right) { int diff; int leftRowLength = left.getRowLength(); int rightRowLength = right.getRowLength(); diff = ByteBufferUtils.compareTo(left.getRowByteBuffer(), left.getRowPosition(), leftRowLength, right.getRowByteBuffer(), right.getRowPosition(), rightRowLength); if (diff != 0) { return diff; } int leftFamilyLengthPosition = left.getFamilyLengthPosition(leftRowLength); int leftFamilyLength = left.getFamilyLength(leftFamilyLengthPosition); int leftKeyLength = left.getKeyLength(); int leftQualifierLength = left.getQualifierLength(leftKeyLength, leftRowLength, leftFamilyLength); byte leftType = left.getTypeByte(leftKeyLength); if (leftType == KeyValue.Type.Minimum.getCode() && leftFamilyLength + leftQualifierLength == 0) { return 1; } int rightFamilyLengthPosition = right.getFamilyLengthPosition(rightRowLength); int rightFamilyLength = right.getFamilyLength(rightFamilyLengthPosition); int rightKeyLength = right.getKeyLength(); int rightQualifierLength = right.getQualifierLength(rightKeyLength, rightRowLength, rightFamilyLength); byte rightType = right.getTypeByte(rightKeyLength); if (rightType == KeyValue.Type.Minimum.getCode() && rightFamilyLength + rightQualifierLength == 0) { return -1; } int leftFamilyPosition = left.getFamilyPosition(leftFamilyLengthPosition); int rightFamilyPosition = right.getFamilyPosition(rightFamilyLengthPosition); diff = ByteBufferUtils.compareTo(left.getFamilyByteBuffer(), leftFamilyPosition, leftFamilyLength, right.getFamilyByteBuffer(), rightFamilyPosition, rightFamilyLength); if (diff != 0) { return diff; } diff = ByteBufferUtils.compareTo(left.getQualifierByteBuffer(), left.getQualifierPosition(leftFamilyPosition, leftFamilyLength), leftQualifierLength, right.getQualifierByteBuffer(), right.getQualifierPosition(rightFamilyPosition, rightFamilyLength), rightQualifierLength); if (diff != 0) { return diff; } ENDING order. diff = Long.compare(right.getTimestamp(rightKeyLength), left.getTimestamp(leftKeyLength)); if (diff != 0) { return diff; } return (0xff & rightType) - (0xff & leftType); }