public class OperatorUtils extends Object
Constructor and Description |
---|
OperatorUtils() |
Modifier and Type | Method and Description |
---|---|
static <T> T |
ancestor(Operator<?> op,
Class<T> clazz,
int... path)
Return the ancestor of the specified operator at the provided path or null if the path is invalid.
|
static com.google.common.collect.Multimap<Class<? extends Operator<?>>,Operator<?>> |
classifyOperators(Operator<?> start,
Set<Class<? extends Operator<?>>> classes)
Given an operator and a set of classes, it classifies the operators it finds
in the stream depending on the classes they instantiate.
|
static com.google.common.collect.Multimap<Class<? extends Operator<?>>,Operator<?>> |
classifyOperatorsUpstream(Operator<?> start,
Set<Class<? extends Operator<?>>> classes)
Given an operator and a set of classes, it classifies the operators it finds
upstream depending on the classes it instantiates.
|
static int |
countOperatorsUpstream(Operator<?> start,
Set<Class<? extends Operator<?>>> classes)
Given an operator and a set of classes, it returns the number of operators it finds
upstream that instantiate any of the given classes.
|
static <T> T |
findLastOperator(Operator<?> op,
Class<T> clazz)
Starting at the input operator, finds the last operator in the stream that
is an instance of the input class.
|
static GroupByOperator |
findMapSideGb(GroupByOperator reduceSideGbOp)
Given group by operator on reduce side, this tries to get to the group by on map side (partial/merge).
|
static Operator<?> |
findOperatorByMarker(Operator<?> start,
String marker) |
static <T> Set<T> |
findOperators(Collection<Operator<?>> starts,
Class<T> clazz) |
static <T> Set<T> |
findOperators(Operator<?> start,
Class<T> clazz) |
static <T> Set<T> |
findOperatorsUpstream(Collection<Operator<?>> starts,
Class<T> clazz) |
static <T> Set<T> |
findOperatorsUpstream(Operator<?> start,
Class<T> clazz) |
static <T> Set<T> |
findOperatorsUpstreamJoinAccounted(Operator<?> start,
Class<T> clazz,
Set<T> found) |
static <T> T |
findSingleOperator(Operator<?> start,
Class<T> clazz) |
static <T> T |
findSingleOperatorUpstream(Operator<?> start,
Class<T> clazz) |
static <T> T |
findSingleOperatorUpstreamJoinAccounted(Operator<?> start,
Class<T> clazz) |
static Operator<? extends OperatorDesc> |
findSourceRS(Operator<?> start,
List<ExprNodeDesc> exprs)
This method backtracks the given expressions to the source RS.
|
static ExprNodeColumnDesc |
findTableOriginColExpr(ExprNodeColumnDesc colName,
Operator<?> start,
Operator<?> end)
Given start, end operators and a colName, look for the original TS colExpr
that it originates from.
|
static Set<Operator<?>> |
findWorkOperatorsAndSemiJoinEdges(Operator<?> start,
Map<ReduceSinkOperator,SemiJoinBranchInfo> rsToSemiJoinBranchInfo,
Set<ReduceSinkOperator> semiJoinOps,
Set<TerminalOperator<?>> terminalOps) |
static Set<Operator<?>> |
getAllFetchOperators(FetchTask task)
Given a
FetchTask this returns a set of all the operators within the task |
static Set<Operator<?>> |
getAllOperatorsForSimpleFetch(Set<Operator<?>> opSet) |
static Set<Operator<?>> |
getOp(BaseWork work,
Class<?> clazz) |
static String |
getOpNamePretty(Operator<?> op) |
static void |
iterateParents(Operator<?> operator,
NodeUtils.Function<Operator<?>> function) |
static void |
removeOperator(Operator<?> op)
Remove operator from the tree, disconnecting it from its
parents and children.
|
static void |
setChildrenCollector(List<Operator<? extends OperatorDesc>> childOperators,
Map<String,org.apache.hadoop.mapred.OutputCollector> outMap) |
static void |
setChildrenCollector(List<Operator<? extends OperatorDesc>> childOperators,
org.apache.hadoop.mapred.OutputCollector out) |
static void |
setMemoryAvailable(List<Operator<? extends OperatorDesc>> operators,
long memoryAvailableToTask) |
static boolean |
treesWithIndependentInputs(Operator<?> tree1,
Operator<?> tree2)
Determines if the two trees are using independent inputs.
|
public static <T> T ancestor(Operator<?> op, Class<T> clazz, int... path)
op.getParentOperators().get(path[0])
.getParentOperators().get(path[1])
...
.getParentOperators().get(path[n])
with additional checks about the validity of the provided path and the type of the ancestor.T
- the type of the ancestorop
- the operator for which weclazz
- the class of the ancestor operatorpath
- the path leading to the desired ancestorpublic static <T> Set<T> findOperators(Collection<Operator<?>> starts, Class<T> clazz)
public static <T> Set<T> findOperatorsUpstream(Operator<?> start, Class<T> clazz)
public static <T> T findSingleOperatorUpstream(Operator<?> start, Class<T> clazz)
public static <T> T findSingleOperatorUpstreamJoinAccounted(Operator<?> start, Class<T> clazz)
public static <T> Set<T> findOperatorsUpstream(Collection<Operator<?>> starts, Class<T> clazz)
public static <T> Set<T> findOperatorsUpstreamJoinAccounted(Operator<?> start, Class<T> clazz, Set<T> found)
public static void setChildrenCollector(List<Operator<? extends OperatorDesc>> childOperators, org.apache.hadoop.mapred.OutputCollector out)
public static void setChildrenCollector(List<Operator<? extends OperatorDesc>> childOperators, Map<String,org.apache.hadoop.mapred.OutputCollector> outMap)
public static <T> T findLastOperator(Operator<?> op, Class<T> clazz)
op
- the starting operatorclazz
- the class that the operator that we are looking for instantiatespublic static void iterateParents(Operator<?> operator, NodeUtils.Function<Operator<?>> function)
public static com.google.common.collect.Multimap<Class<? extends Operator<?>>,Operator<?>> classifyOperators(Operator<?> start, Set<Class<? extends Operator<?>>> classes)
start
- the start operatorclasses
- the set of classespublic static com.google.common.collect.Multimap<Class<? extends Operator<?>>,Operator<?>> classifyOperatorsUpstream(Operator<?> start, Set<Class<? extends Operator<?>>> classes)
start
- the start operatorclasses
- the set of classespublic static int countOperatorsUpstream(Operator<?> start, Set<Class<? extends Operator<?>>> classes)
start
- the start operatorclasses
- the set of classespublic static void setMemoryAvailable(List<Operator<? extends OperatorDesc>> operators, long memoryAvailableToTask)
public static void removeOperator(Operator<?> op)
public static Operator<?> findOperatorByMarker(Operator<?> start, String marker)
public static Set<Operator<?>> findWorkOperatorsAndSemiJoinEdges(Operator<?> start, Map<ReduceSinkOperator,SemiJoinBranchInfo> rsToSemiJoinBranchInfo, Set<ReduceSinkOperator> semiJoinOps, Set<TerminalOperator<?>> terminalOps)
public static Operator<? extends OperatorDesc> findSourceRS(Operator<?> start, List<ExprNodeDesc> exprs)
start
- exprs
- public static GroupByOperator findMapSideGb(GroupByOperator reduceSideGbOp)
reduceSideGbOp
- Make sure this is group by side reducerpublic static boolean treesWithIndependentInputs(Operator<?> tree1, Operator<?> tree2)
public static ExprNodeColumnDesc findTableOriginColExpr(ExprNodeColumnDesc colName, Operator<?> start, Operator<?> end) throws SemanticException
colName
- colName to backtrackstart
- start backtracking from this Opend
- end backtracking at this OpSemanticException
public static Set<Operator<?>> getAllOperatorsForSimpleFetch(Set<Operator<?>> opSet)
Copyright © 2022 The Apache Software Foundation. All rights reserved.