Search in sources :

Example 1 with MetadataProvider

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

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

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

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

the class VectorAllocator method allocateMap.

private void allocateMap(AbstractMapVector vector, ColumnMetadata metadata, int valueCount, MetadataProvider mdProvider) {
    final MetadataProvider mapProvider = mdProvider.childProvider(metadata);
    final TupleMetadata mapSchema = metadata.tupleSchema();
    assert mapSchema != null;
    int i = 0;
    for (final ValueVector child : vector) {
        allocateVector(child, mapProvider.metadata(i, child.getField()), valueCount, mapProvider);
        i++;
    }
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) MetadataProvider(org.apache.drill.exec.physical.resultSet.model.MetadataProvider) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata)

Aggregations

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