org.apache.hadoop.hive.ql.optimizer.correlation
Class CorrelationUtilities

java.lang.Object
  extended by org.apache.hadoop.hive.ql.optimizer.correlation.CorrelationUtilities

public final class CorrelationUtilities
extends Object

Utilities for both CorrelationOptimizer and ReduceSinkDeDuplication.


Constructor Summary
CorrelationUtilities()
           
 
Method Summary
protected static
<T extends Operator<?>>
T[]
findParents(JoinOperator join, Class<T> target)
           
protected static
<T extends Operator<?>>
T
findPossibleParent(Operator<?> start, Class<T> target, boolean trustScript)
           
protected static
<T extends Operator<?>>
T[]
findPossibleParents(Operator<?> start, Class<T> target, boolean trustScript)
           
static List<Operator<? extends OperatorDesc>> findSiblingOperators(Operator<? extends OperatorDesc> op)
          Find all sibling operators (which have the same child operator of op) of op (op included).
static List<ReduceSinkOperator> findSiblingReduceSinkOperators(ReduceSinkOperator op)
          Find all sibling ReduceSinkOperators (which have the same child operator of op) of op (op included).
protected static TableScanOperator findTableScanOperator(Operator<? extends OperatorDesc> startPoint)
          Search the query plan tree from startPoint to the bottom.
protected static String getColumnName(Map<String,ExprNodeDesc> opColumnExprMap, ExprNodeDesc expr)
           
protected static Operator<?> getSingleChild(Operator<?> operator)
           
protected static Operator<?> getSingleChild(Operator<?> operator, boolean throwException)
           
protected static
<T> T
getSingleChild(Operator<?> operator, Class<T> type)
           
protected static Operator<?> getSingleParent(Operator<?> operator)
           
protected static Operator<?> getSingleParent(Operator<?> operator, boolean throwException)
           
protected static
<T> T
getSingleParent(Operator<?> operator, Class<T> type)
           
protected static boolean[] getSortedTags(JoinOperator joinOp)
           
protected static Operator<?> getStartForGroupBy(ReduceSinkOperator cRS)
           
protected static boolean hasGroupingSet(ReduceSinkOperator cRS)
           
protected static int indexOf(ExprNodeDesc cexpr, ExprNodeDesc[] pexprs, Operator child, Operator[] parents, boolean[] sorted)
           
protected static void insertOperatorBetween(Operator<?> newOperator, Operator<?> parent, Operator<?> child)
           
protected static boolean isExisted(ExprNodeDesc expr, List<ExprNodeDesc> columns)
           
protected static void isNullOperator(Operator<?> operator)
          throw a exception if the input operator is null
protected static boolean isSortedTag(JoinOperator joinOp, int tag)
           
protected static Operator<? extends Serializable> putOpInsertMap(Operator<?> op, RowResolver rr, ParseContext context)
           
protected static void removeOperator(Operator<?> target, Operator<?> child, Operator<?> parent, ParseContext context)
           
protected static void removeReduceSinkForGroupBy(ReduceSinkOperator cRS, GroupByOperator cGBYr, ParseContext context, org.apache.hadoop.hive.ql.optimizer.correlation.AbstractCorrelationProcCtx procCtx)
           
protected static SelectOperator replaceOperatorWithSelect(Operator<?> operator, ParseContext context, org.apache.hadoop.hive.ql.optimizer.correlation.AbstractCorrelationProcCtx procCtx)
           
protected static SelectOperator replaceReduceSinkWithSelectOperator(ReduceSinkOperator childRS, ParseContext context, org.apache.hadoop.hive.ql.optimizer.correlation.AbstractCorrelationProcCtx procCtx)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CorrelationUtilities

public CorrelationUtilities()
Method Detail

isExisted

protected static boolean isExisted(ExprNodeDesc expr,
                                   List<ExprNodeDesc> columns)

getColumnName

protected static String getColumnName(Map<String,ExprNodeDesc> opColumnExprMap,
                                      ExprNodeDesc expr)

hasGroupingSet

protected static boolean hasGroupingSet(ReduceSinkOperator cRS)
                                 throws SemanticException
Throws:
SemanticException

getSingleParent

protected static Operator<?> getSingleParent(Operator<?> operator,
                                             boolean throwException)
                                      throws SemanticException
Parameters:
operator - the input operator
throwException - if throw a exception when the input operator has multiple parents
Returns:
the single parent or null when the input operator has multiple parents and throwException is false;
Throws:
HiveException
SemanticException

getSingleParent

protected static Operator<?> getSingleParent(Operator<?> operator)
                                      throws SemanticException
Throws:
SemanticException

getSingleChild

protected static Operator<?> getSingleChild(Operator<?> operator,
                                            boolean throwException)
                                     throws SemanticException
