Search in sources :

Example 31 with ValueVector

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);
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector)

Example 32 with ValueVector

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();
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) BaseValueVector(org.apache.drill.exec.vector.BaseValueVector)

Example 33 with ValueVector

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;
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector)

Example 34 with ValueVector

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;
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) SQLException(java.sql.SQLException)

Example 35 with ValueVector

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);
}
Also used : RepeatedValueVector(org.apache.drill.exec.vector.complex.RepeatedValueVector) ValueVector(org.apache.drill.exec.vector.ValueVector) RepeatedValueVector(org.apache.drill.exec.vector.complex.RepeatedValueVector) RepeatedMapVector(org.apache.drill.exec.vector.complex.RepeatedMapVector) TypedFieldId(org.apache.drill.exec.record.TypedFieldId) MaterializedField(org.apache.drill.exec.record.MaterializedField)

Aggregations

ValueVector (org.apache.drill.exec.vector.ValueVector)130 MaterializedField (org.apache.drill.exec.record.MaterializedField)29 Test (org.junit.Test)21 SchemaChangeException (org.apache.drill.exec.exception.SchemaChangeException)18 RecordBatchLoader (org.apache.drill.exec.record.RecordBatchLoader)13 VectorWrapper (org.apache.drill.exec.record.VectorWrapper)13 QueryDataBatch (org.apache.drill.exec.rpc.user.QueryDataBatch)12 ExecTest (org.apache.drill.exec.ExecTest)11 IOException (java.io.IOException)10 LogicalExpression (org.apache.drill.common.expression.LogicalExpression)10 VectorContainer (org.apache.drill.exec.record.VectorContainer)10 Drillbit (org.apache.drill.exec.server.Drillbit)10 ErrorCollector (org.apache.drill.common.expression.ErrorCollector)9 ErrorCollectorImpl (org.apache.drill.common.expression.ErrorCollectorImpl)9 RemoteServiceSet (org.apache.drill.exec.server.RemoteServiceSet)9 SchemaPath (org.apache.drill.common.expression.SchemaPath)8 MajorType (org.apache.drill.common.types.TypeProtos.MajorType)8 FunctionImplementationRegistry (org.apache.drill.exec.expr.fn.FunctionImplementationRegistry)8 FragmentContext (org.apache.drill.exec.ops.FragmentContext)8 PhysicalPlan (org.apache.drill.exec.physical.PhysicalPlan)8