nullCheck.append(wasNull.set(constantFalse())); clearComment = "clear wasNull";
public BytecodeNode generateExpression(Signature signature, BytecodeGeneratorContext context, Type returnType, List<RowExpression> arguments, Optional<Variable> outputBlockVariable) { Preconditions.checkArgument(arguments.size() == 3); Variable wasNull = context.wasNull(); BytecodeBlock condition = new BytecodeBlock() .append(context.generate(arguments.get(0), Optional.empty())) .comment("... and condition value was not null") .append(wasNull) .invokeStatic(CompilerOperations.class, "not", boolean.class, boolean.class) .invokeStatic(CompilerOperations.class, "and", boolean.class, boolean.class, boolean.class) .append(wasNull.set(constantFalse())); BytecodeBlock block = new BytecodeBlock() .append(new IfStatement() .condition(condition) .ifTrue(context.generate(arguments.get(1), Optional.empty())) .ifFalse(context.generate(arguments.get(2), Optional.empty()))); outputBlockVariable.ifPresent(output -> block.append(generateWrite(context, returnType, output))); return block; } }
@Override public BytecodeNode generateExpression(Signature signature, BytecodeGeneratorContext generatorContext, Type returnType, List<RowExpression> arguments, Optional<Variable> outputBlockVariable) { Preconditions.checkArgument(arguments.size() == 1); RowExpression argument = arguments.get(0); if (argument.getType().equals(UNKNOWN)) { return loadBoolean(true); } BytecodeNode value = generatorContext.generate(argument, Optional.empty()); // evaluate the expression, pop the produced value, and load the null flag Variable wasNull = generatorContext.wasNull(); BytecodeBlock block = new BytecodeBlock() .comment("is null") .append(value) .pop(argument.getType().getJavaType()) .append(wasNull); // clear the null flag block.append(wasNull.set(constantFalse())); outputBlockVariable.ifPresent(output -> block.append(generateWrite(generatorContext, returnType, output))); return block; } }
block.append(boxPrimitiveIfNecessary(scope, valueType)); block.putVariable(valueVariable); block.append(wasNull.set(constantFalse())); captureVariableBuilder.add(valueVariable);
private static BytecodeExpression anyParametersAreNull( List<ParameterMetadata> parameterMetadatas, Variable index, Variable channels, Variable position) { int inputChannel = 0; BytecodeExpression isNull = constantFalse(); for (ParameterMetadata parameterMetadata : parameterMetadatas) { switch (parameterMetadata.getParameterType()) { case BLOCK_INPUT_CHANNEL: case INPUT_CHANNEL: BytecodeExpression getChannel = channels.invoke("get", Object.class, constantInt(inputChannel)).cast(int.class); isNull = BytecodeExpressions.or(isNull, index.invoke("isNull", boolean.class, getChannel, position)); inputChannel++; break; case NULLABLE_BLOCK_INPUT_CHANNEL: inputChannel++; break; } } return isNull; }
Variable wasNullVariable = scope.declareVariable("wasNull", body, constantFalse()); scope.declareVariable("session", body, method.getThis().getField(sessionField)); .append(new IfStatement() .condition(wasNullVariable) .ifTrue(constantFalse().ret()) .ifFalse(result.ret()));
.append(wasNull.set(constantFalse())) .append(nullValue);
Variable wasNullVariable = scope.declareVariable("wasNull", body, constantFalse()); RowExpressionCompiler compiler = new RowExpressionCompiler( callSiteBinder,
scope.declareVariable("wasNull", body, constantFalse()); RowExpressionCompiler compiler = new RowExpressionCompiler( callSiteBinder,
.append(generatorContext.wasNull().set(constantFalse()));
return; scope.declareVariable("wasNull", body, constantFalse()); for (int index = 0; index < joinChannelTypes.size(); index++) { BytecodeExpression leftBlock = thisVariable body.append(new IfStatement() .condition(typeEquals(constantType(callSiteBinder, type), leftBlock, leftBlockPosition, rightBlock, rightPosition)) .ifFalse(constantFalse().ret())); continue; .ifTrue(constantFalse().ret()));
body.append(new IfStatement() .condition(typeEquals(type, leftBlock, leftBlockPosition, rightBlock, rightPosition)) .ifFalse(constantFalse().ret()));
Variable field = scope.createTempVariable(fieldType.getJavaType()); block.comment("Clean wasNull and Generate + " + i + "-th field of row"); block.append(context.wasNull().set(constantFalse())); block.append(context.generate(arguments.get(i), Optional.empty())); block.putVariable(field); block.append(constantType(binder, rowType).invoke("getObject", Object.class, blockBuilder.cast(Block.class), constantInt(0)) .cast(Block.class)); block.append(context.wasNull().set(constantFalse())); outputBlockVariable.ifPresent(output -> block.append(generateWrite(context, rowType, output))); return block;
ifLeftIsNull.ifTrue() .comment("clear the null flag, pop left value off stack, and push left null flag on the stack (true)") .append(wasNull.set(constantFalse())) .pop(arguments.get(0).getType().getJavaType()) // discard left value .push(true);
ifLeftIsNull.ifTrue(new BytecodeBlock() .comment("clear the null flag, pop left value off stack, and push left null flag on the stack (true)") .append(wasNull.set(constantFalse())) .pop(arguments.get(0).getType().getJavaType()) // discard left value .push(true));
.setDescription("match") .visitLabel(match) .append(generatorContext.wasNull().set(constantFalse())) .push(true) .gotoLabel(end);
scope.declareVariable("wasNull", body, constantFalse()); scope.declareVariable("session", body, method.getThis().getField(sessionField));
body.append(wasNull.set(constantFalse()));
wasNullCheck.ifTrue(new BytecodeBlock() .append(caseWasNull.set(constantTrue())) .append(wasNull.set(constantFalse())) .pop(boolean.class) .gotoLabel(elseLabel));
private static void generateIsPositionNull(ClassDefinition classDefinition, List<FieldDefinition> joinChannelFields) { Parameter blockIndex = arg("blockIndex", int.class); Parameter blockPosition = arg("blockPosition", int.class); MethodDefinition isPositionNullMethod = classDefinition.declareMethod( a(PUBLIC), "isPositionNull", type(boolean.class), blockIndex, blockPosition); for (FieldDefinition joinChannelField : joinChannelFields) { BytecodeExpression block = isPositionNullMethod .getThis() .getField(joinChannelField) .invoke("get", Object.class, blockIndex) .cast(Block.class); IfStatement ifStatement = new IfStatement(); ifStatement.condition(block.invoke( "isNull", boolean.class, blockPosition)); ifStatement.ifTrue(constantTrue().ret()); isPositionNullMethod.getBody().append(ifStatement); } isPositionNullMethod .getBody() .append(constantFalse().ret()); }