use of org.apache.drill.exec.vector.ValueVector in project drill by apache.
the class AbstractMapVector method getChildVectorWithOrdinal.
/**
* Returns a vector with its corresponding ordinal mapping if field exists or null.
*/
@Override
public VectorWithOrdinal getChildVectorWithOrdinal(String name) {
final int ordinal = vectors.getOrdinal(name.toLowerCase());
if (ordinal < 0) {
return null;
}
final ValueVector vector = vectors.getByOrdinal(ordinal);
return new VectorWithOrdinal(vector, ordinal);
}
use of org.apache.drill.exec.vector.ValueVector in project drill by apache.
the class MapVector method close.
@Override
public void close() {
final Collection<ValueVector> vectors = getChildren();
for (final ValueVector v : vectors) {
v.close();
}
vectors.clear();
valueCount = 0;
super.close();
}
use of org.apache.drill.exec.vector.ValueVector in project drill by apache.
the class RepeatedListReaderImpl method reader.
@Override
public FieldReader reader() {
if (reader == null) {
ValueVector child = container.getChild(name);
if (child == null) {
reader = NullReader.INSTANCE;
} else {
reader = child.getReader();
}
reader.setPosition(currentOffset);
}
return reader;
}
use of org.apache.drill.exec.vector.ValueVector in project drill by apache.
the class JdbcRecordReader method next.
@Override
public int next() {
int counter = 0;
Boolean b = true;
try {
while (counter < 4095 && b == true) {
// loop at 4095 since nullables use one more than record count and we
// allocate on powers of two.
b = resultSet.next();
if (b == false) {
break;
}
for (Copier<?> c : copiers) {
c.copy(counter);
}
counter++;
}
} catch (SQLException e) {
throw UserException.dataReadError(e).message("Failure while attempting to read from database.").addContext("sql", sql).addContext("plugin", storagePluginName).build(logger);
}
for (ValueVector vv : vectors) {
vv.getMutator().setValueCount(counter > 0 ? counter : 0);
}
return counter > 0 ? counter : 0;
}
use of org.apache.drill.exec.vector.ValueVector in project drill by apache.
the class FlattenRecordBatch method setFlattenVector.
@SuppressWarnings("resource")
private void setFlattenVector() {
final TypedFieldId typedFieldId = incoming.getValueVectorId(popConfig.getColumn());
final MaterializedField field = incoming.getSchema().getColumn(typedFieldId.getFieldIds()[0]);
final RepeatedValueVector vector;
final ValueVector inVV = incoming.getValueAccessorById(field.getValueClass(), typedFieldId.getFieldIds()).getValueVector();
if (!(inVV instanceof RepeatedValueVector)) {
if (incoming.getRecordCount() != 0) {
throw UserException.unsupportedError().message("Flatten does not support inputs of non-list values.").build(logger);
}
//when incoming recordCount is 0, don't throw exception since the type being seen here is not solid
logger.error("setFlattenVector cast failed and recordcount is 0, create empty vector anyway.");
vector = new RepeatedMapVector(field, oContext.getAllocator(), null);
} else {
vector = RepeatedValueVector.class.cast(inVV);
}
flattener.setFlattenField(vector);
}
Aggregations