/** Finds a {@link RexInputRef} that is equivalent to a {@link CorRef}, * and if found, throws a {@link org.apache.calcite.util.Util.FoundOne}. */ private void findCorrelationEquivalent(CorRef correlation, RexNode e) throws Util.FoundOne { switch (e.getKind()) { case EQUALS: final RexCall call = (RexCall) e; final List<RexNode> operands = call.getOperands(); if (references(operands.get(0), correlation)) { throw new Util.FoundOne(operands.get(1)); } if (references(operands.get(1), correlation)) { throw new Util.FoundOne(operands.get(0)); } break; case AND: for (RexNode operand : ((RexCall) e).getOperands()) { findCorrelationEquivalent(correlation, operand); } } }
/** Finds a {@link RexInputRef} that is equivalent to a {@link CorRef}, * and if found, throws a {@link org.apache.calcite.util.Util.FoundOne}. */ private void findCorrelationEquivalent(CorRef correlation, RexNode e) throws Util.FoundOne { switch (e.getKind()) { case EQUALS: final RexCall call = (RexCall) e; final List<RexNode> operands = call.getOperands(); if (references(operands.get(0), correlation)) { throw new Util.FoundOne(operands.get(1)); } if (references(operands.get(1), correlation)) { throw new Util.FoundOne(operands.get(0)); } break; case AND: for (RexNode operand : ((RexCall) e).getOperands()) { findCorrelationEquivalent(correlation, operand); } } }
/** Finds a {@link RexInputRef} that is equivalent to a {@link CorRef}, * and if found, throws a {@link org.apache.calcite.util.Util.FoundOne}. */ private void findCorrelationEquivalent(CorRef correlation, RexNode e) throws Util.FoundOne { switch (e.getKind()) { case EQUALS: final RexCall call = (RexCall) e; final List<RexNode> operands = call.getOperands(); if (references(operands.get(0), correlation)) { throw new Util.FoundOne(operands.get(1)); } if (references(operands.get(1), correlation)) { throw new Util.FoundOne(operands.get(0)); } break; case AND: for (RexNode operand : ((RexCall) e).getOperands()) { findCorrelationEquivalent(correlation, operand); } } }
private boolean references(RexNode e, CorRef correlation) { switch (e.getKind()) { case CAST: final RexNode operand = ((RexCall) e).getOperands().get(0); if (isWidening(e.getType(), operand.getType())) { return references(operand, correlation); } return false; case FIELD_ACCESS: final RexFieldAccess f = (RexFieldAccess) e; if (f.getField().getIndex() == correlation.field && f.getReferenceExpr() instanceof RexCorrelVariable) { if (((RexCorrelVariable) f.getReferenceExpr()).id == correlation.corr) { return true; } } // fall through default: return false; } }
private boolean references(RexNode e, CorRef correlation) { switch (e.getKind()) { case CAST: final RexNode operand = ((RexCall) e).getOperands().get(0); if (isWidening(e.getType(), operand.getType())) { return references(operand, correlation); } return false; case FIELD_ACCESS: final RexFieldAccess f = (RexFieldAccess) e; if (f.getField().getIndex() == correlation.field && f.getReferenceExpr() instanceof RexCorrelVariable) { if (((RexCorrelVariable) f.getReferenceExpr()).id == correlation.corr) { return true; } } // fall through default: return false; } }
private boolean references(RexNode e, CorRef correlation) { switch (e.getKind()) { case CAST: final RexNode operand = ((RexCall) e).getOperands().get(0); if (isWidening(e.getType(), operand.getType())) { return references(operand, correlation); } return false; case FIELD_ACCESS: final RexFieldAccess f = (RexFieldAccess) e; if (f.getField().getIndex() == correlation.field && f.getReferenceExpr() instanceof RexCorrelVariable) { if (((RexCorrelVariable) f.getReferenceExpr()).id == correlation.corr) { return true; } } // fall through default: return false; } }