/** * Walks through the top AND nodes and determine which of them are final * candidates. */ private static void extractFinalCandidates(ExprNodeDesc expr, ExprWalkerInfo ctx) { if (ctx.isCandidate(expr)) { ctx.addFinalCandidate(expr); return; } if (FunctionRegistry.isOpAnd(expr)) { // If the operator is AND, we need to determine if any of the children are // final candidates. for (Node ch : expr.getChildren()) { extractFinalCandidates((ExprNodeDesc) ch, ctx); } } }
@Override public Object process(Node nd, Stack<Node> stack, NodeProcessorCtx procCtx, Object... nodeOutputs) throws SemanticException { ExprWalkerInfo ctx = (ExprWalkerInfo) procCtx; String alias = null; ExprNodeFieldDesc expr = (ExprNodeFieldDesc) nd; boolean isCandidate = true; assert (nd.getChildren().size() == 1); ExprNodeDesc ch = (ExprNodeDesc) nd.getChildren().get(0); ExprNodeDesc newCh = ctx.getConvertedNode(ch); if (newCh != null) { expr.setDesc(newCh); ch = newCh; } String chAlias = ctx.getAlias(ch); isCandidate = isCandidate && ctx.isCandidate(ch); // need to iterate through all children even if one is found to be not a // candidate // in case if the other children could be individually pushed up if (isCandidate && chAlias != null) { if (alias == null) { alias = chAlias; } else if (!chAlias.equalsIgnoreCase(alias)) { isCandidate = false; } } ctx.addAlias(expr, alias); ctx.setIsCandidate(expr, isCandidate); return isCandidate; }
@Override public Object process(Node nd, Stack<Node> stack, NodeProcessorCtx procCtx, Object... nodeOutputs) throws SemanticException { ExprWalkerInfo ctx = (ExprWalkerInfo) procCtx; String alias = null; ExprNodeFieldDesc expr = (ExprNodeFieldDesc) nd; boolean isCandidate = true; assert (nd.getChildren().size() == 1); ExprNodeDesc ch = (ExprNodeDesc) nd.getChildren().get(0); ExprNodeDesc newCh = ctx.getConvertedNode(ch); if (newCh != null) { expr.setDesc(newCh); ch = newCh; } String chAlias = ctx.getAlias(ch); isCandidate = isCandidate && ctx.isCandidate(ch); // need to iterate through all children even if one is found to be not a // candidate // in case if the other children could be individually pushed up if (isCandidate && chAlias != null) { if (alias == null) { alias = chAlias; } else if (!chAlias.equalsIgnoreCase(alias)) { isCandidate = false; } } ctx.addAlias(expr, alias); ctx.setIsCandidate(expr, isCandidate); return isCandidate; }
if (ctx.isCandidate(expr)) { ctx.addFinalCandidate(expr); return;
isCandidate = isCandidate && ctx.isCandidate(ch);
isCandidate = isCandidate && ctx.isCandidate(ch);