Search in sources :

Example 1 with VectorDescrip

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

the class BaseWriterBuilder method buildContainerChildren.

protected List<AbstractObjectWriter> buildContainerChildren(VectorContainer container, MetadataProvider mdProvider) {
    final List<AbstractObjectWriter> writers = 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());
        writers.add(buildVectorWriter(vector, descrip));
    }
    return writers;
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) ArrayList(java.util.ArrayList) VectorDescrip(org.apache.drill.exec.physical.resultSet.model.MetadataProvider.VectorDescrip) AbstractObjectWriter(org.apache.drill.exec.vector.accessor.writer.AbstractObjectWriter)

Example 2 with VectorDescrip

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

the class BaseWriterBuilder method buildMap.

private List<AbstractObjectWriter> buildMap(AbstractMapVector vector, VectorDescrip descrip) {
    final List<AbstractObjectWriter> writers = new ArrayList<>();
    final MetadataProvider provider = descrip.parent.childProvider(descrip.metadata);
    int i = 0;
    for (final ValueVector child : vector) {
        final VectorDescrip childDescrip = new VectorDescrip(provider, i, child.getField());
        writers.add(buildVectorWriter(child, childDescrip));
        i++;
    }
    return writers;
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) MetadataProvider(org.apache.drill.exec.physical.resultSet.model.MetadataProvider) ArrayList(java.util.ArrayList) VectorDescrip(org.apache.drill.exec.physical.resultSet.model.MetadataProvider.VectorDescrip) AbstractObjectWriter(org.apache.drill.exec.vector.accessor.writer.AbstractObjectWriter)

Example 3 with VectorDescrip

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

the class BaseWriterBuilder method build1DList.

private AbstractObjectWriter build1DList(ListVector vector, VectorDescrip descrip) {
    final ValueVector dataVector = vector.getDataVector();
    VectorDescrip dataMetadata;
    if (dataVector.getField().getType().getMinorType() == MinorType.UNION) {
        // If the list holds a union, then the list and union are collapsed
        // together in the metadata layer.
        dataMetadata = descrip;
    } else {
        dataMetadata = new VectorDescrip(descrip.childProvider(), 0, dataVector.getField());
    }
    return new ArrayObjectWriter(new ListWriterImpl(descrip.metadata, vector, buildVectorWriter(dataVector, dataMetadata)));
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) ListWriterImpl(org.apache.drill.exec.vector.accessor.writer.ListWriterImpl) ArrayObjectWriter(org.apache.drill.exec.vector.accessor.writer.AbstractArrayWriter.ArrayObjectWriter) VectorDescrip(org.apache.drill.exec.physical.resultSet.model.MetadataProvider.VectorDescrip)

Example 4 with VectorDescrip

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

the class BaseWriterBuilder method buildUnion.

private AbstractObjectWriter buildUnion(UnionVector vector, VectorDescrip descrip) {
    if (vector == null) {
        throw new UnsupportedOperationException("Dummy variant writer not yet supported");
    }
    final AbstractObjectWriter[] variants = new AbstractObjectWriter[MinorType.values().length];
    final MetadataProvider mdProvider = descrip.childProvider();
    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(mdProvider, i++, memberVector.getField());
        variants[type.ordinal()] = buildVectorWriter(memberVector, memberDescrip);
    }
    return new VariantObjectWriter(new UnionWriterImpl(descrip.metadata, vector, variants));
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) VariantObjectWriter(org.apache.drill.exec.vector.accessor.writer.UnionWriterImpl.VariantObjectWriter) 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) AbstractObjectWriter(org.apache.drill.exec.vector.accessor.writer.AbstractObjectWriter) UnionWriterImpl(org.apache.drill.exec.vector.accessor.writer.UnionWriterImpl)

Example 5 with VectorDescrip

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

the class SimpleReaderBuilder method buildMultiDList.

private AbstractObjectReader buildMultiDList(RepeatedListVector vector, VectorAccessor listAccessor, VectorDescrip listDescrip) {
    final ValueVector child = vector.getDataVector();
    if (child == null) {
        throw new UnsupportedOperationException("No child vector for repeated list.");
    }
    final VectorDescrip childDescrip = new VectorDescrip(listDescrip.childProvider(), 0, child.getField());
    final AbstractObjectReader elementReader = buildVectorReader(child, childDescrip);
    return ArrayReaderImpl.buildRepeatedList(listDescrip.metadata, listAccessor, elementReader);
}
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) 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