/** * Copies the tags info into the tag portion of the cell * @param cell * @param destination * @param destinationOffset * @return position after tags * @deprecated As of HBase-2.0. Will be removed in HBase-3.0. */ @Deprecated public static int copyTagTo(Cell cell, byte[] destination, int destinationOffset) { return PrivateCellUtil.copyTagsTo(cell, destination, destinationOffset); }
/** * Copies the tags info into the tag portion of the cell * @param cell * @param destination * @param destinationOffset * @return position after tags * @deprecated As of HBase-2.0. Will be removed in 3.0. */ @Deprecated public static int copyTagTo(Cell cell, ByteBuffer destination, int destinationOffset) { return PrivateCellUtil.copyTagsTo(cell, destination, destinationOffset); }
public static byte[] cloneTags(Cell cell) { byte[] output = new byte[cell.getTagsLength()]; copyTagsTo(cell, output, 0); return output; }
/** * Copy the Cell content into the passed buf in KeyValue serialization format. */ public static int appendTo(Cell cell, ByteBuffer buf, int offset, boolean withTags) { offset = ByteBufferUtils.putInt(buf, offset, keyLength(cell));// Key length offset = ByteBufferUtils.putInt(buf, offset, cell.getValueLength());// Value length offset = appendKeyTo(cell, buf, offset); offset = CellUtil.copyValueTo(cell, buf, offset);// Value bytes int tagsLength = cell.getTagsLength(); if (withTags && (tagsLength > 0)) { offset = ByteBufferUtils.putAsShort(buf, offset, tagsLength);// Tags length offset = PrivateCellUtil.copyTagsTo(cell, buf, offset);// Tags bytes } return offset; }
/**************** copy key and value *********************/ public static int appendToByteArray(Cell cell, byte[] output, int offset, boolean withTags) { int pos = offset; pos = Bytes.putInt(output, pos, keyLength(cell)); pos = Bytes.putInt(output, pos, cell.getValueLength()); pos = appendKeyTo(cell, output, pos); pos = CellUtil.copyValueTo(cell, output, pos); if (withTags && (cell.getTagsLength() > 0)) { pos = Bytes.putAsShort(output, pos, cell.getTagsLength()); pos = PrivateCellUtil.copyTagsTo(cell, output, pos); } return pos; }
@Test public void testCloneCellFieldsFromByteBufferedCell() { byte[] r = Bytes.toBytes("row1"); byte[] f = Bytes.toBytes("cf1"); byte[] q = Bytes.toBytes("qual1"); byte[] v = Bytes.toBytes("val1"); byte[] tags = Bytes.toBytes("tag1"); KeyValue kv = new KeyValue(r, f, q, 0, q.length, 1234L, KeyValue.Type.Put, v, 0, v.length, tags); ByteBuffer buffer = ByteBuffer.wrap(kv.getBuffer()); Cell bbCell = new ByteBufferKeyValue(buffer, 0, buffer.remaining()); byte[] rDest = CellUtil.cloneRow(bbCell); assertTrue(Bytes.equals(r, rDest)); byte[] fDest = CellUtil.cloneFamily(bbCell); assertTrue(Bytes.equals(f, fDest)); byte[] qDest = CellUtil.cloneQualifier(bbCell); assertTrue(Bytes.equals(q, qDest)); byte[] vDest = CellUtil.cloneValue(bbCell); assertTrue(Bytes.equals(v, vDest)); byte[] tDest = new byte[tags.length]; PrivateCellUtil.copyTagsTo(bbCell, tDest, 0); assertTrue(Bytes.equals(tags, tDest)); }
public static byte[] cloneTags(Cell cell) { byte[] output = new byte[cell.getTagsLength()]; copyTagsTo(cell, output, 0); return output; }
/** * @deprecated As of HBase-2.0. Will be removed in HBase-3.0. * Use {@link RawCell#cloneTags()} */ @Deprecated public static byte[] cloneTags(Cell cell) { byte[] output = new byte[cell.getTagsLength()]; PrivateCellUtil.copyTagsTo(cell, output, 0); return output; }
/** * Returns tag value in a new byte array. If server-side, use {@link Tag#getValueArray()} with * appropriate {@link Tag#getValueOffset()} and {@link Tag#getValueLength()} instead to save on * allocations. * @param cell * @return tag value in a new byte array. * @deprecated As of HBase-2.0. Will be removed in HBase-3.0 */ @Deprecated public static byte[] getTagArray(Cell cell) { byte[] output = new byte[cell.getTagsLength()]; PrivateCellUtil.copyTagsTo(cell, output, 0); return output; }
/** * @deprecated As of HBase-2.0. Will be removed in HBase-3.0. * Use {@link RawCell#cloneTags()} */ @Deprecated public static byte[] cloneTags(Cell cell) { byte[] output = new byte[cell.getTagsLength()]; PrivateCellUtil.copyTagsTo(cell, output, 0); return output; }
public static byte[] cloneTags(Cell cell) { byte[] output = new byte[cell.getTagsLength()]; copyTagsTo(cell, output, 0); return output; }
/** * Returns tag value in a new byte array. If server-side, use {@link Tag#getValueArray()} with * appropriate {@link Tag#getValueOffset()} and {@link Tag#getValueLength()} instead to save on * allocations. * @param cell * @return tag value in a new byte array. * @deprecated As of HBase-2.0. Will be removed in HBase-3.0 */ @Deprecated public static byte[] getTagArray(Cell cell) { byte[] output = new byte[cell.getTagsLength()]; PrivateCellUtil.copyTagsTo(cell, output, 0); return output; }
/**************** copy key and value *********************/ public static int appendToByteArray(Cell cell, byte[] output, int offset, boolean withTags) { int pos = offset; pos = Bytes.putInt(output, pos, keyLength(cell)); pos = Bytes.putInt(output, pos, cell.getValueLength()); pos = appendKeyTo(cell, output, pos); pos = CellUtil.copyValueTo(cell, output, pos); if (withTags && (cell.getTagsLength() > 0)) { pos = Bytes.putAsShort(output, pos, cell.getTagsLength()); pos = PrivateCellUtil.copyTagsTo(cell, output, pos); } return pos; }
/**************** copy key and value *********************/ public static int appendToByteArray(Cell cell, byte[] output, int offset, boolean withTags) { int pos = offset; pos = Bytes.putInt(output, pos, keyLength(cell)); pos = Bytes.putInt(output, pos, cell.getValueLength()); pos = appendKeyTo(cell, output, pos); pos = CellUtil.copyValueTo(cell, output, pos); if (withTags && (cell.getTagsLength() > 0)) { pos = Bytes.putAsShort(output, pos, cell.getTagsLength()); pos = PrivateCellUtil.copyTagsTo(cell, output, pos); } return pos; }
/** * Copy the Cell content into the passed buf in KeyValue serialization format. */ public static int appendTo(Cell cell, ByteBuffer buf, int offset, boolean withTags) { offset = ByteBufferUtils.putInt(buf, offset, keyLength(cell));// Key length offset = ByteBufferUtils.putInt(buf, offset, cell.getValueLength());// Value length offset = appendKeyTo(cell, buf, offset); offset = CellUtil.copyValueTo(cell, buf, offset);// Value bytes int tagsLength = cell.getTagsLength(); if (withTags && (tagsLength > 0)) { offset = ByteBufferUtils.putAsShort(buf, offset, tagsLength);// Tags length offset = PrivateCellUtil.copyTagsTo(cell, buf, offset);// Tags bytes } return offset; }
/** * Copy the Cell content into the passed buf in KeyValue serialization format. */ public static int appendTo(Cell cell, ByteBuffer buf, int offset, boolean withTags) { offset = ByteBufferUtils.putInt(buf, offset, keyLength(cell));// Key length offset = ByteBufferUtils.putInt(buf, offset, cell.getValueLength());// Value length offset = appendKeyTo(cell, buf, offset); offset = CellUtil.copyValueTo(cell, buf, offset);// Value bytes int tagsLength = cell.getTagsLength(); if (withTags && (tagsLength > 0)) { offset = ByteBufferUtils.putAsShort(buf, offset, tagsLength);// Tags length offset = PrivateCellUtil.copyTagsTo(cell, buf, offset);// Tags bytes } return offset; }
@Test public void testCloneCellFieldsFromByteBufferedCell() { byte[] r = Bytes.toBytes("row1"); byte[] f = Bytes.toBytes("cf1"); byte[] q = Bytes.toBytes("qual1"); byte[] v = Bytes.toBytes("val1"); byte[] tags = Bytes.toBytes("tag1"); KeyValue kv = new KeyValue(r, f, q, 0, q.length, 1234L, KeyValue.Type.Put, v, 0, v.length, tags); ByteBuffer buffer = ByteBuffer.wrap(kv.getBuffer()); Cell bbCell = new ByteBufferKeyValue(buffer, 0, buffer.remaining()); byte[] rDest = CellUtil.cloneRow(bbCell); assertTrue(Bytes.equals(r, rDest)); byte[] fDest = CellUtil.cloneFamily(bbCell); assertTrue(Bytes.equals(f, fDest)); byte[] qDest = CellUtil.cloneQualifier(bbCell); assertTrue(Bytes.equals(q, qDest)); byte[] vDest = CellUtil.cloneValue(bbCell); assertTrue(Bytes.equals(v, vDest)); byte[] tDest = new byte[tags.length]; PrivateCellUtil.copyTagsTo(bbCell, tDest, 0); assertTrue(Bytes.equals(tags, tDest)); }
@Test public void testCloneCellFieldsFromByteBufferedCell() { byte[] r = Bytes.toBytes("row1"); byte[] f = Bytes.toBytes("cf1"); byte[] q = Bytes.toBytes("qual1"); byte[] v = Bytes.toBytes("val1"); byte[] tags = Bytes.toBytes("tag1"); KeyValue kv = new KeyValue(r, f, q, 0, q.length, 1234L, KeyValue.Type.Put, v, 0, v.length, tags); ByteBuffer buffer = ByteBuffer.wrap(kv.getBuffer()); Cell bbCell = new ByteBufferKeyValue(buffer, 0, buffer.remaining()); byte[] rDest = CellUtil.cloneRow(bbCell); assertTrue(Bytes.equals(r, rDest)); byte[] fDest = CellUtil.cloneFamily(bbCell); assertTrue(Bytes.equals(f, fDest)); byte[] qDest = CellUtil.cloneQualifier(bbCell); assertTrue(Bytes.equals(q, qDest)); byte[] vDest = CellUtil.cloneValue(bbCell); assertTrue(Bytes.equals(v, vDest)); byte[] tDest = new byte[tags.length]; PrivateCellUtil.copyTagsTo(bbCell, tDest, 0); assertTrue(Bytes.equals(tags, tDest)); }