Search in sources :

Example 26 with ValueVector

use of org.apache.drill.exec.vector.ValueVector in project drill by apache.

the class ExternalSortBatch method createCopier.

private void createCopier(VectorAccessible batch, List<BatchGroup> batchGroupList, VectorContainer outputContainer, boolean spilling) throws SchemaChangeException {
    try {
        if (copier == null) {
            CodeGenerator<PriorityQueueCopier> cg = CodeGenerator.get(PriorityQueueCopier.TEMPLATE_DEFINITION, context.getFunctionRegistry(), context.getOptions());
            cg.plainJavaCapable(true);
            // Uncomment out this line to debug the generated code.
            //        cg.saveCodeForDebugging(true);
            ClassGenerator<PriorityQueueCopier> g = cg.getRoot();
            generateComparisons(g, batch);
            g.setMappingSet(COPIER_MAPPING_SET);
            CopyUtil.generateCopies(g, batch, true);
            g.setMappingSet(MAIN_MAPPING);
            copier = context.getImplementationClass(cg);
        } else {
            copier.close();
        }
        @SuppressWarnings("resource") BufferAllocator allocator = spilling ? copierAllocator : oAllocator;
        for (VectorWrapper<?> i : batch) {
            @SuppressWarnings("resource") ValueVector v = TypeHelper.getNewVector(i.getField(), allocator);
            outputContainer.add(v);
        }
        copier.setup(context, allocator, batch, batchGroupList, outputContainer);
    } catch (ClassTransformationException | IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) ClassTransformationException(org.apache.drill.exec.exception.ClassTransformationException) IOException(java.io.IOException) BufferAllocator(org.apache.drill.exec.memory.BufferAllocator)

Example 27 with ValueVector

use of org.apache.drill.exec.vector.ValueVector in project drill by apache.

the class FrameSupportTemplate method allocateInternal.

private void allocateInternal() {
    for (VectorWrapper<?> w : container) {
        ValueVector vv = internal.addOrGet(w.getField());
        vv.allocateNew();
    }
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) BaseDataValueVector(org.apache.drill.exec.vector.BaseDataValueVector)

Example 28 with ValueVector

use of org.apache.drill.exec.vector.ValueVector in project drill by apache.

the class HyperVectorWrapper method getChildWrapper.

@Override
public VectorWrapper<?> getChildWrapper(int[] ids) {
    if (ids.length == 1) {
        return this;
    }
    ValueVector[] vectors = new ValueVector[this.vectors.length];
    int index = 0;
    for (ValueVector v : this.vectors) {
        ValueVector vector = v;
        for (int i = 1; i < ids.length; i++) {
            final AbstractMapVector mapLike = AbstractMapVector.class.cast(vector);
            if (mapLike == null) {
                return null;
            }
            vector = mapLike.getChildByOrdinal(ids[i]);
        }
        vectors[index] = vector;
        index++;
    }
    return new HyperVectorWrapper<ValueVector>(vectors[0].getField(), vectors);
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) AbstractMapVector(org.apache.drill.exec.vector.complex.AbstractMapVector)

Example 29 with ValueVector

use of org.apache.drill.exec.vector.ValueVector in project drill by apache.

the class SimpleVectorWrapper method getChildWrapper.

@SuppressWarnings("resource")
@Override
public VectorWrapper<?> getChildWrapper(int[] ids) {
    if (ids.length == 1) {
        return this;
    }
    ValueVector vector = this.vector;
    for (int i = 1; i < ids.length; i++) {
        final AbstractMapVector mapLike = AbstractMapVector.class.cast(vector);
        if (mapLike == null) {
            return null;
        }
        vector = mapLike.getChildByOrdinal(ids[i]);
    }
    return new SimpleVectorWrapper<>(vector);
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) AbstractMapVector(org.apache.drill.exec.vector.complex.AbstractMapVector)

Example 30 with ValueVector

use of org.apache.drill.exec.vector.ValueVector in project drill by apache.

the class VectorAccessibleComplexWriter method addOrGet.

@Override
public <T extends ValueVector> T addOrGet(String name, MajorType type, Class<T> clazz) {
    final ValueVector v = vc.addOrGet(name, type, clazz);
    putChild(name, v);
    return this.typeify(v, clazz);
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector)

Aggregations

ValueVector (org.apache.drill.exec.vector.ValueVector)130 MaterializedField (org.apache.drill.exec.record.MaterializedField)29 Test (org.junit.Test)21 SchemaChangeException (org.apache.drill.exec.exception.SchemaChangeException)18 RecordBatchLoader (org.apache.drill.exec.record.RecordBatchLoader)13 VectorWrapper (org.apache.drill.exec.record.VectorWrapper)13 QueryDataBatch (org.apache.drill.exec.rpc.user.QueryDataBatch)12 ExecTest (org.apache.drill.exec.ExecTest)11 IOException (java.io.IOException)10 LogicalExpression (org.apache.drill.common.expression.LogicalExpression)10 VectorContainer (org.apache.drill.exec.record.VectorContainer)10 Drillbit (org.apache.drill.exec.server.Drillbit)10 ErrorCollector (org.apache.drill.common.expression.ErrorCollector)9 ErrorCollectorImpl (org.apache.drill.common.expression.ErrorCollectorImpl)9 RemoteServiceSet (org.apache.drill.exec.server.RemoteServiceSet)9 SchemaPath (org.apache.drill.common.expression.SchemaPath)8 MajorType (org.apache.drill.common.types.TypeProtos.MajorType)8 FunctionImplementationRegistry (org.apache.drill.exec.expr.fn.FunctionImplementationRegistry)8 FragmentContext (org.apache.drill.exec.ops.FragmentContext)8 PhysicalPlan (org.apache.drill.exec.physical.PhysicalPlan)8