Search in sources :

Example 11 with AbstractObjectReader

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

the class SimpleReaderBuilder method buildMapMembers.

protected List<AbstractObjectReader> buildMapMembers(AbstractMapVector mapVector, MetadataProvider provider) {
    final List<AbstractObjectReader> readers = new ArrayList<>();
    int i = 0;
    for (final ValueVector vector : mapVector) {
        final VectorDescrip descrip = new VectorDescrip(provider, i, vector.getField());
        readers.add(buildVectorReader(vector, descrip));
        i++;
    }
    return readers;
}
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) ArrayList(java.util.ArrayList) VectorDescrip(org.apache.drill.exec.physical.resultSet.model.MetadataProvider.VectorDescrip)

Example 12 with AbstractObjectReader

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

the class SimpleReaderBuilder method buildUnion.

private AbstractObjectReader buildUnion(UnionVector vector, VectorAccessor unionAccessor, VectorDescrip descrip) {
    final MetadataProvider provider = descrip.childProvider();
    final AbstractObjectReader[] variants = new AbstractObjectReader[MinorType.values().length];
    int i = 0;
    for (final MinorType type : vector.getField().getType().getSubTypeList()) {
        // This call will create the vector if it does not yet exist.
        // Will throw an exception for unsupported types.
        // so call this only if the MajorType reports that the type
        // already exists.
        final ValueVector memberVector = vector.getMember(type);
        final VectorDescrip memberDescrip = new VectorDescrip(provider, i++, memberVector.getField());
        variants[type.ordinal()] = buildVectorReader(memberVector, memberDescrip);
    }
    return UnionReaderImpl.build(descrip.metadata, unionAccessor, variants);
}
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) MetadataProvider(org.apache.drill.exec.physical.resultSet.model.MetadataProvider) MinorType(org.apache.drill.common.types.TypeProtos.MinorType) VectorDescrip(org.apache.drill.exec.physical.resultSet.model.MetadataProvider.VectorDescrip)

Example 13 with AbstractObjectReader

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

the class SimpleReaderBuilder method buildContainerChildren.

public List<AbstractObjectReader> buildContainerChildren(VectorContainer container, MetadataProvider mdProvider) {
    final List<AbstractObjectReader> readers = new ArrayList<>();
    for (int i = 0; i < container.getNumberOfColumns(); i++) {
        final ValueVector vector = container.getValueVector(i).getValueVector();
        final VectorDescrip descrip = new VectorDescrip(mdProvider, i, vector.getField());
        readers.add(buildVectorReader(vector, descrip));
    }
    return readers;
}
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) ArrayList(java.util.ArrayList) VectorDescrip(org.apache.drill.exec.physical.resultSet.model.MetadataProvider.VectorDescrip)

Example 14 with AbstractObjectReader

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

Example 15 with AbstractObjectReader

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

the class HyperReaderBuilder method buildMapMembers.

protected List<AbstractObjectReader> buildMapMembers(VectorAccessor va, TupleMetadata mapSchema) {
    List<AbstractObjectReader> readers = new ArrayList<>();
    for (int i = 0; i < mapSchema.size(); i++) {
        ColumnMetadata member = mapSchema.metadata(i);
        // Does not use the hyper-vector mechanism.
        readers.add(buildVectorReader(new VectorAccessors.MapMemberHyperVectorAccessor(va, i, member.majorType()), member));
    }
    return readers;
}
Also used : AbstractObjectReader(org.apache.drill.exec.vector.accessor.reader.AbstractObjectReader) ColumnMetadata(org.apache.drill.exec.record.metadata.ColumnMetadata) ArrayList(java.util.ArrayList)

Aggregations

AbstractObjectReader (org.apache.drill.exec.vector.accessor.reader.AbstractObjectReader)16 ArrayList (java.util.ArrayList)8 ValueVector (org.apache.drill.exec.vector.ValueVector)8 RepeatedValueVector (org.apache.drill.exec.vector.complex.RepeatedValueVector)6 VectorDescrip (org.apache.drill.exec.physical.resultSet.model.MetadataProvider.VectorDescrip)4 VectorDescrip (org.apache.drill.exec.physical.rowSet.model.MetadataProvider.VectorDescrip)4 VectorAccessor (org.apache.drill.exec.vector.accessor.reader.VectorAccessor)3 MetadataProvider (org.apache.drill.exec.physical.rowSet.model.MetadataProvider)2 ColumnMetadata (org.apache.drill.exec.record.metadata.ColumnMetadata)2 BaseHyperVectorAccessor (org.apache.drill.exec.vector.accessor.reader.VectorAccessors.BaseHyperVectorAccessor)2 MinorType (org.apache.drill.common.types.TypeProtos.MinorType)1 MetadataProvider (org.apache.drill.exec.physical.resultSet.model.MetadataProvider)1 MetadataCreator (org.apache.drill.exec.physical.resultSet.model.MetadataProvider.MetadataCreator)1 RowSetReaderImpl (org.apache.drill.exec.physical.rowSet.RowSetReaderImpl)1 HyperVectorWrapper (org.apache.drill.exec.record.HyperVectorWrapper)1 MaterializedField (org.apache.drill.exec.record.MaterializedField)1 VariantMetadata (org.apache.drill.exec.record.metadata.VariantMetadata)1 VectorAccessors (org.apache.drill.exec.vector.accessor.reader.VectorAccessors)1 SingleVectorAccessor (org.apache.drill.exec.vector.accessor.reader.VectorAccessors.SingleVectorAccessor)1 DictVector (org.apache.drill.exec.vector.complex.DictVector)1