本文整理了Java中org.apache.hadoop.hbase.util.ByteBufferUtils.copyFromBufferToBuffer()
方法的一些代码示例,展示了ByteBufferUtils.copyFromBufferToBuffer()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBufferUtils.copyFromBufferToBuffer()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.util.ByteBufferUtils
类名称:ByteBufferUtils
方法名:copyFromBufferToBuffer
[英]Copy one buffer's whole data to another. Write starts at the current position of 'out' buffer. Note : This will advance the position marker of out and also change the position maker for in.
[中]将一个缓冲区的全部数据复制到另一个缓冲区。写入从“输出”缓冲区的当前位置开始。注意:这将使位置标记前进到out,并将位置标记更改为in。
代码示例来源:origin: apache/hbase
@Override
public void get(ByteBuffer out, int sourceOffset, int length) {
ByteBufferUtils.copyFromBufferToBuffer(buf, out, sourceOffset, length);
}
代码示例来源:origin: apache/hbase
@Override
public void write(ByteBuffer buf, int offset) {
ByteBufferUtils.copyFromBufferToBuffer(this.buf, buf, this.offset, offset, this.length);
}
代码示例来源:origin: apache/hbase
@Override
public void write(ByteBuffer b, int off, int len) throws IOException {
checkSizeAndGrow(len);
ByteBufferUtils.copyFromBufferToBuffer(b, curBuf, off, len);
}
代码示例来源:origin: apache/hbase
@Override
public void write(ByteBuffer b, int off, int len) throws IOException {
int toWrite = 0;
while (len > 0) {
toWrite = Math.min(len, this.curBuf.remaining());
ByteBufferUtils.copyFromBufferToBuffer(b, this.curBuf, off, toWrite);
off += toWrite;
len -= toWrite;
if (len > 0) {
allocateNewBuffer();// The curBuf is over. Let us move to the next one
}
}
}
}
代码示例来源:origin: apache/hbase
protected void checkSizeAndGrow(int extra) {
long capacityNeeded = curBuf.position() + (long) extra;
if (capacityNeeded > curBuf.limit()) {
// guarantee it's possible to fit
if (capacityNeeded > MAX_ARRAY_SIZE) {
throw new BufferOverflowException();
}
// double until hit the cap
long nextCapacity = Math.min(curBuf.capacity() * 2L, MAX_ARRAY_SIZE);
// but make sure there is enough if twice the existing capacity is still too small
nextCapacity = Math.max(nextCapacity, capacityNeeded);
ByteBuffer newBuf = allocate((int) nextCapacity, curBuf.isDirect());
curBuf.flip();
ByteBufferUtils.copyFromBufferToBuffer(curBuf, newBuf);
curBuf = newBuf;
}
}
代码示例来源:origin: apache/hbase
@Override
public SingleByteBuff put(int offset, ByteBuff src, int srcOffset, int length) {
if (src instanceof SingleByteBuff) {
ByteBufferUtils.copyFromBufferToBuffer(((SingleByteBuff) src).buf, this.buf, srcOffset,
offset, length);
} else {
// TODO we can do some optimization here? Call to asSubByteBuffer might
// create a copy.
ObjectIntPair
src.asSubByteBuffer(srcOffset, length, pair);
if (pair.getFirst() != null) {
ByteBufferUtils.copyFromBufferToBuffer(pair.getFirst(), this.buf, pair.getSecond(), offset,
length);
}
}
return this;
}
代码示例来源:origin: apache/hbase
private int decodeKeyValue(DataInputStream source, ByteBuffer buffer,
int prevKeyOffset)
throws IOException, EncoderBufferTooSmallException {
int keyLength = ByteBufferUtils.readCompressedInt(source);
int valueLength = ByteBufferUtils.readCompressedInt(source);
int commOnLength= ByteBufferUtils.readCompressedInt(source);
int keyOffset;
keyLength += commonLength;
ensureSpace(buffer, keyLength + valueLength + KeyValue.ROW_OFFSET);
buffer.putInt(keyLength);
buffer.putInt(valueLength);
// copy the prefix
if (commonLength > 0) {
keyOffset = buffer.position();
ByteBufferUtils.copyFromBufferToBuffer(buffer, buffer, prevKeyOffset,
commonLength);
} else {
keyOffset = buffer.position();
}
// copy rest of the key and value
int len = keyLength - commonLength + valueLength;
ByteBufferUtils.copyFromStreamToBuffer(buffer, source, len);
return keyOffset;
}
代码示例来源:origin: apache/hbase
/**
* Test copying from buffer.
*/
@Test
public void testCopyFromBuffer() {
ByteBuffer srcBuffer = ByteBuffer.allocate(array.length);
ByteBuffer dstBuffer = ByteBuffer.allocate(array.length);
srcBuffer.put(array);
ByteBufferUtils.copyFromBufferToBuffer(srcBuffer, dstBuffer,
array.length / 2, array.length / 4);
for (int i = 0; i
dstBuffer.get(i));
}
}
代码示例来源:origin: apache/hbase
toRead = srcItem.limit() - srcOffset;
toMove = Math.min(length, Math.min(toRead, toWrite));
ByteBufferUtils.copyFromBufferToBuffer(srcItem, destItem, srcOffset, offset, toMove);
length -= toMove;
if (length == 0) break;
代码示例来源:origin: apache/hbase
ByteBufferUtils.copyFromBufferToBuffer(out, out, prevOffset, common);
ByteBufferUtils.copyFromBufferToBuffer(out, out,
state.prevOffset + KeyValue.ROW_OFFSET + KeyValue.ROW_LENGTH_SIZE
+ state.rowLength, state.familyLength
ByteBufferUtils.copyFromBufferToBuffer(out, out,
state.prevTimestampOffset, prefixTimestamp);
state.prevTimestampOffset = out.position() - prefixTimestamp;
out.put(state.type);
if ((flag & FLAG_SAME_VALUE) != 0) {
ByteBufferUtils.copyFromBufferToBuffer(out, out, state.prevOffset +
KeyValue.ROW_OFFSET + prevKeyLength, state.valueLength);
} else {
ByteBufferUtils.copyFromStreamToBuffer(out, source,
KeyValue.TYPE_SIZE);
ByteBufferUtils.copyFromBufferToBuffer(out, out, state.prevOffset +
KeyValue.ROW_OFFSET + prevKeyLength, state.valueLength);
} else {
代码示例来源:origin: apache/hbase
@Test
public void testRelativeCopyFromBuffertoBuffer() {
ByteBuffer bb1 = ByteBuffer.allocate(135);
ByteBuffer bb2 = ByteBuffer.allocate(135);
fillBB(bb1, (byte) 5);
ByteBufferUtils.copyFromBufferToBuffer(bb1, bb2);
assertTrue(bb1.position() == bb2.position());
assertTrue(bb1.limit() == bb2.limit());
bb1 = ByteBuffer.allocateDirect(135);
bb2 = ByteBuffer.allocateDirect(135);
fillBB(bb1, (byte) 5);
ByteBufferUtils.copyFromBufferToBuffer(bb1, bb2);
assertTrue(bb1.position() == bb2.position());
assertTrue(bb1.limit() == bb2.limit());
}
@Test
代码示例来源:origin: apache/hbase
ByteBufferUtils.copyFromBufferToBuffer(buffer, buffer, state.prevOffset
+ KeyValue.ROW_OFFSET, commonPrefix);
代码示例来源:origin: apache/hbase
/**
* 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;
}
代码示例来源:origin: apache/hbase
/**
* 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;
}
代码示例来源:origin: apache/hbase
/**
* 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;
}
代码示例来源:origin: apache/hbase
/**
* 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;
}
代码示例来源:origin: apache/hbase
ByteBufferUtils.copyFromBufferToBuffer((ByteBuffer) input,
(ByteBuffer) output, offset, offset, length);
代码示例来源:origin: apache/hbase
/**
* 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;
}
代码示例来源:origin: org.apache.hbase/hbase-common
@Override
public void write(ByteBuffer b, int off, int len) throws IOException {
checkSizeAndGrow(len);
ByteBufferUtils.copyFromBufferToBuffer(b, curBuf, off, len);
}
代码示例来源:origin: com.aliyun.hbase/alihbase-common
@Override
public void write(ByteBuffer b, int off, int len) throws IOException {
checkSizeAndGrow(len);
ByteBufferUtils.copyFromBufferToBuffer(b, curBuf, off, len);
}