/** * Allocate a slice of the given length. */ public ByteBuffer clone(ByteBuffer buffer) { assert buffer != null; if (buffer.remaining() == 0) return ByteBufferUtil.EMPTY_BYTE_BUFFER; ByteBuffer cloned = allocate(buffer.remaining()); cloned.mark(); cloned.put(buffer.duplicate()); cloned.reset(); return cloned; }
/** * Allocate a slice of the given length. */ public ByteBuffer clone(ByteBuffer buffer) { assert buffer != null; if (buffer.remaining() == 0) return ByteBufferUtil.EMPTY_BYTE_BUFFER; ByteBuffer cloned = allocate(buffer.remaining()); cloned.mark(); cloned.put(buffer.duplicate()); cloned.reset(); return cloned; }
/** * Allocate a slice of the given length. */ public ByteBuffer clone(ByteBuffer buffer) { assert buffer != null; if (buffer.remaining() == 0) return ByteBufferUtil.EMPTY_BYTE_BUFFER; ByteBuffer cloned = allocate(buffer.remaining()); cloned.mark(); cloned.put(buffer.duplicate()); cloned.reset(); return cloned; }
/** * Allocate a slice of the given length. */ public ByteBuffer clone(ByteBuffer buffer) { assert buffer != null; if (buffer.remaining() == 0) return ByteBufferUtil.EMPTY_BYTE_BUFFER; ByteBuffer cloned = allocate(buffer.remaining()); cloned.mark(); cloned.put(buffer.duplicate()); cloned.reset(); return cloned; }
/** * Allocate a slice of the given length. */ public ByteBuffer clone(ByteBuffer buffer) { assert buffer != null; if (buffer.remaining() == 0) return ByteBufferUtil.EMPTY_BYTE_BUFFER; ByteBuffer cloned = allocate(buffer.remaining()); cloned.mark(); cloned.put(buffer.duplicate()); cloned.reset(); return cloned; }
private ByteBuffer get(int i, AbstractAllocator copy) { // remember to take dense/sparse into account, and only return EOC when not dense int size = size(); assert i >= 0 && i < size(); int cellNamesOffset = nameDeltaOffset(size); int startDelta = i == 0 ? 0 : getShort(nameDeltaOffset(i)); int endDelta = i < size - 1 ? getShort(nameDeltaOffset(i + 1)) : valueStartOffset() - cellNamesOffset; int length = endDelta - startDelta; if (copy == null) return getByteBuffer(cellNamesOffset + startDelta, length).order(ByteOrder.BIG_ENDIAN); ByteBuffer result = copy.allocate(length); FastByteOperations.UnsafeOperations.copy(null, peer + cellNamesOffset + startDelta, result, 0, length); return result; }