@Override public ByteBuffer getValueByteBuffer() { return this.cell.getValueByteBuffer(); }
@Override public ByteBuffer getValueByteBuffer() { if (cell instanceof ByteBufferExtendedCell) { return ((ByteBufferExtendedCell) this.cell).getValueByteBuffer(); } else { return ByteBuffer.wrap(CellUtil.cloneValue(this.cell)); } }
/** * Writes the value 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 vlength the value length * @throws IOException */ public static void writeValue(OutputStream out, Cell cell, int vlength) throws IOException { if (cell instanceof ByteBufferExtendedCell) { ByteBufferUtils.copyBufferToStream(out, ((ByteBufferExtendedCell) cell).getValueByteBuffer(), ((ByteBufferExtendedCell) cell).getValuePosition(), vlength); } else { out.write(cell.getValueArray(), cell.getValueOffset(), vlength); } }
/** * Copies the value to the given byte[] * @param cell the cell whose value has to be copied * @param destination the destination byte[] to which the value has to be copied * @param destinationOffset the offset in the destination byte[] * @return the offset of the byte[] after the copy has happened */ public static int copyValueTo(Cell cell, byte[] destination, int destinationOffset) { int vlen = cell.getValueLength(); if (cell instanceof ByteBufferExtendedCell) { ByteBufferUtils.copyFromBufferToArray(destination, ((ByteBufferExtendedCell) cell).getValueByteBuffer(), ((ByteBufferExtendedCell) cell).getValuePosition(), destinationOffset, vlen); } else { System.arraycopy(cell.getValueArray(), cell.getValueOffset(), destination, destinationOffset, vlen); } return destinationOffset + vlen; }
/** * Converts the value bytes of the given cell into a long value * @param cell * @return value as long */ public static long getValueAsLong(Cell cell) { if (cell instanceof ByteBufferExtendedCell) { return ByteBufferUtils.toLong(((ByteBufferExtendedCell) cell).getValueByteBuffer(), ((ByteBufferExtendedCell) cell).getValuePosition()); } return Bytes.toLong(cell.getValueArray(), cell.getValueOffset()); }
/** * Converts the value bytes of the given cell into a int value * @param cell * @return value as int */ public static int getValueAsInt(Cell cell) { if (cell instanceof ByteBufferExtendedCell) { return ByteBufferUtils.toInt(((ByteBufferExtendedCell) cell).getValueByteBuffer(), ((ByteBufferExtendedCell) cell).getValuePosition()); } return Bytes.toInt(cell.getValueArray(), cell.getValueOffset()); }
/** * Converts the value bytes of the given cell into a double value * @param cell * @return value as double */ public static double getValueAsDouble(Cell cell) { if (cell instanceof ByteBufferExtendedCell) { return ByteBufferUtils.toDouble(((ByteBufferExtendedCell) cell).getValueByteBuffer(), ((ByteBufferExtendedCell) cell).getValuePosition()); } return Bytes.toDouble(cell.getValueArray(), cell.getValueOffset()); }
public static boolean matchingValue(final Cell left, final Cell right, int lvlength, int rvlength) { if (left instanceof ByteBufferExtendedCell && right instanceof ByteBufferExtendedCell) { return ByteBufferUtils.equals(((ByteBufferExtendedCell) left).getValueByteBuffer(), ((ByteBufferExtendedCell) left).getValuePosition(), lvlength, ((ByteBufferExtendedCell) right).getValueByteBuffer(), ((ByteBufferExtendedCell) right).getValuePosition(), rvlength); } if (left instanceof ByteBufferExtendedCell) { return ByteBufferUtils.equals(((ByteBufferExtendedCell) left).getValueByteBuffer(), ((ByteBufferExtendedCell) left).getValuePosition(), lvlength, right.getValueArray(), right.getValueOffset(), rvlength); } if (right instanceof ByteBufferExtendedCell) { return ByteBufferUtils.equals(((ByteBufferExtendedCell) right).getValueByteBuffer(), ((ByteBufferExtendedCell) right).getValuePosition(), rvlength, left.getValueArray(), left.getValueOffset(), lvlength); } return Bytes.equals(left.getValueArray(), left.getValueOffset(), lvlength, right.getValueArray(), right.getValueOffset(), rvlength); }
public static boolean matchingValue(final Cell left, final Cell right, int lvlength, int rvlength) { if (left instanceof ByteBufferExtendedCell && right instanceof ByteBufferExtendedCell) { return ByteBufferUtils.equals(((ByteBufferExtendedCell) left).getValueByteBuffer(), ((ByteBufferExtendedCell) left).getValuePosition(), lvlength, ((ByteBufferExtendedCell) right).getValueByteBuffer(), ((ByteBufferExtendedCell) right).getValuePosition(), rvlength); } if (left instanceof ByteBufferExtendedCell) { return ByteBufferUtils.equals(((ByteBufferExtendedCell) left).getValueByteBuffer(), ((ByteBufferExtendedCell) left).getValuePosition(), lvlength, right.getValueArray(), right.getValueOffset(), rvlength); } if (right instanceof ByteBufferExtendedCell) { return ByteBufferUtils.equals(((ByteBufferExtendedCell) right).getValueByteBuffer(), ((ByteBufferExtendedCell) right).getValuePosition(), rvlength, left.getValueArray(), left.getValueOffset(), lvlength); } return Bytes .equals(left.getValueArray(), left.getValueOffset(), lvlength, right.getValueArray(), right.getValueOffset(), rvlength); }
public static boolean matchingValue(final Cell left, final byte[] buf) { if (left instanceof ByteBufferExtendedCell) { return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getValueByteBuffer(), ((ByteBufferExtendedCell) left).getValuePosition(), left.getValueLength(), buf, 0, buf.length) == 0; } return Bytes.equals(left.getValueArray(), left.getValueOffset(), left.getValueLength(), buf, 0, buf.length); }
/** * Converts the value bytes of the given cell into a BigDecimal * @param cell * @return value as BigDecimal */ public static BigDecimal getValueAsBigDecimal(Cell cell) { if (cell instanceof ByteBufferExtendedCell) { return ByteBufferUtils.toBigDecimal(((ByteBufferExtendedCell) cell).getValueByteBuffer(), ((ByteBufferExtendedCell) cell).getValuePosition(), cell.getValueLength()); } return Bytes.toBigDecimal(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()); }
/** * Copies the value to the given bytebuffer * @param cell the cell whose value has to be copied * @param destination the destination bytebuffer to which the value has to be copied * @param destinationOffset the offset in the destination bytebuffer * @return the offset of the bytebuffer after the copy has happened */ public static int copyValueTo(Cell cell, ByteBuffer destination, int destinationOffset) { int vlen = cell.getValueLength(); if (cell instanceof ByteBufferExtendedCell) { ByteBufferUtils.copyFromBufferToBuffer(((ByteBufferExtendedCell) cell).getValueByteBuffer(), destination, ((ByteBufferExtendedCell) cell).getValuePosition(), destinationOffset, vlen); } else { ByteBufferUtils.copyFromArrayToBuffer(destination, destinationOffset, cell.getValueArray(), cell.getValueOffset(), vlen); } return destinationOffset + vlen; }
/** * Compare cell's value against given comparator * @param cell * @param comparator * @return result comparing cell's value */ public static int compareValue(Cell cell, ByteArrayComparable comparator) { if (cell instanceof ByteBufferExtendedCell) { return comparator.compareTo(((ByteBufferExtendedCell) cell).getValueByteBuffer(), ((ByteBufferExtendedCell) cell).getValuePosition(), cell.getValueLength()); } return comparator.compareTo(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()); }
ByteBuffer bb = bbCell.getValueByteBuffer(); if (bb != lastBlock) { context.incrementResponseBlockSize(bb.capacity());
public static CellProtos.Cell toCell(final Cell kv) { // Doing this is going to kill us if we do it for all data passed. // St.Ack 20121205 CellProtos.Cell.Builder kvbuilder = CellProtos.Cell.newBuilder(); if (kv instanceof ByteBufferExtendedCell) { kvbuilder.setRow(wrap(((ByteBufferExtendedCell) kv).getRowByteBuffer(), ((ByteBufferExtendedCell) kv).getRowPosition(), kv.getRowLength())); kvbuilder.setFamily(wrap(((ByteBufferExtendedCell) kv).getFamilyByteBuffer(), ((ByteBufferExtendedCell) kv).getFamilyPosition(), kv.getFamilyLength())); kvbuilder.setQualifier(wrap(((ByteBufferExtendedCell) kv).getQualifierByteBuffer(), ((ByteBufferExtendedCell) kv).getQualifierPosition(), kv.getQualifierLength())); kvbuilder.setCellType(CellProtos.CellType.valueOf(kv.getTypeByte())); kvbuilder.setTimestamp(kv.getTimestamp()); kvbuilder.setValue(wrap(((ByteBufferExtendedCell) kv).getValueByteBuffer(), ((ByteBufferExtendedCell) kv).getValuePosition(), kv.getValueLength())); // TODO : Once tags become first class then we may have to set tags to kvbuilder. } else { kvbuilder.setRow( UnsafeByteOperations.unsafeWrap(kv.getRowArray(), kv.getRowOffset(), kv.getRowLength())); kvbuilder.setFamily(UnsafeByteOperations.unsafeWrap(kv.getFamilyArray(), kv.getFamilyOffset(), kv.getFamilyLength())); kvbuilder.setQualifier(UnsafeByteOperations.unsafeWrap(kv.getQualifierArray(), kv.getQualifierOffset(), kv.getQualifierLength())); kvbuilder.setCellType(CellProtos.CellType.valueOf(kv.getTypeByte())); kvbuilder.setTimestamp(kv.getTimestamp()); kvbuilder.setValue(UnsafeByteOperations.unsafeWrap(kv.getValueArray(), kv.getValueOffset(), kv.getValueLength())); } return kvbuilder.build(); }
assertEquals( ROW1, ByteBufferUtils.toStringBinary(offheapKV.getValueByteBuffer(), offheapKV.getValuePosition(), offheapKV.getValueLength())); assertEquals(0L, offheapKV.getTimestamp()); assertEquals( ROW1, ByteBufferUtils.toStringBinary(offheapKV.getValueByteBuffer(), offheapKV.getValuePosition(), offheapKV.getValueLength())); assertEquals(0L, offheapKV.getTimestamp());
/** * Converts the value bytes of the given cell into a long value * @param cell * @return value as long */ public static long getValueAsLong(Cell cell) { if (cell instanceof ByteBufferExtendedCell) { return ByteBufferUtils.toLong(((ByteBufferExtendedCell) cell).getValueByteBuffer(), ((ByteBufferExtendedCell) cell).getValuePosition()); } return Bytes.toLong(cell.getValueArray(), cell.getValueOffset()); }
public static CellProtos.Cell toCell(final Cell kv) { // Doing this is going to kill us if we do it for all data passed. // St.Ack 20121205 CellProtos.Cell.Builder kvbuilder = CellProtos.Cell.newBuilder(); if (kv instanceof ByteBufferExtendedCell) { kvbuilder.setRow(wrap(((ByteBufferExtendedCell) kv).getRowByteBuffer(), ((ByteBufferExtendedCell) kv).getRowPosition(), kv.getRowLength())); kvbuilder.setFamily(wrap(((ByteBufferExtendedCell) kv).getFamilyByteBuffer(), ((ByteBufferExtendedCell) kv).getFamilyPosition(), kv.getFamilyLength())); kvbuilder.setQualifier(wrap(((ByteBufferExtendedCell) kv).getQualifierByteBuffer(), ((ByteBufferExtendedCell) kv).getQualifierPosition(), kv.getQualifierLength())); kvbuilder.setCellType(CellProtos.CellType.valueOf(kv.getTypeByte())); kvbuilder.setTimestamp(kv.getTimestamp()); kvbuilder.setValue(wrap(((ByteBufferExtendedCell) kv).getValueByteBuffer(), ((ByteBufferExtendedCell) kv).getValuePosition(), kv.getValueLength())); // TODO : Once tags become first class then we may have to set tags to kvbuilder. } else { kvbuilder.setRow( UnsafeByteOperations.unsafeWrap(kv.getRowArray(), kv.getRowOffset(), kv.getRowLength())); kvbuilder.setFamily(UnsafeByteOperations.unsafeWrap(kv.getFamilyArray(), kv.getFamilyOffset(), kv.getFamilyLength())); kvbuilder.setQualifier(UnsafeByteOperations.unsafeWrap(kv.getQualifierArray(), kv.getQualifierOffset(), kv.getQualifierLength())); kvbuilder.setCellType(CellProtos.CellType.valueOf(kv.getTypeByte())); kvbuilder.setTimestamp(kv.getTimestamp()); kvbuilder.setValue(UnsafeByteOperations.unsafeWrap(kv.getValueArray(), kv.getValueOffset(), kv.getValueLength())); } return kvbuilder.build(); }
/** * Converts the value bytes of the given cell into a BigDecimal * @param cell * @return value as BigDecimal */ public static BigDecimal getValueAsBigDecimal(Cell cell) { if (cell instanceof ByteBufferExtendedCell) { return ByteBufferUtils.toBigDecimal(((ByteBufferExtendedCell) cell).getValueByteBuffer(), ((ByteBufferExtendedCell) cell).getValuePosition(), cell.getValueLength()); } return Bytes.toBigDecimal(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()); }
public static boolean matchingValue(final Cell left, final byte[] buf) { if (left instanceof ByteBufferExtendedCell) { return ByteBufferUtils.compareTo(((ByteBufferExtendedCell) left).getValueByteBuffer(), ((ByteBufferExtendedCell) left).getValuePosition(), left.getValueLength(), buf, 0, buf.length) == 0; } return Bytes.equals(left.getValueArray(), left.getValueOffset(), left.getValueLength(), buf, 0, buf.length); }