@Override public PhysicalContext resolve(PhysicalContext pctx) throws SemanticException { Map<Rule, NodeProcessor> opRules = new LinkedHashMap<Rule, NodeProcessor>(); Dispatcher disp = new AnnotateRunTimeStatsDispatcher(pctx, opRules); GraphWalker ogw = new DefaultGraphWalker(disp); ArrayList<Node> topNodes = new ArrayList<Node>(); topNodes.addAll(pctx.getRootTasks()); ogw.startWalking(topNodes, null); return pctx; }
getDispatchedList().containsAll(node.getChildren())) { if (!getDispatchedList().contains(node)) { dispatch(node, opStack); opQueue.add(node); if (!getDispatchedList().contains(childNode)) { opStack.push(childNode); break;
/** * starting point for walking. * * @throws SemanticException */ public void startWalking(Collection<Node> startNodes, HashMap<Node, Object> nodeOutput) throws SemanticException { toWalk.addAll(startNodes); while (toWalk.size() > 0) { Node nd = toWalk.remove(0); walk(nd); // Some walkers extending DefaultGraphWalker e.g. ForwardWalker // do not use opQueue and rely uniquely in the toWalk structure, // thus we store the results produced by the dispatcher here // TODO: rewriting the logic of those walkers to use opQueue if (nodeOutput != null && getDispatchedList().contains(nd)) { nodeOutput.put(nd, retMap.get(nd)); } } // Store the results produced by the dispatcher while (!opQueue.isEmpty()) { Node node = opQueue.poll(); if (nodeOutput != null && getDispatchedList().contains(node)) { nodeOutput.put(node, retMap.get(node)); } } }
/** * walk the current operator and its descendants. * * @param nd * current operator in the graph * @throws SemanticException */ public void walk(Node nd) throws SemanticException { if (opStack.empty() || nd != opStack.peek()) { opStack.push(nd); } if ((nd.getChildren() == null) || getDispatchedList().containsAll(nd.getChildren())) { // all children are done or no need to walk the children if (!getDispatchedList().contains(nd)) { dispatch(nd, opStack); } opStack.pop(); return; } // add children, self to the front of the queue in that order getToWalk().add(0, nd); getToWalk().removeAll(nd.getChildren()); getToWalk().addAll(0, nd.getChildren()); } }
/** * starting point for walking. * * @throws SemanticException */ public void startWalking(Collection<Node> startNodes, HashMap<Node, Object> nodeOutput) throws SemanticException { toWalk.addAll(startNodes); while (toWalk.size() > 0) { Node nd = toWalk.remove(0); walk(nd); if (nodeOutput != null) { nodeOutput.put(nd, retMap.get(nd)); } } }
/** * Dispatch the current operator. * * @param nd * node being walked * @param ndStack * stack of nodes encountered * @throws SemanticException */ public void dispatch(Node nd, Stack<Node> ndStack) throws SemanticException { dispatchAndReturn(nd, ndStack); }
/** * walk the current operator and its descendants. * * @param nd * current operator in the graph * @throws SemanticException */ public void walk(Node nd) throws SemanticException { if (opStack.empty() || nd != opStack.peek()) { opStack.push(nd); } if ((nd.getChildren() == null) || getDispatchedList().containsAll(nd.getChildren())) { // all children are done or no need to walk the children if (getDispatchedList().contains(nd)) { // sanity check assert false; } dispatch(nd, opStack); opStack.pop(); return; } // add children, self to the front of the queue in that order getToWalk().add(0, nd); getToWalk().removeAll(nd.getChildren()); getToWalk().addAll(0, nd.getChildren()); } }
/** * starting point for walking. * * @throws SemanticException */ public void startWalking(Collection<Node> startNodes, HashMap<Node, Object> nodeOutput) throws SemanticException { toWalk.addAll(startNodes); while (toWalk.size() > 0) { Node nd = toWalk.remove(0); walk(nd); if (nodeOutput != null) { nodeOutput.put(nd, retMap.get(nd)); } } }
/** * Dispatch the current operator. * * @param nd * node being walked * @param ndStack * stack of nodes encountered * @throws SemanticException */ public void dispatch(Node nd, Stack<Node> ndStack) throws SemanticException { dispatchAndReturn(nd, ndStack); }
private static void collectDynamicValuePredicates(ExprNodeDesc pred, NodeProcessorCtx ctx) throws SemanticException { // create a walker which walks the tree in a DFS manner while maintaining // the operator stack. The dispatcher // generates the plan from the operator tree Map<Rule, NodeProcessor> exprRules = new LinkedHashMap<Rule, NodeProcessor>(); exprRules.put(new RuleRegExp("R1", ExprNodeDynamicValueDesc.class.getName() + "%"), new DynamicValuePredicateProc()); Dispatcher disp = new DefaultRuleDispatcher(null, exprRules, ctx); GraphWalker egw = new DefaultGraphWalker(disp); List<Node> startNodes = new ArrayList<Node>(); startNodes.add(pred); egw.startWalking(startNodes, null); }
/** * starting point for walking. * * @throws SemanticException */ public void startWalking(Collection<Node> startNodes, HashMap<Node, Object> nodeOutput) throws SemanticException { toWalk.addAll(startNodes); while (toWalk.size() > 0) { Node nd = toWalk.remove(0); walk(nd); // Some walkers extending DefaultGraphWalker e.g. ForwardWalker // do not use opQueue and rely uniquely in the toWalk structure, // thus we store the results produced by the dispatcher here // TODO: rewriting the logic of those walkers to use opQueue if (nodeOutput != null && getDispatchedList().contains(nd)) { nodeOutput.put(nd, retMap.get(nd)); } } // Store the results produced by the dispatcher while (!opQueue.isEmpty()) { Node node = opQueue.poll(); if (nodeOutput != null && getDispatchedList().contains(node)) { nodeOutput.put(node, retMap.get(node)); } } }
getDispatchedList().containsAll(node.getChildren())) { if (!getDispatchedList().contains(node)) { dispatch(node, opStack); opQueue.add(node); if (!getDispatchedList().contains(childNode)) { opStack.push(childNode); break;
/** * Dispatch the current operator. * * @param nd * node being walked * @param ndStack * stack of nodes encountered * @throws SemanticException */ public void dispatch(Node nd, Stack<Node> ndStack) throws SemanticException { dispatchAndReturn(nd, ndStack); }
@Override public PhysicalContext resolve(PhysicalContext pctx) throws SemanticException { Map<Rule, NodeProcessor> opRules = new LinkedHashMap<Rule, NodeProcessor>(); Dispatcher disp = new AnnotateRunTimeStatsDispatcher(pctx, opRules); GraphWalker ogw = new DefaultGraphWalker(disp); ArrayList<Node> topNodes = new ArrayList<Node>(); topNodes.addAll(pctx.getRootTasks()); ogw.startWalking(topNodes, null); return pctx; }
@Override public PhysicalContext resolve(PhysicalContext pctx) throws SemanticException { Dispatcher disp = new SkewJoinTaskDispatcher(pctx); GraphWalker ogw = new DefaultGraphWalker(disp); ArrayList<Node> topNodes = new ArrayList<Node>(); topNodes.addAll(pctx.getRootTasks()); ogw.startWalking(topNodes, null); return pctx; }
private boolean evaluateOperators(BaseWork work) throws SemanticException { // lets take a look at the operators. we're checking for user // code in those. we will not run that in llap. Dispatcher disp = new DefaultRuleDispatcher(null, rules, null); GraphWalker ogw = new DefaultGraphWalker(disp); ArrayList<Node> topNodes = new ArrayList<Node>(); topNodes.addAll(work.getAllRootOperators()); HashMap<Node, Object> nodeOutput = new HashMap<Node, Object>(); ogw.startWalking(topNodes, nodeOutput); for (Node n : nodeOutput.keySet()) { if (nodeOutput.get(n) != null) { if (!((Boolean)nodeOutput.get(n))) { return false; } } } return true; }
@Override public PhysicalContext resolve(PhysicalContext pctx) throws SemanticException { Dispatcher disp = new SkewJoinTaskDispatcher(pctx); GraphWalker ogw = new DefaultGraphWalker(disp); ArrayList<Node> topNodes = new ArrayList<Node>(); topNodes.addAll(pctx.getRootTasks()); ogw.startWalking(topNodes, null); return pctx; }
@Override public PhysicalContext resolve(PhysicalContext physicalContext) throws SemanticException { Dispatcher dispatcher = new IndexWhereTaskDispatcher(physicalContext); GraphWalker opGraphWalker = new DefaultGraphWalker(dispatcher); ArrayList<Node> topNodes = new ArrayList<Node>(); topNodes.addAll(physicalContext.getRootTasks()); opGraphWalker.startWalking(topNodes, null); return physicalContext; } }
private static void collectDynamicValuePredicates(ExprNodeDesc pred, NodeProcessorCtx ctx) throws SemanticException { // create a walker which walks the tree in a DFS manner while maintaining // the operator stack. The dispatcher // generates the plan from the operator tree Map<Rule, NodeProcessor> exprRules = new LinkedHashMap<Rule, NodeProcessor>(); exprRules.put(new RuleRegExp("R1", ExprNodeDynamicValueDesc.class.getName() + "%"), new DynamicValuePredicateProc()); Dispatcher disp = new DefaultRuleDispatcher(null, exprRules, ctx); GraphWalker egw = new DefaultGraphWalker(disp); List<Node> startNodes = new ArrayList<Node>(); startNodes.add(pred); egw.startWalking(startNodes, null); } }
private boolean evaluateOperators(BaseWork work) throws SemanticException { // lets take a look at the operators. we're checking for user // code in those. we will not run that in llap. Dispatcher disp = new DefaultRuleDispatcher(null, rules, null); GraphWalker ogw = new DefaultGraphWalker(disp); ArrayList<Node> topNodes = new ArrayList<Node>(); topNodes.addAll(work.getAllRootOperators()); HashMap<Node, Object> nodeOutput = new HashMap<Node, Object>(); ogw.startWalking(topNodes, nodeOutput); for (Node n : nodeOutput.keySet()) { if (nodeOutput.get(n) != null) { if (!((Boolean)nodeOutput.get(n))) { return false; } } } return true; }