Search in sources :

Example 61 with TypedFieldId

use of org.apache.drill.exec.record.TypedFieldId in project drill by apache.

the class OutputWidthVisitor method visitVarLenReadExpr.

/**
 * Converts the {@link VarLenReadExpr} to a {@link FixedLenExpr} by getting
 * the size for the corresponding column from the RecordBatchSizer.
 */
@Override
public OutputWidthExpression visitVarLenReadExpr(VarLenReadExpr varLenReadExpr, OutputWidthVisitorState state) throws RuntimeException {
    String columnName = varLenReadExpr.getInputColumnName();
    if (columnName == null) {
        TypedFieldId fieldId = varLenReadExpr.getReadExpression().getTypedFieldId();
        columnName = TypedFieldId.getPath(fieldId, state.manager.incomingBatch());
    }
    final RecordBatchSizer.ColumnSize columnSize = state.manager.getColumnSize(columnName);
    int columnWidth = columnSize.getDataSizePerEntry();
    return new FixedLenExpr(columnWidth);
}
Also used : RecordBatchSizer(org.apache.drill.exec.record.RecordBatchSizer) FixedLenExpr(org.apache.drill.exec.physical.impl.project.OutputWidthExpression.FixedLenExpr) TypedFieldId(org.apache.drill.exec.record.TypedFieldId)

Example 62 with TypedFieldId

use of org.apache.drill.exec.record.TypedFieldId in project drill by apache.

the class ProjectBatchBuilder method addOutputVector.

@Override
public ValueVectorWriteExpression addOutputVector(String name, LogicalExpression expr) {
    MaterializedField outputField = MaterializedField.create(name, expr.getMajorType());
    ValueVector vv = container.addOrGet(outputField, callBack);
    projectBatch.allocationVectors.add(vv);
    TypedFieldId fid = container.getValueVectorId(SchemaPath.getSimplePath(outputField.getName()));
    ValueVectorWriteExpression write = new ValueVectorWriteExpression(fid, expr, true);
    projectBatch.memoryManager.addNewField(vv, write);
    return write;
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) TypedFieldId(org.apache.drill.exec.record.TypedFieldId) ValueVectorWriteExpression(org.apache.drill.exec.expr.ValueVectorWriteExpression) MaterializedField(org.apache.drill.exec.record.MaterializedField)

Example 63 with TypedFieldId

use of org.apache.drill.exec.record.TypedFieldId in project drill by apache.

the class ProjectBatchBuilder method addEvalVector.

@Override
public ValueVectorWriteExpression addEvalVector(String outputName, LogicalExpression expr) {
    MaterializedField outputField = MaterializedField.create(outputName, expr.getMajorType());
    ValueVector ouputVector = container.addOrGet(outputField, callBack);
    projectBatch.allocationVectors.add(ouputVector);
    TypedFieldId fid = container.getValueVectorId(SchemaPath.getSimplePath(outputField.getName()));
    boolean useSetSafe = !(ouputVector instanceof FixedWidthVector);
    ValueVectorWriteExpression write = new ValueVectorWriteExpression(fid, expr, useSetSafe);
    projectBatch.memoryManager.addNewField(ouputVector, write);
    // need to instantiate the output vector.
    if (expr instanceof ValueVectorReadExpression) {
        ValueVectorReadExpression vectorRead = (ValueVectorReadExpression) expr;
        if (!vectorRead.hasReadPath()) {
            TypedFieldId id = vectorRead.getFieldId();
            ValueVector vvIn = incomingBatch.getValueAccessorById(id.getIntermediateClass(), id.getFieldIds()).getValueVector();
            vvIn.makeTransferPair(ouputVector);
        }
    }
    return write;
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) ValueVectorReadExpression(org.apache.drill.exec.expr.ValueVectorReadExpression) FixedWidthVector(org.apache.drill.exec.vector.FixedWidthVector) TypedFieldId(org.apache.drill.exec.record.TypedFieldId) ValueVectorWriteExpression(org.apache.drill.exec.expr.ValueVectorWriteExpression) MaterializedField(org.apache.drill.exec.record.MaterializedField)

Aggregations

TypedFieldId (org.apache.drill.exec.record.TypedFieldId)63 LogicalExpression (org.apache.drill.common.expression.LogicalExpression)30 ErrorCollector (org.apache.drill.common.expression.ErrorCollector)22 ErrorCollectorImpl (org.apache.drill.common.expression.ErrorCollectorImpl)22 MaterializedField (org.apache.drill.exec.record.MaterializedField)22 ValueVector (org.apache.drill.exec.vector.ValueVector)22 SchemaChangeException (org.apache.drill.exec.exception.SchemaChangeException)21 SchemaPath (org.apache.drill.common.expression.SchemaPath)18 ValueVectorWriteExpression (org.apache.drill.exec.expr.ValueVectorWriteExpression)17 ValueVectorReadExpression (org.apache.drill.exec.expr.ValueVectorReadExpression)12 TransferPair (org.apache.drill.exec.record.TransferPair)12 Test (org.junit.Test)11 JVar (com.sun.codemodel.JVar)10 NamedExpression (org.apache.drill.common.logical.data.NamedExpression)9 VectorWrapper (org.apache.drill.exec.record.VectorWrapper)9 FieldReference (org.apache.drill.common.expression.FieldReference)7 TypeProtos (org.apache.drill.common.types.TypeProtos)7 MajorType (org.apache.drill.common.types.TypeProtos.MajorType)7 JExpression (com.sun.codemodel.JExpression)6 IOException (java.io.IOException)6