use of org.apache.drill.exec.record.TypedFieldId in project drill by apache.
the class ProjectBatchBuilder method addDirectTransfer.
@Override
public int addDirectTransfer(FieldReference ref, ValueVectorReadExpression vectorRead) {
TypedFieldId id = vectorRead.getFieldId();
ValueVector vvIn = incomingBatch.getValueAccessorById(id.getIntermediateClass(), id.getFieldIds()).getValueVector();
Preconditions.checkNotNull(incomingBatch);
ValueVector vvOut = container.addOrGet(MaterializedField.create(ref.getLastSegment().getNameSegment().getPath(), vectorRead.getMajorType()), callBack);
TransferPair tp = vvIn.makeTransferPair(vvOut);
projectBatch.memoryManager.addTransferField(vvIn, TypedFieldId.getPath(id, incomingBatch), vvOut.getField().getName());
transfers.add(tp);
return vectorRead.getFieldId().getFieldIds()[0];
}
use of org.apache.drill.exec.record.TypedFieldId in project drill by apache.
the class ExpressionTest method testSpecial.
@Test
public void testSpecial() throws Exception {
final RecordBatch batch = mock(RecordBatch.class);
final VectorWrapper wrapper = mock(VectorWrapper.class);
final TypeProtos.MajorType type = Types.optional(MinorType.INT);
final TypedFieldId tfid = new TypedFieldId.Builder().finalType(type).hyper(false).addId(0).build();
when(wrapper.getValueVector()).thenReturn(new IntVector(MaterializedField.create("result", type), RootAllocatorFactory.newRoot(c)));
when(batch.getValueVectorId(new SchemaPath("alpha", ExpressionPosition.UNKNOWN))).thenReturn(tfid);
when(batch.getValueAccessorById(IntVector.class, tfid.getFieldIds())).thenReturn(wrapper);
getExpressionCode("1 + 1", batch);
}
use of org.apache.drill.exec.record.TypedFieldId in project drill by apache.
the class ExpressionTest method getExpressionCode.
private String getExpressionCode(String expression, RecordBatch batch) throws Exception {
final LogicalExpression expr = parseExpr(expression);
final ErrorCollector error = new ErrorCollectorImpl();
final LogicalExpression materializedExpr = ExpressionTreeMaterializer.materialize(expr, batch, error, registry);
if (error.getErrorCount() != 0) {
logger.error("Failure while materializing expression [{}]. Errors: {}", expression, error);
assertEquals(0, error.getErrorCount());
}
FunctionImplementationRegistry funcReg = new FunctionImplementationRegistry(DrillConfig.create());
final ClassGenerator<Projector> cg = CodeGenerator.get(Projector.TEMPLATE_DEFINITION, null).getRoot();
TypedFieldId fieldId = new TypedFieldId.Builder().finalType(materializedExpr.getMajorType()).addId(-1).build();
cg.addExpr(new ValueVectorWriteExpression(fieldId, materializedExpr));
return cg.getCodeGenerator().generateAndGet();
}
use of org.apache.drill.exec.record.TypedFieldId in project drill by apache.
the class StatisticsAggBatch method createNestedKeyColumn.
/*
* Creates the key column within the parent value vector
*/
private void createNestedKeyColumn(MapVector parent, String name, LogicalExpression expr, List<LogicalExpression> keyExprs, List<TypedFieldId> keyOutputIds) {
LogicalExpression mle = PhysicalOperatorUtil.materializeExpression(expr, incoming, context);
TypedFieldId id = createVVFieldId(mle, name, parent);
keyExprs.add(mle);
keyOutputIds.add(id);
}
use of org.apache.drill.exec.record.TypedFieldId in project drill by apache.
the class StatisticsAggBatch method addMapVector.
/*
* Creates the value vector within the parent value vector. The map vector key is
* is the column name and value is the statistic expression e.g. "salary" : NDV(emp.salary)
*/
private void addMapVector(String name, MapVector parent, LogicalExpression expr, List<LogicalExpression> valueExprs) {
LogicalExpression mle = PhysicalOperatorUtil.materializeExpression(expr, incoming, context);
TypedFieldId id = createVVFieldId(mle, name, parent);
valueExprs.add(new ValueVectorWriteExpression(id, mle, true));
}
Aggregations