Search in sources :

Example 1 with SingleVectorAccessor

use of org.apache.drill.exec.vector.accessor.reader.VectorAccessors.SingleVectorAccessor 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 2 with SingleVectorAccessor

use of org.apache.drill.exec.vector.accessor.reader.VectorAccessors.SingleVectorAccessor 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)

Aggregations

VectorAccessor (org.apache.drill.exec.vector.accessor.reader.VectorAccessor)2 SingleVectorAccessor (org.apache.drill.exec.vector.accessor.reader.VectorAccessors.SingleVectorAccessor)2 MajorType (org.apache.drill.common.types.TypeProtos.MajorType)1 AbstractObjectReader (org.apache.drill.exec.vector.accessor.reader.AbstractObjectReader)1 DictVector (org.apache.drill.exec.vector.complex.DictVector)1 RepeatedValueVector (org.apache.drill.exec.vector.complex.RepeatedValueVector)1