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);
}
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));
}
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;
}
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);
}
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;
}
Aggregations