Search in sources :

Example 16 with DrillBuf

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++;
    }
}
Also used : DrillBuf(io.netty.buffer.DrillBuf) SelectionVector4(org.apache.drill.exec.record.selection.SelectionVector4)

Example 17 with DrillBuf

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++;
        }
    }
}
Also used : DrillBuf(io.netty.buffer.DrillBuf) SelectionVector4(org.apache.drill.exec.record.selection.SelectionVector4)

Example 18 with DrillBuf

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);
}
Also used : RawFragmentBatch(org.apache.drill.exec.record.RawFragmentBatch) DrillBuf(io.netty.buffer.DrillBuf)

Example 19 with DrillBuf

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);
}
Also used : DrillBuf(io.netty.buffer.DrillBuf)

Example 20 with DrillBuf

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;
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) SerializedField(org.apache.drill.exec.proto.UserBitShared.SerializedField) RecordBatchDef(org.apache.drill.exec.proto.UserBitShared.RecordBatchDef) DrillBuf(io.netty.buffer.DrillBuf)

Aggregations

DrillBuf (io.netty.buffer.DrillBuf)187 Test (org.junit.Test)63 MemoryTest (org.apache.drill.categories.MemoryTest)38 SelectionVector4 (org.apache.drill.exec.record.selection.SelectionVector4)22 ValueVector (org.apache.drill.exec.vector.ValueVector)18 BaseTest (org.apache.drill.test.BaseTest)18 MaterializedField (org.apache.drill.exec.record.MaterializedField)16 IOException (java.io.IOException)13 VectorTest (org.apache.drill.categories.VectorTest)13 OutOfMemoryException (org.apache.drill.exec.exception.OutOfMemoryException)13 ExecTest (org.apache.drill.exec.ExecTest)11 BufferAllocator (org.apache.drill.exec.memory.BufferAllocator)11 VectorContainer (org.apache.drill.exec.record.VectorContainer)10 Stopwatch (com.google.common.base.Stopwatch)9 ByteBuffer (java.nio.ByteBuffer)9 BatchSchema (org.apache.drill.exec.record.BatchSchema)9 UnlikelyTest (org.apache.drill.categories.UnlikelyTest)8 UserBitShared (org.apache.drill.exec.proto.UserBitShared)8 SerializedField (org.apache.drill.exec.proto.UserBitShared.SerializedField)8 DrillTest (org.apache.drill.test.DrillTest)8