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