public Void visitLocalRef(RexLocalRef localRef) { final int index = localRef.getIndex(); refCounts[index]++; return null; } }
public RexNode visitLocalRef(RexLocalRef localRef) { final int index = localRef.getIndex(); if (index < inputFieldCount) { // Reference to input field. return localRef; } return new RexLocalRef( flattenedAggCallList.size() + index, localRef.getType()); } };
if (conditionRef != null) { final Ord<RelDataType> newField = getNewFieldForOldInput(conditionRef.getIndex()); programBuilder.addCondition(new RexLocalRef(newField.i, newField.e));
new Checker(inputRowType, RexUtil.types(exprs), null, litmus); if (condition != null) { if (!SqlTypeUtil.inBooleanFamily(condition.getType())) { return litmus.fail("condition must be boolean"); condition.accept(checker); if (checker.failCount > 0) { return litmus.fail(null); project.accept(checker); if (checker.failCount > 0) { return litmus.fail(null);
/** * Adds an expression to the list of common expressions, and returns a * reference to the expression. <b>DOES NOT CHECK WHETHER THE EXPRESSION * ALREADY EXISTS</b>. * * @param expr Expression * @return Reference to expression */ public RexLocalRef addExpr(RexNode expr) { RexLocalRef ref; final int index = exprList.size(); exprList.add(expr); ref = new RexLocalRef( index, expr.getType()); localRefList.add(ref); return ref; }
public RexNode visitInputRef(RexInputRef input) { // This expression refers to the Nth project column. Lookup that // column and find out what common sub-expression IT refers to. final int index = input.getIndex(); final RexLocalRef local = projectRefList.get(index); assert RelOptUtil.eq( "type1", local.getType(), "type2", input.getType(), Litmus.THROW); return local; }
/** * Fully expands a RexLocalRef back into a pure RexNode tree containing no * RexLocalRefs (reversing the effect of common subexpression elimination). * For example, <code>program.expandLocalRef(program.getCondition())</code> * will return the expansion of a program's condition. * * @param ref a RexLocalRef from this program * @return expanded form */ public RexNode expandLocalRef(RexLocalRef ref) { return ref.accept(new ExpansionShuttle(exprs)); }
/** * Creates a local variable. * * @param index Index of the field in the underlying row type * @param type Type of the column */ public RexLocalRef(int index, RelDataType type) { super(createName(index), index, type); assert type != null; assert index >= 0; }
/** * Sets the condition of the program. * * <p>The expression must be specified in terms of the input fields. If * not, call {@link #registerOutput(RexNode)} first.</p> */ public void addCondition(RexNode expr) { assert expr != null; if (conditionRef == null) { conditionRef = registerInput(expr); } else { // AND the new condition with the existing condition. // If the new condition is identical to the existing condition, skip it. RexLocalRef ref = registerInput(expr); if (!ref.equals(conditionRef)) { conditionRef = registerInput( rexBuilder.makeCall( SqlStdOperatorTable.AND, conditionRef, ref)); } } }
if (conditionRef != null) { final Ord<RelDataType> newField = getNewFieldForOldInput(conditionRef.getIndex()); programBuilder.addCondition(new RexLocalRef(newField.i, newField.e));
new Checker(inputRowType, RexUtil.types(exprs), null, litmus); if (condition != null) { if (!SqlTypeUtil.inBooleanFamily(condition.getType())) { return litmus.fail("condition must be boolean"); condition.accept(checker); if (checker.failCount > 0) { return litmus.fail(null); project.accept(checker); if (checker.failCount > 0) { return litmus.fail(null);
/** * Adds an expression to the list of common expressions, and returns a * reference to the expression. <b>DOES NOT CHECK WHETHER THE EXPRESSION * ALREADY EXISTS</b>. * * @param expr Expression * @return Reference to expression */ public RexLocalRef addExpr(RexNode expr) { RexLocalRef ref; final int index = exprList.size(); exprList.add(expr); ref = new RexLocalRef( index, expr.getType()); localRefList.add(ref); return ref; }
public RexNode visitInputRef(RexInputRef input) { // This expression refers to the Nth project column. Lookup that // column and find out what common sub-expression IT refers to. final int index = input.getIndex(); final RexLocalRef local = projectRefList.get(index); assert RelOptUtil.eq( "type1", local.getType(), "type2", input.getType(), Litmus.THROW); return local; }
/** * Fully expands a RexLocalRef back into a pure RexNode tree containing no * RexLocalRefs (reversing the effect of common subexpression elimination). * For example, <code>program.expandLocalRef(program.getCondition())</code> * will return the expansion of a program's condition. * * @param ref a RexLocalRef from this program * @return expanded form */ public RexNode expandLocalRef(RexLocalRef ref) { return ref.accept(new ExpansionShuttle(exprs)); }
/** * Creates a local variable. * * @param index Index of the field in the underlying row type * @param type Type of the column */ public RexLocalRef(int index, RelDataType type) { super(createName(index), index, type); assert type != null; assert index >= 0; }
/** * Sets the condition of the program. * * <p>The expression must be specified in terms of the input fields. If * not, call {@link #registerOutput(RexNode)} first.</p> */ public void addCondition(RexNode expr) { assert expr != null; if (conditionRef == null) { conditionRef = registerInput(expr); } else { // AND the new condition with the existing condition. // If the new condition is identical to the existing condition, skip it. RexLocalRef ref = registerInput(expr); if (!ref.equals(conditionRef)) { conditionRef = registerInput( rexBuilder.makeCall( SqlStdOperatorTable.AND, conditionRef, ref)); } } }
public Void visitLocalRef(RexLocalRef localRef) { final int index = localRef.getIndex(); refCounts[index]++; return null; } }
public RexNode visitLocalRef(RexLocalRef localRef) { final int index = localRef.getIndex(); if (index < inputFieldCount) { // Reference to input field. return localRef; } return new RexLocalRef( flattenedAggCallList.size() + index, localRef.getType()); } };