Search in sources :

Example 6 with VectorDescrip

use of org.apache.drill.exec.physical.resultSet.model.MetadataProvider.VectorDescrip in project drill by apache.

the class BaseWriterBuilder method buildMultiDList.

private AbstractObjectWriter buildMultiDList(RepeatedListVector vector, VectorDescrip descrip) {
    final ValueVector child = vector.getDataVector();
    if (child == null) {
        throw new UnsupportedOperationException("No child vector for repeated list.");
    }
    final VectorDescrip childDescrip = new VectorDescrip(descrip.childProvider(), 0, child.getField());
    final AbstractObjectWriter childWriter = buildVectorWriter(child, childDescrip);
    return RepeatedListWriter.buildRepeatedList(descrip.metadata, vector, childWriter);
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) VectorDescrip(org.apache.drill.exec.physical.resultSet.model.MetadataProvider.VectorDescrip) AbstractObjectWriter(org.apache.drill.exec.vector.accessor.writer.AbstractObjectWriter)

Example 7 with VectorDescrip

use of org.apache.drill.exec.physical.resultSet.model.MetadataProvider.VectorDescrip in project drill by apache.

the class SimpleReaderBuilder method build1DList.

/**
 * Build a list vector.
 * <p>
 * The list vector is a complex, somewhat ad-hoc structure. It can
 * take the place of repeated vectors, with some extra features.
 * The four "modes" of list vector, and thus list reader, are:
 * <ul>
 * <li>Similar to a scalar array.</li>
 * <li>Similar to a map (tuple) array.</li>
 * <li>The only way to represent an array of unions.</li>
 * <li>The only way to represent an array of lists.</li>
 * </ul>
 * Lists add an extra feature compared to the "regular" scalar or
 * map arrays. Each array entry can be either null or empty (regular
 * arrays can only be empty.)
 * <p>
 * When working with unions, this introduces an ambiguity: both the
 * list and the union have a null flag. Here, we assume that the
 * list flag has precedence, and that if the list entry is not null
 * then the union must also be not null. (Experience will show whether
 * existing code does, in fact, follow that convention.)
 */
private AbstractObjectReader build1DList(ListVector vector, VectorAccessor listAccessor, VectorDescrip listDescrip) {
    final ValueVector dataVector = vector.getDataVector();
    VectorDescrip dataMetadata;
    if (dataVector.getField().getType().getMinorType() == MinorType.UNION) {
        // At the metadata level, a list always holds a union. But, at the
        // implementation layer, a union of a single type is collapsed out
        // to leave just a list of that single type.
        dataMetadata = listDescrip;
    } else {
        dataMetadata = new VectorDescrip(listDescrip.childProvider(), 0, dataVector.getField());
    }
    return ArrayReaderImpl.buildList(listDescrip.metadata, listAccessor, buildVectorReader(dataVector, dataMetadata));
}
Also used : RepeatedValueVector(org.apache.drill.exec.vector.complex.RepeatedValueVector) ValueVector(org.apache.drill.exec.vector.ValueVector) VectorDescrip(org.apache.drill.exec.physical.resultSet.model.MetadataProvider.VectorDescrip)

Example 8 with VectorDescrip

use of org.apache.drill.exec.physical.resultSet.model.MetadataProvider.VectorDescrip 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 9 with VectorDescrip

use of org.apache.drill.exec.physical.resultSet.model.MetadataProvider.VectorDescrip 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 10 with VectorDescrip

use of org.apache.drill.exec.physical.resultSet.model.MetadataProvider.VectorDescrip 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)

Aggregations

VectorDescrip (org.apache.drill.exec.physical.resultSet.model.MetadataProvider.VectorDescrip)10 ValueVector (org.apache.drill.exec.vector.ValueVector)10 RepeatedValueVector (org.apache.drill.exec.vector.complex.RepeatedValueVector)5 ArrayList (java.util.ArrayList)4 AbstractObjectReader (org.apache.drill.exec.vector.accessor.reader.AbstractObjectReader)4 AbstractObjectWriter (org.apache.drill.exec.vector.accessor.writer.AbstractObjectWriter)4 MetadataProvider (org.apache.drill.exec.physical.resultSet.model.MetadataProvider)3 MinorType (org.apache.drill.common.types.TypeProtos.MinorType)2 ArrayObjectWriter (org.apache.drill.exec.vector.accessor.writer.AbstractArrayWriter.ArrayObjectWriter)1 ListWriterImpl (org.apache.drill.exec.vector.accessor.writer.ListWriterImpl)1 UnionWriterImpl (org.apache.drill.exec.vector.accessor.writer.UnionWriterImpl)1 VariantObjectWriter (org.apache.drill.exec.vector.accessor.writer.UnionWriterImpl.VariantObjectWriter)1