use of io.netty.buffer.DrillBuf in project drill by axbaretto.
the class PriorityQueueCopierTemplate method setup.
@Override
public void setup(FragmentContext context, BufferAllocator allocator, VectorAccessible hyperBatch, List<BatchGroup> batchGroups, VectorAccessible outgoing) throws SchemaChangeException {
this.hyperBatch = hyperBatch;
this.batchGroups = batchGroups;
this.outgoing = outgoing;
this.size = batchGroups.size();
final DrillBuf drillBuf = allocator.buffer(4 * size);
vector4 = new SelectionVector4(drillBuf, size, Character.MAX_VALUE);
doSetup(context, hyperBatch, outgoing);
queueSize = 0;
for (int i = 0; i < size; i++) {
vector4.set(i, i, batchGroups.get(i).getNextIndex());
siftUp();
queueSize++;
}
}
use of io.netty.buffer.DrillBuf in project drill by axbaretto.
the class PriorityQueueCopierTemplate method setup.
@Override
public void setup(BufferAllocator allocator, VectorAccessible hyperBatch, List<BatchGroup> batchGroups, VectorAccessible outgoing) throws SchemaChangeException {
this.hyperBatch = hyperBatch;
this.batchGroups = batchGroups;
this.outgoing = outgoing;
this.size = batchGroups.size();
@SuppressWarnings("resource") final DrillBuf drillBuf = allocator.buffer(4 * size);
vector4 = new SelectionVector4(drillBuf, size, Character.MAX_VALUE);
doSetup(hyperBatch, outgoing);
queueSize = 0;
for (int i = 0; i < size; i++) {
int index = batchGroups.get(i).getNextIndex();
vector4.set(i, i, index);
if (index > -1) {
siftUp();
queueSize++;
}
}
}
use of io.netty.buffer.DrillBuf in project drill by axbaretto.
the class IncomingDataBatch method newRawFragmentBatch.
/**
* 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 DrillBuf transferredBuffer = body == null ? null : body.transferOwnership(allocator).buffer;
sender.increment();
return new RawFragmentBatch(header, transferredBuffer, sender);
}
use of io.netty.buffer.DrillBuf in project drill by axbaretto.
the class WritableBatch method transfer.
public WritableBatch transfer(BufferAllocator allocator) {
List<DrillBuf> newBuffers = Lists.newArrayList();
for (DrillBuf buf : buffers) {
int writerIndex = buf.writerIndex();
DrillBuf newBuf = buf.transferOwnership(allocator).buffer;
newBuf.writerIndex(writerIndex);
newBuffers.add(newBuf);
}
clear();
return new WritableBatch(def, newBuffers);
}
use of io.netty.buffer.DrillBuf in project drill by axbaretto.
the class WritableBatch method getBatchNoHV.
public static WritableBatch getBatchNoHV(int recordCount, Iterable<ValueVector> vectors, boolean isSV2) {
List<DrillBuf> buffers = Lists.newArrayList();
List<SerializedField> metadata = Lists.newArrayList();
for (ValueVector vv : vectors) {
metadata.add(vv.getMetadata());
// don't try to get the buffers if we don't have any records. It is possible the buffers are dead buffers.
if (recordCount == 0) {
vv.clear();
continue;
}
for (DrillBuf b : vv.getBuffers(true)) {
buffers.add(b);
}
// remove vv access to buffers.
vv.clear();
}
RecordBatchDef batchDef = RecordBatchDef.newBuilder().addAllField(metadata).setRecordCount(recordCount).setCarriesTwoByteSelectionVector(isSV2).build();
WritableBatch b = new WritableBatch(batchDef, buffers);
return b;
}
Aggregations