use of org.apache.drill.exec.expr.HoldingContainerExpression in project drill by apache.
the class StreamingAggBatch method outputRecordKeysPrev.
private void outputRecordKeysPrev(ClassGenerator<StreamingAggregator> cg, TypedFieldId[] keyOutputIds, LogicalExpression[] keyExprs) {
cg.setMappingSet(RECORD_KEYS_PREV);
for (int i = 0; i < keyExprs.length; i++) {
// IMPORTANT: there is an implicit assertion here that the TypedFieldIds for the previous batch and the current batch are the same. This is possible because InternalBatch guarantees this.
logger.debug("Writing out expr {}", keyExprs[i]);
cg.rotateBlock();
cg.setMappingSet(RECORD_KEYS_PREV);
final HoldingContainer innerExpression = cg.addExpr(keyExprs[i], ClassGenerator.BlkCreateMode.FALSE);
cg.setMappingSet(RECORD_KEYS_PREV_OUT);
cg.addExpr(new ValueVectorWriteExpression(keyOutputIds[i], new HoldingContainerExpression(innerExpression), true), ClassGenerator.BlkCreateMode.FALSE);
}
}
use of org.apache.drill.exec.expr.HoldingContainerExpression in project drill by apache.
the class FunctionGenerationHelper method getFunctionExpression.
private static LogicalExpression getFunctionExpression(String name, MajorType returnType, FunctionImplementationRegistry registry, HoldingContainer... args) {
List<MajorType> argTypes = new ArrayList<MajorType>(args.length);
List<LogicalExpression> argExpressions = new ArrayList<LogicalExpression>(args.length);
for (HoldingContainer c : args) {
argTypes.add(c.getMajorType());
argExpressions.add(new HoldingContainerExpression(c));
}
return new FunctionCall(name, argExpressions, ExpressionPosition.UNKNOWN);
}
use of org.apache.drill.exec.expr.HoldingContainerExpression in project drill by apache.
the class FunctionGenerationHelper method getTypeComparisonFunction.
/**
* Wraps the comparison function in an If-statement which compares the types first, evaluating the comaprison function only
* if the types are equivialent
*
* @param comparisonFunction
* @param args
* @return
*/
private static LogicalExpression getTypeComparisonFunction(LogicalExpression comparisonFunction, HoldingContainer... args) {
List<LogicalExpression> argExpressions = Lists.newArrayList();
List<MajorType> argTypes = Lists.newArrayList();
for (HoldingContainer c : args) {
argTypes.add(c.getMajorType());
argExpressions.add(new HoldingContainerExpression(c));
}
FunctionCall call = new FunctionCall("compareType", argExpressions, ExpressionPosition.UNKNOWN);
List<LogicalExpression> newArgs = Lists.newArrayList();
newArgs.add(call);
newArgs.add(new IntExpression(0, ExpressionPosition.UNKNOWN));
FunctionCall notEqual = new FunctionCall("not_equal", newArgs, ExpressionPosition.UNKNOWN);
IfExpression.IfCondition ifCondition = new IfCondition(notEqual, call);
IfExpression ifExpression = IfExpression.newBuilder().setIfCondition(ifCondition).setElse(comparisonFunction).build();
return ifExpression;
}
Aggregations