Search in sources :

Example 1 with VectorAccessor

use of org.apache.drill.exec.vector.accessor.reader.VectorAccessor in project drill by apache.

the class HyperReaderBuilder method buildContainerChildren.

protected List<AbstractObjectReader> buildContainerChildren(VectorContainer container, TupleMetadata schema) {
    List<AbstractObjectReader> readers = new ArrayList<>();
    for (int i = 0; i < container.getNumberOfColumns(); i++) {
        VectorWrapper<?> vw = container.getValueVector(i);
        VectorAccessor va = new HyperVectorAccessor(vw);
        readers.add(buildVectorReader(va, schema.metadata(i)));
    }
    return readers;
}
Also used : AbstractObjectReader(org.apache.drill.exec.vector.accessor.reader.AbstractObjectReader) BaseHyperVectorAccessor(org.apache.drill.exec.vector.accessor.reader.VectorAccessors.BaseHyperVectorAccessor) ArrayList(java.util.ArrayList) BaseHyperVectorAccessor(org.apache.drill.exec.vector.accessor.reader.VectorAccessors.BaseHyperVectorAccessor) VectorAccessor(org.apache.drill.exec.vector.accessor.reader.VectorAccessor)

Example 2 with VectorAccessor

use of org.apache.drill.exec.vector.accessor.reader.VectorAccessor in project drill by apache.

the class SimpleReaderBuilder method buildDict.

private AbstractObjectReader buildDict(ValueVector vector, VectorAccessor va, VectorDescrip descrip) {
    boolean isArray = descrip.metadata.isArray();
    DictVector dictVector;
    VectorAccessor dictAccessor;
    if (isArray) {
        dictVector = (DictVector) ((RepeatedValueVector) vector).getDataVector();
        dictAccessor = new SingleVectorAccessor(dictVector);
    } else {
        dictVector = (DictVector) vector;
        dictAccessor = va;
    }
    List<AbstractObjectReader> readers = buildMapMembers(dictVector, descrip.childProvider());
    AbstractObjectReader reader = DictReaderImpl.build(descrip.metadata, dictAccessor, readers);
    if (!isArray) {
        return reader;
    }
    return ArrayReaderImpl.buildTuple(descrip.metadata, va, reader);
}
Also used : DictVector(org.apache.drill.exec.vector.complex.DictVector) AbstractObjectReader(org.apache.drill.exec.vector.accessor.reader.AbstractObjectReader) RepeatedValueVector(org.apache.drill.exec.vector.complex.RepeatedValueVector) SingleVectorAccessor(org.apache.drill.exec.vector.accessor.reader.VectorAccessors.SingleVectorAccessor) VectorAccessor(org.apache.drill.exec.vector.accessor.reader.VectorAccessor) SingleVectorAccessor(org.apache.drill.exec.vector.accessor.reader.VectorAccessors.SingleVectorAccessor)

Example 3 with VectorAccessor

use of org.apache.drill.exec.vector.accessor.reader.VectorAccessor in project drill by apache.

the class SimpleReaderBuilder method buildVectorReader.

protected AbstractObjectReader buildVectorReader(ValueVector vector, VectorDescrip descrip) {
    final VectorAccessor va = new SingleVectorAccessor(vector);
    final MajorType type = va.type();
    switch(type.getMinorType()) {
        case DICT:
            return buildDict(vector, va, descrip);
        case MAP:
            return buildMap((AbstractMapVector) vector, va, type.getMode(), descrip);
        case UNION:
            return buildUnion((UnionVector) vector, va, descrip);
        case LIST:
            return buildList(vector, va, descrip);
        case LATE:
            return AbstractScalarReader.nullReader(descrip.metadata);
        default:
            return buildScalarReader(va, descrip.metadata);
    }
}
Also used : MajorType(org.apache.drill.common.types.TypeProtos.MajorType) SingleVectorAccessor(org.apache.drill.exec.vector.accessor.reader.VectorAccessors.SingleVectorAccessor) VectorAccessor(org.apache.drill.exec.vector.accessor.reader.VectorAccessor) SingleVectorAccessor(org.apache.drill.exec.vector.accessor.reader.VectorAccessors.SingleVectorAccessor)

Example 4 with VectorAccessor

use of org.apache.drill.exec.vector.accessor.reader.VectorAccessor in project drill by apache.

the class HyperReaderBuilder method buildDict.

private AbstractObjectReader buildDict(VectorAccessor va, ColumnMetadata metadata) {
    boolean isArray = metadata.isArray();
    ValueVector vector = va.vector();
    VectorAccessor dictAccessor;
    if (isArray) {
        ValueVector dictVector = ((RepeatedValueVector) vector).getDataVector();
        dictAccessor = new VectorAccessors.SingleVectorAccessor(dictVector);
    } else {
        dictAccessor = va;
    }
    List<AbstractObjectReader> readers = buildMapMembers(dictAccessor, metadata.tupleSchema());
    AbstractObjectReader reader = DictReaderImpl.build(metadata, dictAccessor, readers);
    if (!isArray) {
        return reader;
    }
    return ArrayReaderImpl.buildTuple(metadata, va, reader);
}
Also used : RepeatedValueVector(org.apache.drill.exec.vector.complex.RepeatedValueVector) ValueVector(org.apache.drill.exec.vector.ValueVector) AbstractObjectReader(org.apache.drill.exec.vector.accessor.reader.AbstractObjectReader) RepeatedValueVector(org.apache.drill.exec.vector.complex.RepeatedValueVector) BaseHyperVectorAccessor(org.apache.drill.exec.vector.accessor.reader.VectorAccessors.BaseHyperVectorAccessor) VectorAccessor(org.apache.drill.exec.vector.accessor.reader.VectorAccessor) VectorAccessors(org.apache.drill.exec.vector.accessor.reader.VectorAccessors)

Aggregations

VectorAccessor (org.apache.drill.exec.vector.accessor.reader.VectorAccessor)4 AbstractObjectReader (org.apache.drill.exec.vector.accessor.reader.AbstractObjectReader)3 BaseHyperVectorAccessor (org.apache.drill.exec.vector.accessor.reader.VectorAccessors.BaseHyperVectorAccessor)2 SingleVectorAccessor (org.apache.drill.exec.vector.accessor.reader.VectorAccessors.SingleVectorAccessor)2 RepeatedValueVector (org.apache.drill.exec.vector.complex.RepeatedValueVector)2 ArrayList (java.util.ArrayList)1 MajorType (org.apache.drill.common.types.TypeProtos.MajorType)1 ValueVector (org.apache.drill.exec.vector.ValueVector)1 VectorAccessors (org.apache.drill.exec.vector.accessor.reader.VectorAccessors)1 DictVector (org.apache.drill.exec.vector.complex.DictVector)1