public Void visitInputRef(RexInputRef inputRef) { super.visitInputRef(inputRef); if (inputRef.getIndex() >= inputRowType.getFieldCount()) { throw new IllegalForwardRefException(); } return null; }
/** * Determines if a filter condition is a simple one and returns the parameters corresponding to * the simple filters. * * @param calcRel original CalcRel * @param filterExprs filter expression being analyzed * @param filterList returns the list of filter ordinals in the simple expression * @param literals returns the list of literals to be used in the simple comparisons * @param op returns the operator to be used in the simple comparison * @return true if the filter condition is simple */ private boolean isConditionSimple( CalcRel calcRel, RexNode filterExprs, List<Integer> filterList, List<RexLiteral> literals, List<CompOperatorEnum> op) { SargFactory sargFactory = new SargFactory(calcRel.getCluster().getRexBuilder()); SargRexAnalyzer rexAnalyzer = sargFactory.newRexAnalyzer(true); List<SargBinding> sargBindingList = rexAnalyzer.analyzeAll(filterExprs); // Currently, it's all or nothing. So, if there are filters rejected // by the analyzer, we can't process a subset using the reshape // exec stream if (rexAnalyzer.getNonSargFilterRexNode() != null) { return false; } List<RexInputRef> filterCols = new ArrayList<RexInputRef>(); List<RexNode> filterOperands = new ArrayList<RexNode>(); if (FennelRelUtil.extractSimplePredicates(sargBindingList, filterCols, filterOperands, op)) { for (RexInputRef filterCol : filterCols) { filterList.add(filterCol.getIndex()); } for (RexNode operand : filterOperands) { literals.add((RexLiteral) operand); } return true; } else { return false; } }
/** * Returns whether the leading edge of a given array of expressions is wholly {@link RexInputRef} * objects with types corresponding to the underlying datatype. */ public static boolean containIdentity(RexNode[] exprs, RelDataType rowType, boolean fail) { final RelDataTypeField[] fields = rowType.getFields(); if (exprs.length < fields.length) { assert !fail : "exprs/rowType length mismatch"; return false; } for (int i = 0; i < fields.length; i++) { if (!(exprs[i] instanceof RexInputRef)) { assert !fail : "expr[" + i + "] is not a RexInputRef"; return false; } RexInputRef inputRef = (RexInputRef) exprs[i]; if (inputRef.getIndex() != i) { assert !fail : "expr[" + i + "] has ordinal " + inputRef.getIndex(); return false; } if (!RelOptUtil.eq("type1", exprs[i].getType(), "type2", fields[i].getType(), fail)) { return false; } } return true; }
public JavaRel findRel(JavaRel rel, RexNode expression) { if (expression instanceof RexInputRef) { RexInputRef variable = (RexInputRef) expression; // REVIEW jvs 30-May-2005: What's up with this? The "&& false" // should have at least a comment! if ((rel instanceof JoinRelBase) && false) { return (JavaRel) findInputRel(rel, variable.getIndex()); } else { return (JavaRel) rel.getInput(variable.getIndex()); } } else if (expression instanceof RexFieldAccess) { RexFieldAccess fieldAccess = (RexFieldAccess) expression; String fieldName = fieldAccess.getName(); RexNode refExp = fieldAccess.getReferenceExpr(); JavaRel rel2 = findRel(rel, refExp); // recursive if (rel2 == null) { return null; } return implementFieldAccess(rel2, fieldName); } else { return null; } }
public Void visitInputRef(RexInputRef inputRef) { refCounts[inputRef.getIndex()]++; return null; }
protected Integer mapFieldRef(RexNode exp, List<String> origFieldName, RelDataType rowType) { RexInputRef fieldAccess = (RexInputRef) exp; origFieldName.add(rowType.getFields()[fieldAccess.getIndex()].getName()); return fieldAccess.getIndex(); }