public static <T> T findSingleOperatorUpstreamJoinAccounted(Operator<?> start, Class<T> clazz) { Set<T> found = findOperatorsUpstreamJoinAccounted(start, clazz, new HashSet<T>()); return found.size() >= 1 ? found.iterator().next(): null; }
public static <T> T findSingleOperatorUpstreamJoinAccounted(Operator<?> start, Class<T> clazz) { Set<T> found = findOperatorsUpstreamJoinAccounted(start, clazz, new HashSet<T>()); return found.size() >= 1 ? found.iterator().next(): null; }
public static <T> Set<T> findOperatorsUpstreamJoinAccounted(Operator<?> start, Class<T> clazz, Set<T> found) { if (clazz.isInstance(start)) { found.add((T) start); } int onlyIncludeIndex = -1; if (start instanceof AbstractMapJoinOperator) { AbstractMapJoinOperator mapJoinOp = (AbstractMapJoinOperator) start; MapJoinDesc desc = (MapJoinDesc) mapJoinOp.getConf(); onlyIncludeIndex = desc.getPosBigTable(); } if (start.getParentOperators() != null) { int i = 0; for (Operator<?> parent : start.getParentOperators()) { if (onlyIncludeIndex >= 0) { if (onlyIncludeIndex == i) { findOperatorsUpstreamJoinAccounted(parent, clazz, found); } } else { findOperatorsUpstreamJoinAccounted(parent, clazz, found); } i++; } } return found; }
public static <T> T findSingleOperatorUpstreamJoinAccounted(Operator<?> start, Class<T> clazz) { Set<T> found = findOperatorsUpstreamJoinAccounted(start, clazz, new HashSet<T>()); return found.size() == 1 ? found.iterator().next(): null; }