Parameters:
operator - the input operator
throwException - if throw a exception when the input operator has multiple children
Returns:
the single child or null when the input operator has multiple children and throwException is false;
Throws:
HiveException
SemanticException

getSingleChild

protected static Operator<?> getSingleChild(Operator<?> operator)
                                     throws SemanticException
Throws:
SemanticException

getSingleChild

protected static <T> T getSingleChild(Operator<?> operator,
                                      Class<T> type)
                           throws SemanticException
Throws:
SemanticException

getSingleParent

protected static <T> T getSingleParent(Operator<?> operator,
                                       Class<T> type)
                            throws SemanticException
Throws:
SemanticException

getStartForGroupBy

protected static Operator<?> getStartForGroupBy(ReduceSinkOperator cRS)
                                         throws SemanticException
Throws:
SemanticException

getSortedTags

protected static boolean[] getSortedTags(JoinOperator joinOp)

isSortedTag

protected static boolean isSortedTag(JoinOperator joinOp,
                                     int tag)

indexOf

protected static int indexOf(ExprNodeDesc cexpr,
                             ExprNodeDesc[] pexprs,
                             Operator child,
                             Operator[] parents,
                             boolean[] sorted)
                      throws SemanticException
Throws:
SemanticException

findPossibleParent

protected static <T extends Operator<?>> T findPossibleParent(Operator<?> start,
                                                              Class<T> target,
                                                              boolean trustScript)
                                                   throws SemanticException
Throws:
SemanticException

findPossibleParents

protected static <T extends Operator<?>> T[] findPossibleParents(Operator<?> start,
                                                                 Class<T> target,
                                                                 boolean trustScript)
                                                      throws SemanticException
Throws:
SemanticException

findParents

protected static <T extends Operator<?>> T[] findParents(JoinOperator join,
                                                         Class<T> target)
                                              throws SemanticException
Throws:
SemanticException

findTableScanOperator

protected static TableScanOperator findTableScanOperator(Operator<? extends OperatorDesc> startPoint)
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.

Parameters:
startPoint - the operator which the search will start at
Returns:
the TableScanOperator traced from startPoint. Null, if the search encounters any ReduceSinkOperator.

findSiblingReduceSinkOperators

public static List<ReduceSinkOperator> findSiblingReduceSinkOperators(ReduceSinkOperator op)
                                                               throws SemanticException
Find all sibling ReduceSinkOperators (which have the same child operator of op) of op (op included).

Throws:
SemanticException

findSiblingOperators

public static List<Operator<? extends OperatorDesc>> findSiblingOperators(Operator<? extends OperatorDesc> op)
                                                                   throws SemanticException
Find all sibling operators (which have the same child operator of op) of op (op included).

Throws:
SemanticException

replaceReduceSinkWithSelectOperator

protected static SelectOperator replaceReduceSinkWithSelectOperator(ReduceSinkOperator childRS,
                                                                    ParseContext context,
                                                                    org.apache.hadoop.hive.ql.optimizer.correlation.AbstractCorrelationProcCtx procCtx)
                                                             throws SemanticException
Throws:
SemanticException

replaceOperatorWithSelect

protected static SelectOperator replaceOperatorWithSelect(Operator<?> operator,
                                                          ParseContext context,
                                                          org.apache.hadoop.hive.ql.optimizer.correlation.AbstractCorrelationProcCtx procCtx)
                                                   throws SemanticException
Throws:
SemanticException

removeReduceSinkForGroupBy

protected static void removeReduceSinkForGroupBy(ReduceSinkOperator cRS,
                                                 GroupByOperator cGBYr,
                                                 ParseContext context,
                                                 org.apache.hadoop.hive.ql.optimizer.correlation.AbstractCorrelationProcCtx procCtx)
                                          throws SemanticException
Throws:
SemanticException

isNullOperator

protected static void isNullOperator(Operator<?> operator)
                              throws SemanticException
throw a exception if the input operator is null

Parameters:
operator -
Throws:
HiveException
SemanticException

insertOperatorBetween

protected static void insertOperatorBetween(Operator<?> newOperator,
                                            Operator<?> parent,
                                            Operator<?> child)
                                     throws SemanticException
Parameters:
newOperator - the operator will be inserted between child and parent
child -
parent -
context -
Throws:
HiveException
SemanticException

removeOperator

protected static void removeOperator(Operator<?> target,
                                     Operator<?> child,
                                     Operator<?> parent,
                                     ParseContext context)

putOpInsertMap

protected static Operator<? extends Serializable> putOpInsertMap(Operator<?> op,
                                                                 RowResolver rr,
                                                                 ParseContext context)


Copyright © 2012 The Apache Software Foundation