public Statement visit(ConditionalStatement conditionalStatement, List<Node> list) { return list.equals(conditionalStatement.expressionList) ? conditionalStatement : Expressions.ifThenElse(list); }
/** * Creates a ConditionalExpression that represents a conditional * block with if and else statements: * <code>if (test) stmt1 [ else if (test2) stmt2 ]... [ else stmtN ]</code>. */ public static ConditionalStatement ifThenElse(Expression test, Node... nodes) { return ifThenElse(new FluentArrayList<Node>().append(test) .appendAll(nodes)); }
Expressions.ifThenElse(seenNotNullRows, thenBranch, Expressions.statement(
Expressions.ifThenElse(rowInRange, thenBranch, Expressions.statement(Expressions.assign(res, defaultValue)))); return res;
Expressions.ifThenElse(rowInRange, thenBranch, Expressions.statement(Expressions.assign(res, defaultValue)))); return res;
Expressions.ifThenElse(seenNotNullRows, thenBranch, Expressions.statement(
public Expression implementResult(AggContext info, AggResultContext result) { WinAggResultContext winResult = (WinAggResultContext) result; List<RexNode> rexArgs = winResult.rexArguments(); ParameterExpression res = Expressions.parameter(0, info.returnType(), result.currentBlock().newName("nth")); RexToLixTranslator currentRowTranslator = winResult.rowTranslator( winResult.computeIndex(Expressions.constant(0), SeekType.START)); Expression dstIndex = winResult.computeIndex( Expressions.subtract( currentRowTranslator.translate(rexArgs.get(1), int.class), Expressions.constant(1)), SeekType.START); Expression rowInRange = winResult.rowInPartition(dstIndex); BlockBuilder thenBlock = result.nestBlock(); Expression nthValue = winResult.rowTranslator(dstIndex) .translate(rexArgs.get(0), res.type); thenBlock.add(Expressions.statement(Expressions.assign(res, nthValue))); result.exitBlock(); BlockStatement thenBranch = thenBlock.toBlock(); Expression defaultValue = getDefaultValue(res.type); result.currentBlock().add(Expressions.declare(0, res, null)); result.currentBlock().add( Expressions.ifThenElse(rowInRange, thenBranch, Expressions.statement(Expressions.assign(res, defaultValue)))); return res; } }
public Expression implementResult(AggContext info, AggResultContext result) { WinAggResultContext winResult = (WinAggResultContext) result; List<RexNode> rexArgs = winResult.rexArguments(); ParameterExpression res = Expressions.parameter(0, info.returnType(), result.currentBlock().newName("nth")); RexToLixTranslator currentRowTranslator = winResult.rowTranslator( winResult.computeIndex(Expressions.constant(0), SeekType.START)); Expression dstIndex = winResult.computeIndex( Expressions.subtract( currentRowTranslator.translate(rexArgs.get(1), int.class), Expressions.constant(1)), SeekType.START); Expression rowInRange = winResult.rowInPartition(dstIndex); BlockBuilder thenBlock = result.nestBlock(); Expression nthValue = winResult.rowTranslator(dstIndex) .translate(rexArgs.get(0), res.type); thenBlock.add(Expressions.statement(Expressions.assign(res, nthValue))); result.exitBlock(); BlockStatement thenBranch = thenBlock.toBlock(); Expression defaultValue = getDefaultValue(res.type); result.currentBlock().add(Expressions.declare(0, res, null)); result.currentBlock().add( Expressions.ifThenElse(rowInRange, thenBranch, Expressions.statement(Expressions.assign(res, defaultValue)))); return res; } }
Expressions.lessThanOrEqual(startTmp, endTmp)); builder4.add( Expressions.ifThenElse(hasRows, Expressions.block( Expressions.statement( Expressions.declare(0, actualStart, null)); builder5.add( Expressions.ifThenElse(needRecomputeWindow, resetWindowState, Expressions.statement(
Expressions.lessThanOrEqual(startTmp, endTmp)); builder4.add( Expressions.ifThenElse(hasRows, Expressions.block( Expressions.statement( Expressions.declare(0, actualStart, null)); builder5.add( Expressions.ifThenElse(needRecomputeWindow, resetWindowState, Expressions.statement(