public void setInputContext(String tableName, String partitionName) { if (childOperators != null) { for (Operator<? extends OperatorDesc> child : childOperators) { if (child.getNumParent() == 1) { child.setInputContext(tableName, partitionName); } } } }
public void setInputContext(String tableName, String partitionName) { if (childOperators != null) { for (Operator<? extends OperatorDesc> child : childOperators) { if (child.getNumParent() == 1) { child.setInputContext(tableName, partitionName); } } } }
/** * Compares the whole operator tree with the other. */ // Currently only used during re-optimization related parts. // FIXME: HIVE-18703 should probably move this method somewhere else public final boolean logicalEqualsTree(Operator<?> o) { // XXX: this could easily become a hot-spot if (!logicalEquals(o)) { return false; } if (o.getNumParent() != getNumParent()) { return false; } for (int i = 0; i < getNumParent(); i++) { Operator<? extends OperatorDesc> copL = parentOperators.get(i); Operator<? extends OperatorDesc> copR = o.parentOperators.get(i); if (!copL.logicalEquals(copR)) { return false; } } return true; }
private static boolean isStrictEqualityNeeded(ReduceSinkOperator cRS, ReduceSinkOperator pRS) { Operator<? extends OperatorDesc> parent = cRS.getParentOperators().get(0); while (parent != pRS) { assert parent.getNumParent() == 1; if (parent instanceof PTFOperator) { return true; } parent = parent.getParentOperators().get(0); } return false; }
private boolean isStrictEqualityNeeded(ReduceSinkOperator cRS, ReduceSinkOperator pRS) { Operator<? extends OperatorDesc> parent = cRS.getParentOperators().get(0); while (parent != pRS) { assert parent.getNumParent() == 1; if (parent instanceof PTFOperator) { return true; } parent = parent.getParentOperators().get(0); } return false; }
protected static boolean checkSingleBranchOnly(ReduceSinkOperator cRS, ReduceSinkOperator pRS) { Operator<? extends OperatorDesc> parent = cRS.getParentOperators().get(0); while (parent != pRS) { assert parent.getNumParent() == 1; if (parent.getChildOperators().size() > 1) { return false; } parent = parent.getParentOperators().get(0); } return true; }
/** * Search the query plan tree from startPoint to the bottom. If there is no ReduceSinkOperator * between startPoint and the corresponding TableScanOperator, return the corresponding * TableScanOperator. Otherwise, return null. * @param startPoint the operator which the search will start at * @return the TableScanOperator traced from startPoint. Null, if the search encounters any * ReduceSinkOperator. */ protected static Set<TableScanOperator> findTableScanOperators(Operator<?> startPoint) { if (startPoint instanceof ReduceSinkOperator) { assert startPoint.getNumParent() == 1; // for now startPoint = startPoint.getParentOperators().get(0); } return findTableScanOperators(startPoint, new LinkedHashSet<TableScanOperator>()); }
private static Set<TableScanOperator> findTableScanOperators(Operator<?> current, Set<TableScanOperator> found) { if (current instanceof TableScanOperator) { found.add((TableScanOperator) current); return found; } if (current instanceof ReduceSinkOperator || current.getNumParent() == 0) { return found; } for (Operator<?> parent : current.getParentOperators()) { findTableScanOperators(parent, found); } return found; }
/** * Recursively collect all roots (e.g., table scans) that can be reached via this op. * @param result contains all roots can be reached via op * @param op the op to examine. */ private void collectRoots(List<Operator<?>> result, Operator<?> op) { if (op.getNumParent() == 0) { result.add(op); } else { for (Operator<?> parentOp : op.getParentOperators()) { collectRoots(result, parentOp); } } }
/** * Search the query plan tree from startPoint to the bottom. If there is no ReduceSinkOperator * between startPoint and the corresponding TableScanOperator, return the corresponding * TableScanOperator. Otherwise, return null. * @param startPoint the operator which the search will start at * @return the TableScanOperator traced from startPoint. Null, if the search encounters any * ReduceSinkOperator. */ protected static Set<TableScanOperator> findTableScanOperators(Operator<?> startPoint) { if (startPoint instanceof ReduceSinkOperator) { assert startPoint.getNumParent() == 1; // for now startPoint = startPoint.getParentOperators().get(0); } return findTableScanOperators(startPoint, new LinkedHashSet<TableScanOperator>()); }
protected static boolean checkSelectSingleBranchOnly(ReduceSinkOperator cRS, ReduceSinkOperator pRS) { Operator<? extends OperatorDesc> parent = cRS.getParentOperators().get(0); while (parent != pRS) { assert parent.getNumParent() == 1; if (!(parent instanceof SelectOperator)) { return false; } if (parent.getChildOperators().size() > 1) { return false; } parent = parent.getParentOperators().get(0); } return true; }
/** * Recursively collect all roots (e.g., table scans) that can be reached via this op. * @param result contains all roots can be reached via op * @param op the op to examine. */ private void collectRoots(List<Operator<?>> result, Operator<?> op) { if (op.getNumParent() == 0) { result.add(op); } else { for (Operator<?> parentOp : op.getParentOperators()) { collectRoots(result, parentOp); } } }
private static Set<TableScanOperator> findTableScanOperators(Operator<?> current, Set<TableScanOperator> found) { if (current instanceof TableScanOperator) { found.add((TableScanOperator) current); return found; } if (current instanceof ReduceSinkOperator || current.getNumParent() == 0) { return found; } for (Operator<?> parent : current.getParentOperators()) { findTableScanOperators(parent, found); } return found; }
private static void iterateParents(Operator<?> operator, Function<Operator<?>> function, Set<Operator<?>> visited) { if (!visited.add(operator)) { return; } function.apply(operator); if (operator.getNumParent() > 0) { for (Operator<?> parent : operator.getParentOperators()) { iterateParents(parent, function, visited); } } }
public static void removeOperator(Operator<?> target, ParseContext context) { assert target.getNumParent() == 1 && target.getNumChild() == 1; removeOperator(target, target.getChildOperators().get(0), target.getParentOperators().get(0), context); }
private static void iterateParents(Operator<?> operator, Function<Operator<?>> function, Set<Operator<?>> visited) { if (!visited.add(operator)) { return; } function.apply(operator); if (operator.getNumParent() > 0) { for (Operator<?> parent : operator.getParentOperators()) { iterateParents(parent, function, visited); } } }
public static void removeOperator(Operator<?> target, ParseContext context) { assert target.getNumParent() == 1 && target.getNumChild() == 1; removeOperator(target, target.getChildOperators().get(0), target.getParentOperators().get(0), context); }
Operator<?> parent = joinOp.getParentOperators().get(tablePosition); for (; parent != null; parent = parent.getNumParent() > 0 ? parent.getParentOperators().get(0) : null) { if (parent.getNumChild() > 1 && !(parent instanceof LateralViewForwardOperator)) { if (multiChildrenSource >= 0) {
/** * Remove operator from the tree, disconnecting it from its * parents and children. */ public static void removeOperator(Operator<?> op) { if (op.getNumParent() != 0) { List<Operator<? extends OperatorDesc>> allParent = Lists.newArrayList(op.getParentOperators()); for (Operator<?> parentOp : allParent) { parentOp.removeChild(op); } } if (op.getNumChild() != 0) { List<Operator<? extends OperatorDesc>> allChildren = Lists.newArrayList(op.getChildOperators()); for (Operator<?> childOp : allChildren) { childOp.removeParent(op); } } }
Operator<? extends OperatorDesc> parent = pSel; while (!(parent instanceof ReduceSinkOperator)) { if (parent.getNumParent() != 1 || !(parent instanceof SelectOperator)) { return;