public static void replaceNode(LogicalNode plan, LogicalNode newNode, NodeType type) { LogicalNode parent = findTopParentNode(plan, type); Preconditions.checkArgument(parent instanceof UnaryNode); Preconditions.checkArgument(!(newNode instanceof BinaryNode)); UnaryNode parentNode = (UnaryNode) parent; LogicalNode child = parentNode.getChild(); if (child instanceof UnaryNode) { ((UnaryNode) newNode).setChild(((UnaryNode) child).getChild()); } parentNode.setChild(newNode); }
@Override public Object clone() throws CloneNotSupportedException { LimitNode newLimitNode = (LimitNode) super.clone(); newLimitNode.fetchFirstNum = fetchFirstNum; return newLimitNode; }
@Override public boolean equals(Object obj) { if (obj instanceof LimitNode) { LimitNode other = (LimitNode) obj; return super.equals(other) && fetchFirstNum == other.fetchFirstNum; } else { return false; } }
private LogicalNode visitUnaryNode(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, UnaryNode node, Stack<LogicalNode> stack) throws TajoException { context.depth++; stack.push(node); visit(context, plan, block, node.getChild(), stack); context.depth--; context.add(context.depth, node.getPlanString()); return node; }
public void setLogicalPlan(LogicalNode plan) { this.plan = plan; LogicalNode node = plan; ArrayList<LogicalNode> s = new ArrayList<LogicalNode>(); s.add(node); while (!s.isEmpty()) { node = s.remove(s.size()-1); if (node instanceof UnaryNode) { UnaryNode unary = (UnaryNode) node; s.add(s.size(), unary.getChild()); } else if (node instanceof BinaryNode) { BinaryNode binary = (BinaryNode) node; s.add(s.size(), binary.getLeftChild()); s.add(s.size(), binary.getRightChild()); } else if (node instanceof ScanNode) { scan.add((ScanNode)node); } else if (node instanceof TableSubQueryNode) { s.add(((TableSubQueryNode) node).getSubQuery()); } } }
public void setChild(LogicalNode subNode) { super.setChild(subNode); }
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((options == null) ? 0 : options.hashCode()); result = prime * result + ((storageType == null) ? 0 : storageType.hashCode()); return result; }
public void setLogicalPlan(LogicalNode plan) { this.plan = plan; LogicalNode node = plan; ArrayList<LogicalNode> s = new ArrayList<>(); s.add(node); while (!s.isEmpty()) { node = s.remove(s.size()-1); if (node instanceof UnaryNode) { UnaryNode unary = (UnaryNode) node; s.add(s.size(), unary.getChild()); } else if (node instanceof BinaryNode) { BinaryNode binary = (BinaryNode) node; s.add(s.size(), binary.getLeftChild()); s.add(s.size(), binary.getRightChild()); } else if (node instanceof ScanNode) { scan.add((ScanNode)node); } else if (node instanceof TableSubQueryNode) { s.add(((TableSubQueryNode) node).getSubQuery()); } } }
public void setChild(LogicalNode subNode) { super.setChild(subNode); }
private LogicalNode visitUnaryNode(Context context, LogicalPlan plan, LogicalPlan.QueryBlock block, UnaryNode node, Stack<LogicalNode> stack) throws TajoException { context.depth++; stack.push(node); visit(context, plan, block, node.getChild(), stack); context.depth--; context.add(context.depth, node.getPlanString()); return node; }
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((options == null) ? 0 : options.hashCode()); result = prime * result + ((storageType == null) ? 0 : storageType.hashCode()); return result; }
public static void replaceNode(LogicalNode plan, LogicalNode newNode, NodeType type) { LogicalNode parent = findTopParentNode(plan, type); Preconditions.checkArgument(parent instanceof UnaryNode); Preconditions.checkArgument(!(newNode instanceof BinaryNode)); UnaryNode parentNode = (UnaryNode) parent; LogicalNode child = parentNode.getChild(); if (child instanceof UnaryNode) { ((UnaryNode) newNode).setChild(((UnaryNode) child).getChild()); } parentNode.setChild(newNode); }
LogicalNode childNode = node.getChild(); if (child.getChild().getType() == NodeType.PROJECTION) { child = child.getChild(); if (child.getChild().getType() == NodeType.TABLE_SUBQUERY) { TableSubQueryNode tableSubQuery = child.getChild(); return tableSubQuery.getSubQuery().getType() == NodeType.UNION; TableSubQueryNode tableSubQuery = node.getChild(); return tableSubQuery.getSubQuery().getType() == NodeType.UNION; } else if (childNode.getType() == NodeType.UNION) { // third case
public void setChild(LogicalNode subNode) { super.setChild(subNode); }
@Override public Object clone() throws CloneNotSupportedException { LimitNode newLimitNode = (LimitNode) super.clone(); newLimitNode.fetchFirstNum = fetchFirstNum; return newLimitNode; }
@Override public boolean equals(Object obj) { if (obj instanceof LimitNode) { LimitNode other = (LimitNode) obj; return super.equals(other) && fetchFirstNum == other.fetchFirstNum; } else { return false; } }
/** * Delete the logical node from a plan. * * @param parent this node must be a parent node of one node to be removed. * @param tobeRemoved this node must be a child node of the parent. */ public static LogicalNode deleteNode(LogicalNode parent, LogicalNode tobeRemoved) { Preconditions.checkArgument(tobeRemoved instanceof UnaryNode, "ERROR: the logical node to be removed must be unary node."); UnaryNode child = (UnaryNode) tobeRemoved; LogicalNode grandChild = child.getChild(); if (parent instanceof UnaryNode) { UnaryNode unaryParent = (UnaryNode) parent; Preconditions.checkArgument(unaryParent.getChild() == child, "ERROR: both logical node must be parent and child nodes"); unaryParent.setChild(grandChild); } else if (parent instanceof BinaryNode) { BinaryNode binaryParent = (BinaryNode) parent; if (binaryParent.getLeftChild().deepEquals(child)) { binaryParent.setLeftChild(grandChild); } else if (binaryParent.getRightChild().deepEquals(child)) { binaryParent.setRightChild(grandChild); } else { throw new TajoInternalError("both logical node must be parent and child nodes"); } } else { throw new TajoInternalError("unexpected logical plan: " + parent); } return child; }
LogicalNode childNode = node.getChild(); if (child.getChild().getType() == NodeType.PROJECTION) { child = child.getChild(); if (child.getChild().getType() == NodeType.TABLE_SUBQUERY) { TableSubQueryNode tableSubQuery = child.getChild(); return tableSubQuery.getSubQuery().getType() == NodeType.UNION; TableSubQueryNode tableSubQuery = node.getChild(); return tableSubQuery.getSubQuery().getType() == NodeType.UNION; } else if (childNode.getType() == NodeType.UNION) { // third case
public void setChild(LogicalNode subNode) { super.setChild(subNode); }
@Override public Object clone() throws CloneNotSupportedException { return super.clone(); }