Search in sources :

Example 1 with HoldingContainerExpression

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);
    }
}
Also used : HoldingContainer(org.apache.drill.exec.expr.ClassGenerator.HoldingContainer) ValueVectorWriteExpression(org.apache.drill.exec.expr.ValueVectorWriteExpression) HoldingContainerExpression(org.apache.drill.exec.expr.HoldingContainerExpression)

Example 2 with HoldingContainerExpression

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);
}
Also used : LogicalExpression(org.apache.drill.common.expression.LogicalExpression) HoldingContainer(org.apache.drill.exec.expr.ClassGenerator.HoldingContainer) MajorType(org.apache.drill.common.types.TypeProtos.MajorType) ArrayList(java.util.ArrayList) FunctionCall(org.apache.drill.common.expression.FunctionCall) HoldingContainerExpression(org.apache.drill.exec.expr.HoldingContainerExpression)

Example 3 with HoldingContainerExpression

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;
}
Also used : LogicalExpression(org.apache.drill.common.expression.LogicalExpression) IfExpression(org.apache.drill.common.expression.IfExpression) HoldingContainer(org.apache.drill.exec.expr.ClassGenerator.HoldingContainer) MajorType(org.apache.drill.common.types.TypeProtos.MajorType) IntExpression(org.apache.drill.common.expression.ValueExpressions.IntExpression) FunctionCall(org.apache.drill.common.expression.FunctionCall) IfCondition(org.apache.drill.common.expression.IfExpression.IfCondition) HoldingContainerExpression(org.apache.drill.exec.expr.HoldingContainerExpression) IfCondition(org.apache.drill.common.expression.IfExpression.IfCondition)

Aggregations

HoldingContainer (org.apache.drill.exec.expr.ClassGenerator.HoldingContainer)3 HoldingContainerExpression (org.apache.drill.exec.expr.HoldingContainerExpression)3 FunctionCall (org.apache.drill.common.expression.FunctionCall)2 LogicalExpression (org.apache.drill.common.expression.LogicalExpression)2 MajorType (org.apache.drill.common.types.TypeProtos.MajorType)2 ArrayList (java.util.ArrayList)1 IfExpression (org.apache.drill.common.expression.IfExpression)1 IfCondition (org.apache.drill.common.expression.IfExpression.IfCondition)1 IntExpression (org.apache.drill.common.expression.ValueExpressions.IntExpression)1 ValueVectorWriteExpression (org.apache.drill.exec.expr.ValueVectorWriteExpression)1