/** * Data buffer can always be split and transferred using slicing. */ private void splitAndTransferValueBuffer(int startIndex, int length, BaseFixedWidthVector target) { final int startPoint = startIndex * typeWidth; final int sliceLength = length * typeWidth; target.valueBuffer = valueBuffer.slice(startPoint, sliceLength).transferOwnership(target.allocator).buffer; }
/** * Transfer this vector'data to another vector. The memory associated * with this vector is transferred to the allocator of target vector * for accounting and management purposes. * @param target destination vector for transfer */ public void transferTo(BaseFixedWidthVector target) { compareTypes(target, "transferTo"); target.clear(); target.validityBuffer = validityBuffer.transferOwnership(target.allocator).buffer; target.valueBuffer = valueBuffer.transferOwnership(target.allocator).buffer; target.valueCount = valueCount; clear(); }
@Nullable @Override public ArrowBuf apply(@Nullable ArrowBuf buf) { int writerIndex = buf.writerIndex(); ArrowBuf newBuf = buf.transferOwnership(allocator).buffer; newBuf.writerIndex(writerIndex); buf.release(); return newBuf; } }).toList();
/** * Transfer this vector'data to another vector. The memory associated * with this vector is transferred to the allocator of target vector * for accounting and management purposes. * @param target destination vector for transfer */ public void transferTo(BaseVariableWidthVector target) { compareTypes(target, "transferTo"); target.clear(); target.validityBuffer = validityBuffer.transferOwnership(target.allocator).buffer; target.valueBuffer = valueBuffer.transferOwnership(target.allocator).buffer; target.offsetBuffer = offsetBuffer.transferOwnership(target.allocator).buffer; target.setLastSet(this.lastSet); if (this.valueCount > 0) { target.setValueCount(this.valueCount); } clear(); }
/** * Create a new RawFragmentBatch based on this incoming data batch that is transferred into the provided allocator. * Also increments the AckSender to expect one additional return message. * * @param allocator * Target allocator that should be associated with data underlying this batch. * @return The newly created RawFragmentBatch */ public RawFragmentBatch newRawFragmentBatch(final BufferAllocator allocator) { final ArrowBuf transferredBuffer = body == null ? null : body.transferOwnership(allocator).buffer; sender.increment(); return new RawFragmentBatch(header, transferredBuffer, sender); }
@Nullable @Override public ArrowBuf apply(@Nullable ArrowBuf buf) { int writerIndex = buf.writerIndex(); ArrowBuf newBuf = buf.transferOwnership(context.getAllocator()).buffer; newBuf.writerIndex(writerIndex); buf.release(); return newBuf; } }).toList();
public WritableBatch transfer(BufferAllocator allocator) { List<ArrowBuf> newBuffers = Lists.newArrayList(); for (ArrowBuf buf : buffers) { int writerIndex = buf.writerIndex(); ArrowBuf newBuf = buf.transferOwnership(allocator).buffer; newBuf.writerIndex(writerIndex); newBuffers.add(newBuf); } clear(); return new WritableBatch(def, newBuffers); }
/** * Transfer this vector'data to another vector. The memory associated * with this vector is transferred to the allocator of target vector * for accounting and management purposes. */ @Override public void transfer() { to.clear(); dataTransferPair.transfer(); to.validityBuffer = validityBuffer.transferOwnership(to.allocator).buffer; to.offsetBuffer = offsetBuffer.transferOwnership(to.allocator).buffer; to.lastSet = lastSet; if (valueCount > 0) { to.setValueCount(valueCount); } clear(); }
/** * Create a new ArrowRecordBatch which has the same information as this batch but whose buffers * are owned by that Allocator. * * <p>This will also close this record batch and make it no longer useful. * * @return A cloned ArrowRecordBatch */ public ArrowRecordBatch cloneWithTransfer(final BufferAllocator allocator) { final List<ArrowBuf> newBufs = buffers.stream() .map(t -> (t.transferOwnership(allocator).buffer).writerIndex(t.writerIndex())) .collect(Collectors.toList()); close(); return new ArrowRecordBatch(false, length, nodes, newBufs); }
@Override public void transfer() { target.clear(); target.validityBuffer = validityBuffer.transferOwnership(target.allocator).buffer; super.transfer(); clear(); }
public void transferTo(SimpleIntVector target) { target.clear(); target.dataBuffer = this.dataBuffer.transferOwnership(target.allocator).buffer; target.dataBuffer.writerIndex(this.dataBuffer.writerIndex()); this.clear(); }
@Override public void transfer() { to.clear(); dataPair.transfer(); to.validityBuffer = validityBuffer.transferOwnership(to.allocator).buffer; to.setValueCount(valueCount); clear(); }
/** * Transfer the offsets along with data. Unlike the data buffer, we cannot simply * slice the offset buffer for split and transfer. The reason is that offsets * in the target vector have to be adjusted and made relative to the staring * offset in source vector from the start index of split. This is why, we * need to explicitly allocate the offset buffer and set the adjusted offsets * in the target vector. */ private void splitAndTransferOffsetBuffer(int startIndex, int length, BaseVariableWidthVector target) { final int start = offsetBuffer.getInt(startIndex * OFFSET_WIDTH); final int end = offsetBuffer.getInt((startIndex + length) * OFFSET_WIDTH); final int dataLength = end - start; target.allocateOffsetBuffer((length + 1) * OFFSET_WIDTH); for (int i = 0; i < length + 1; i++) { final int relativeSourceOffset = offsetBuffer.getInt((startIndex + i) * OFFSET_WIDTH) - start; target.offsetBuffer.setInt(i * OFFSET_WIDTH, relativeSourceOffset); } target.valueBuffer = valueBuffer.slice(start, dataLength).transferOwnership(target.allocator).buffer; }