本文整理汇总了Java中org.apache.hadoop.hbase.util.ByteBufferUtils.copyFromArrayToBuffer方法的典型用法代码示例。如果您正苦于以下问题:Java ByteBufferUtils.copyFromArrayToBuffer方法的具体用法?Java ByteBufferUtils.copyFromArrayToBuffer怎么用?Java ByteBufferUtils.copyFromArrayToBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.util.ByteBufferUtils
的用法示例。
在下文中一共展示了ByteBufferUtils.copyFromArrayToBuffer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetKeyMethods
import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
@Test
public void testGetKeyMethods() throws Exception {
KeyValue kvCell = new KeyValue(row1, fam1, qual1, 0L, Type.Put, row1, tags);
ByteBuffer buf = ByteBuffer.allocateDirect(kvCell.getKeyLength());
ByteBufferUtils.copyFromArrayToBuffer(buf, kvCell.getBuffer(), kvCell.getKeyOffset(),
kvCell.getKeyLength());
ByteBufferExtendedCell offheapKeyOnlyKV = new ByteBufferKeyOnlyKeyValue(buf, 0, buf.capacity());
assertEquals(
ROW1,
ByteBufferUtils.toStringBinary(offheapKeyOnlyKV.getRowByteBuffer(),
offheapKeyOnlyKV.getRowPosition(), offheapKeyOnlyKV.getRowLength()));
assertEquals(
FAM1,
ByteBufferUtils.toStringBinary(offheapKeyOnlyKV.getFamilyByteBuffer(),
offheapKeyOnlyKV.getFamilyPosition(), offheapKeyOnlyKV.getFamilyLength()));
assertEquals(
QUAL1,
ByteBufferUtils.toStringBinary(offheapKeyOnlyKV.getQualifierByteBuffer(),
offheapKeyOnlyKV.getQualifierPosition(),
offheapKeyOnlyKV.getQualifierLength()));
assertEquals(0L, offheapKeyOnlyKV.getTimestamp());
assertEquals(Type.Put.getCode(), offheapKeyOnlyKV.getTypeByte());
}
示例2: write
import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
@Override
public void write(ByteBuffer buf, int offset) {
offset = KeyValueUtil.appendTo(this.cell, buf, offset, false);
int tagsLen = this.tags == null ? 0 : this.tags.length;
if (tagsLen > 0) {
offset = ByteBufferUtils.putAsShort(buf, offset, tagsLen);
ByteBufferUtils.copyFromArrayToBuffer(buf, offset, this.tags, 0, tagsLen);
}
}
示例3: copyTagsTo
import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
/**
* Copies the tags info into the tag portion of the cell
* @param cell
* @param destination
* @param destinationOffset
* @return the position after tags
*/
public static int copyTagsTo(Cell cell, ByteBuffer destination, int destinationOffset) {
int tlen = cell.getTagsLength();
if (cell instanceof ByteBufferExtendedCell) {
ByteBufferUtils.copyFromBufferToBuffer(((ByteBufferExtendedCell) cell).getTagsByteBuffer(),
destination, ((ByteBufferExtendedCell) cell).getTagsPosition(), destinationOffset, tlen);
} else {
ByteBufferUtils.copyFromArrayToBuffer(destination, destinationOffset, cell.getTagsArray(),
cell.getTagsOffset(), tlen);
}
return destinationOffset + tlen;
}
示例4: writeCellToBuffer
import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
/**
* Writes a cell to the buffer at the given offset
* @param cell the cell to be written
* @param buf the buffer to which the cell has to be wrriten
* @param offset the offset at which the cell should be written
*/
public static void writeCellToBuffer(Cell cell, ByteBuffer buf, int offset) {
if (cell instanceof ExtendedCell) {
((ExtendedCell) cell).write(buf, offset);
} else {
// Using the KVUtil
byte[] bytes = KeyValueUtil.copyToNewByteArray(cell);
ByteBufferUtils.copyFromArrayToBuffer(buf, offset, bytes, 0, bytes.length);
}
}
示例5: copyRowTo
import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
/**
* 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;
}
示例6: copyFamilyTo
import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
/**
* Copies the family to the given bytebuffer
* @param cell the cell whose family has to be copied
* @param destination the destination bytebuffer to which the family 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 copyFamilyTo(Cell cell, ByteBuffer destination, int destinationOffset) {
byte fLen = cell.getFamilyLength();
if (cell instanceof ByteBufferExtendedCell) {
ByteBufferUtils.copyFromBufferToBuffer(((ByteBufferExtendedCell) cell).getFamilyByteBuffer(),
destination, ((ByteBufferExtendedCell) cell).getFamilyPosition(), destinationOffset, fLen);
} else {
ByteBufferUtils.copyFromArrayToBuffer(destination, destinationOffset, cell.getFamilyArray(),
cell.getFamilyOffset(), fLen);
}
return destinationOffset + fLen;
}
示例7: copyQualifierTo
import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
/**
* Copies the qualifier to the given bytebuffer
* @param cell the cell whose qualifier has to be copied
* @param destination the destination bytebuffer to which the qualifier 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 copyQualifierTo(Cell cell, ByteBuffer destination, int destinationOffset) {
int qlen = cell.getQualifierLength();
if (cell instanceof ByteBufferExtendedCell) {
ByteBufferUtils.copyFromBufferToBuffer(
((ByteBufferExtendedCell) cell).getQualifierByteBuffer(),
destination, ((ByteBufferExtendedCell) cell).getQualifierPosition(),
destinationOffset, qlen);
} else {
ByteBufferUtils.copyFromArrayToBuffer(destination, destinationOffset,
cell.getQualifierArray(), cell.getQualifierOffset(), qlen);
}
return destinationOffset + qlen;
}
示例8: copyValueTo
import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
/**
* 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;
}
示例9: put
import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
/**
* Copies from the given byte[] to this MBB
* @param src
* @param offset the position in the byte array from which the copy should be done
* @param length the length upto which the copy should happen
* @return this MBB
*/
@Override
public MultiByteBuff put(byte[] src, int offset, int length) {
if (this.curItem.remaining() >= length) {
ByteBufferUtils.copyFromArrayToBuffer(this.curItem, src, offset, length);
return this;
}
int end = offset + length;
for (int i = offset; i < end; i++) {
this.put(src[i]);
}
return this;
}
示例10: write
import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
@Override
public void write(byte[] b, int off, int len) throws IOException {
int toWrite = 0;
while (len > 0) {
toWrite = Math.min(len, this.curBuf.remaining());
ByteBufferUtils.copyFromArrayToBuffer(this.curBuf, b, off, toWrite);
off += toWrite;
len -= toWrite;
if (len > 0) {
allocateNewBuffer();// The curBuf is over. Let us move to the next one
}
}
}
示例11: testByteBufferBackedKeyValueWithTags
import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
@Test
public void testByteBufferBackedKeyValueWithTags() throws Exception {
KeyValue kvCell = new KeyValue(row1, fam1, qual1, 0L, Type.Put, row1, tags);
ByteBuffer buf = ByteBuffer.allocateDirect(kvCell.getBuffer().length);
ByteBufferUtils.copyFromArrayToBuffer(buf, kvCell.getBuffer(), 0, kvCell.getBuffer().length);
ByteBufferKeyValue offheapKV = new ByteBufferKeyValue(buf, 0, buf.capacity(), 0L);
assertEquals(
ROW1,
ByteBufferUtils.toStringBinary(offheapKV.getRowByteBuffer(),
offheapKV.getRowPosition(), offheapKV.getRowLength()));
assertEquals(
FAM1,
ByteBufferUtils.toStringBinary(offheapKV.getFamilyByteBuffer(),
offheapKV.getFamilyPosition(), offheapKV.getFamilyLength()));
assertEquals(
QUAL1,
ByteBufferUtils.toStringBinary(offheapKV.getQualifierByteBuffer(),
offheapKV.getQualifierPosition(), offheapKV.getQualifierLength()));
assertEquals(
ROW1,
ByteBufferUtils.toStringBinary(offheapKV.getValueByteBuffer(),
offheapKV.getValuePosition(), offheapKV.getValueLength()));
assertEquals(0L, offheapKV.getTimestamp());
assertEquals(Type.Put.getCode(), offheapKV.getTypeByte());
// change tags to handle both onheap and offheap stuff
List<Tag> resTags = PrivateCellUtil.getTags(offheapKV);
Tag tag1 = resTags.get(0);
assertEquals(t1.getType(), tag1.getType());
assertEquals(Tag.getValueAsString(t1),
Tag.getValueAsString(tag1));
Tag tag2 = resTags.get(1);
assertEquals(tag2.getType(), tag2.getType());
assertEquals(Tag.getValueAsString(t2),
Tag.getValueAsString(tag2));
Tag res = PrivateCellUtil.getTag(offheapKV, (byte) 2).get();
assertEquals(Tag.getValueAsString(t2),
Tag.getValueAsString(tag2));
assertFalse(PrivateCellUtil.getTag(offheapKV, (byte) 3).isPresent());
}
示例12: createOffheapKVWithTags
import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
private Cell createOffheapKVWithTags(int noOfTags) {
List<Tag> tags = new ArrayList<>();
for (int i = 0; i < noOfTags; i++) {
tags.add(new ArrayBackedTag((byte) i, "tagValue" + i));
}
KeyValue kv = new KeyValue(ROW, CF, Q, 1234L, V, tags);
ByteBuffer dbb = ByteBuffer.allocateDirect(kv.getBuffer().length);
ByteBufferUtils.copyFromArrayToBuffer(dbb, kv.getBuffer(), 0, kv.getBuffer().length);
ByteBufferKeyValue offheapKV = new ByteBufferKeyValue(dbb, 0, kv.getBuffer().length, 0);
return offheapKV;
}
示例13: write
import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
@Override
public void write(ByteBuffer buf, int offset) {
ByteBufferUtils.copyFromArrayToBuffer(buf, offset, this.bytes, this.offset, this.length);
}
示例14: setTimestamp
import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
@Override
public void setTimestamp(long ts) throws IOException {
ByteBufferUtils.copyFromArrayToBuffer(this.buf, this.getTimestampOffset(), Bytes.toBytes(ts), 0,
Bytes.SIZEOF_LONG);
}
示例15: put
import org.apache.hadoop.hbase.util.ByteBufferUtils; //导入方法依赖的package包/类
@Override
public SingleByteBuff put(byte[] src, int offset, int length) {
ByteBufferUtils.copyFromArrayToBuffer(this.buf, src, offset, length);
return this;
}