@Override public int getRowPosition() { if (cell instanceof ByteBufferExtendedCell) { return ((ByteBufferExtendedCell) this.cell).getRowPosition(); } else { return 0; } }
@Override public int getRowPosition() { return this.cell.getRowPosition(); }
@Override public int getRowPosition() { return cell.getRowPosition(); }
/********************* misc *************************************/ public static byte getRowByte(Cell cell, int index) { if (cell instanceof ByteBufferExtendedCell) { return ((ByteBufferExtendedCell) cell).getRowByteBuffer() .get(((ByteBufferExtendedCell) cell).getRowPosition() + index); } return cell.getRowArray()[cell.getRowOffset() + index]; }
private int compareRows(ByteBuffer row, Cell seekCell) { if (seekCell instanceof ByteBufferExtendedCell) { return ByteBufferUtils.compareTo(row, row.position(), row.remaining(), ((ByteBufferExtendedCell) seekCell).getRowByteBuffer(), ((ByteBufferExtendedCell) seekCell).getRowPosition(), seekCell.getRowLength()); } else { return ByteBufferUtils.compareTo(row, row.position(), row.remaining(), seekCell.getRowArray(), seekCell.getRowOffset(), seekCell.getRowLength()); } }
/** * Writes the row from the given cell to the output stream * @param out The outputstream to which the data has to be written * @param cell The cell whose contents has to be written * @param rlength the row length * @throws IOException */ public static void writeRow(OutputStream out, Cell cell, short rlength) throws IOException { if (cell instanceof ByteBufferExtendedCell) { ByteBufferUtils.copyBufferToStream(out, ((ByteBufferExtendedCell) cell).getRowByteBuffer(), ((ByteBufferExtendedCell) cell).getRowPosition(), rlength); } else { out.write(cell.getRowArray(), cell.getRowOffset(), rlength); } }
/** * Copies the row to a new byte[] * @param cell the cell from which row has to copied * @return the byte[] containing the row */ public static byte[] copyRow(Cell cell) { if (cell instanceof ByteBufferExtendedCell) { return ByteBufferUtils.copyOfRange(((ByteBufferExtendedCell) cell).getRowByteBuffer(), ((ByteBufferExtendedCell) cell).getRowPosition(), ((ByteBufferExtendedCell) cell).getRowPosition() + cell.getRowLength()); } else { return Arrays.copyOfRange(cell.getRowArray(), cell.getRowOffset(), cell.getRowOffset() + cell.getRowLength()); } }
/** * Writes the row from the given cell to the output stream excluding the common prefix * @param out The dataoutputstream to which the data has to be written * @param cell The cell whose contents has to be written * @param rlength the row length * @throws IOException */ public static void writeRowSkippingBytes(DataOutputStream out, Cell cell, short rlength, int commonPrefix) throws IOException { if (cell instanceof ByteBufferExtendedCell) { ByteBufferUtils .copyBufferToStream((DataOutput) out, ((ByteBufferExtendedCell) cell).getRowByteBuffer(), ((ByteBufferExtendedCell) cell).getRowPosition() + commonPrefix, rlength - commonPrefix); } else { out.write(cell.getRowArray(), cell.getRowOffset() + commonPrefix, rlength - commonPrefix); } }
public static Cell createFirstOnRowFamily(Cell cell, byte[] fArray, int foff, int flen) { if (cell instanceof ByteBufferExtendedCell) { return new FirstOnRowColByteBufferExtendedCell( ((ByteBufferExtendedCell) cell).getRowByteBuffer(), ((ByteBufferExtendedCell) cell).getRowPosition(), cell.getRowLength(), ByteBuffer.wrap(fArray), foff, (byte) flen, HConstants.EMPTY_BYTE_BUFFER, 0, 0); } return new FirstOnRowColCell(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), fArray, foff, (byte) flen, HConstants.EMPTY_BYTE_ARRAY, 0, 0); }
/** * Converts the rowkey bytes of the given cell into an int value * @param cell * @return rowkey as int */ public static int getRowAsInt(Cell cell) { if (cell instanceof ByteBufferExtendedCell) { return ByteBufferUtils.toInt(((ByteBufferExtendedCell) cell).getRowByteBuffer(), ((ByteBufferExtendedCell) cell).getRowPosition()); } return Bytes.toInt(cell.getRowArray(), cell.getRowOffset()); }
public static void compressRow(OutputStream out, Cell cell, Dictionary dict) throws IOException { if (cell instanceof ByteBufferExtendedCell) { Dictionary.write(out, ((ByteBufferExtendedCell) cell).getRowByteBuffer(), ((ByteBufferExtendedCell) cell).getRowPosition(), cell.getRowLength(), dict); } else { Dictionary.write(out, cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), dict); } }
/** * Create a Cell that is larger than all other possible Cells for the given Cell's row. * @param cell * @return Last possible Cell on passed Cell's row. */ public static Cell createLastOnRow(final Cell cell) { if (cell instanceof ByteBufferExtendedCell) { return new LastOnRowByteBufferExtendedCell(((ByteBufferExtendedCell) cell).getRowByteBuffer(), ((ByteBufferExtendedCell) cell).getRowPosition(), cell.getRowLength()); } return new LastOnRowCell(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength()); }
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); }
/** * Create a Cell that is smaller than all other possible Cells for the given Cell's row. * @param cell * @return First possible Cell on passed Cell's row. */ public static Cell createFirstOnRow(final Cell cell) { if (cell instanceof ByteBufferExtendedCell) { return new FirstOnRowByteBufferExtendedCell( ((ByteBufferExtendedCell) cell).getRowByteBuffer(), ((ByteBufferExtendedCell) cell).getRowPosition(), cell.getRowLength()); } return new FirstOnRowCell(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength()); }
/** * Copies the row to the given bytebuffer * @param cell cell the cell whose row has to be copied * @param destination the destination bytebuffer to which the row has to be copied * @param destinationOffset the offset in the destination byte[] * @return the offset of the bytebuffer after the copy has happened */ public static int copyRowTo(Cell cell, ByteBuffer destination, int destinationOffset) { short rowLen = cell.getRowLength(); if (cell instanceof ByteBufferExtendedCell) { ByteBufferUtils.copyFromBufferToBuffer(((ByteBufferExtendedCell) cell).getRowByteBuffer(), destination, ((ByteBufferExtendedCell) cell).getRowPosition(), destinationOffset, rowLen); } else { ByteBufferUtils.copyFromArrayToBuffer(destination, destinationOffset, cell.getRowArray(), cell.getRowOffset(), rowLen); } return destinationOffset + rowLen; }
/** * Compare cell's row against given comparator * @param cell * @param comparator * @return result comparing cell's row */ public static int compareRow(Cell cell, ByteArrayComparable comparator) { if (cell instanceof ByteBufferExtendedCell) { return comparator.compareTo(((ByteBufferExtendedCell) cell).getRowByteBuffer(), ((ByteBufferExtendedCell) cell).getRowPosition(), cell.getRowLength()); } return comparator.compareTo(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength()); }
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()); }
private int calculateHashForKey(ByteBufferExtendedCell cell) { int rowHash = ByteBufferUtils.hashCode(cell.getRowByteBuffer(), cell.getRowPosition(), cell.getRowLength()); int familyHash = ByteBufferUtils.hashCode(cell.getFamilyByteBuffer(), cell.getFamilyPosition(), cell.getFamilyLength()); int qualifierHash = ByteBufferUtils.hashCode(cell.getQualifierByteBuffer(), cell.getQualifierPosition(), cell.getQualifierLength()); int hash = 31 * rowHash + familyHash; hash = 31 * hash + qualifierHash; hash = 31 * hash + (int) cell.getTimestamp(); hash = 31 * hash + cell.getTypeByte(); return hash; } }
/** * Creates the first cell with the row/family/qualifier of this cell and the given timestamp. Uses * the "maximum" type that guarantees that the new cell is the lowest possible for this * combination of row, family, qualifier, and timestamp. This cell's own timestamp is ignored. * @param cell - cell * @param ts */ public static Cell createFirstOnRowColTS(Cell cell, long ts) { if (cell instanceof ByteBufferExtendedCell) { return new FirstOnRowColTSByteBufferExtendedCell( ((ByteBufferExtendedCell) cell).getRowByteBuffer(), ((ByteBufferExtendedCell) cell).getRowPosition(), cell.getRowLength(), ((ByteBufferExtendedCell) cell).getFamilyByteBuffer(), ((ByteBufferExtendedCell) cell).getFamilyPosition(), cell.getFamilyLength(), ((ByteBufferExtendedCell) cell).getQualifierByteBuffer(), ((ByteBufferExtendedCell) cell).getQualifierPosition(), cell.getQualifierLength(), ts); } return new FirstOnRowColTSCell(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength(), cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength(), ts); }
/** * Create a Cell that is larger than all other possible Cells for the given Cell's rk:cf:q. Used * in creating "fake keys" for the multi-column Bloom filter optimization to skip the row/column * we already know is not in the file. * @param cell * @return Last possible Cell on passed Cell's rk:cf:q. */ public static Cell createLastOnRowCol(final Cell cell) { if (cell instanceof ByteBufferExtendedCell) { return new LastOnRowColByteBufferExtendedCell( ((ByteBufferExtendedCell) cell).getRowByteBuffer(), ((ByteBufferExtendedCell) cell).getRowPosition(), cell.getRowLength(), ((ByteBufferExtendedCell) cell).getFamilyByteBuffer(), ((ByteBufferExtendedCell) cell).getFamilyPosition(), cell.getFamilyLength(), ((ByteBufferExtendedCell) cell).getQualifierByteBuffer(), ((ByteBufferExtendedCell) cell).getQualifierPosition(), cell.getQualifierLength()); } return new LastOnRowColCell(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength(), cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()); }