Search in sources :

Example 6 with GenMRUnionCtx

use of org.apache.hadoop.hive.ql.optimizer.GenMRProcContext.GenMRUnionCtx in project hive by apache.

the class GenMRUnion1 method processMapOnlyUnion.

/**
 * Process the union if all sub-queries are map-only
 *
 * @return
 * @throws SemanticException
 */
private Object processMapOnlyUnion(UnionOperator union, Stack<Node> stack, GenMRProcContext ctx, UnionProcContext uCtx) throws SemanticException {
    // merge currTask from multiple topOps
    GenMRUnionCtx uCtxTask = ctx.getUnionTask(union);
    if (uCtxTask != null) {
        // get task associated with this union
        Task<?> uTask = ctx.getUnionTask(union).getUTask();
        if (uTask != null) {
            if (ctx.getCurrTask() != null && ctx.getCurrTask() != uTask) {
                // if ctx.getCurrTask() is in rootTasks, should be removed
                ctx.getRootTasks().remove(ctx.getCurrTask());
            }
            ctx.setCurrTask(uTask);
        }
    }
    UnionParseContext uPrsCtx = uCtx.getUnionParseContext(union);
    ctx.getMapCurrCtx().put(union, new GenMapRedCtx(ctx.getCurrTask(), ctx.getCurrAliasId()));
    // if the union is the first time seen, set current task to GenMRUnionCtx
    uCtxTask = ctx.getUnionTask(union);
    if (uCtxTask == null) {
        uCtxTask = new GenMRUnionCtx(ctx.getCurrTask());
        ctx.setUnionTask(union, uCtxTask);
    }
    Task<?> uTask = ctx.getCurrTask();
    if (uTask.getParentTasks() == null || uTask.getParentTasks().isEmpty()) {
        if (!ctx.getRootTasks().contains(uTask)) {
            ctx.getRootTasks().add(uTask);
        }
    }
    return true;
}
Also used : UnionParseContext(org.apache.hadoop.hive.ql.optimizer.unionproc.UnionProcContext.UnionParseContext) GenMapRedCtx(org.apache.hadoop.hive.ql.optimizer.GenMRProcContext.GenMapRedCtx) GenMRUnionCtx(org.apache.hadoop.hive.ql.optimizer.GenMRProcContext.GenMRUnionCtx)

Aggregations

GenMRUnionCtx (org.apache.hadoop.hive.ql.optimizer.GenMRProcContext.GenMRUnionCtx)6 ConditionalTask (org.apache.hadoop.hive.ql.exec.ConditionalTask)2 DependencyCollectionTask (org.apache.hadoop.hive.ql.exec.DependencyCollectionTask)2 MoveTask (org.apache.hadoop.hive.ql.exec.MoveTask)2 Task (org.apache.hadoop.hive.ql.exec.Task)2 MapRedTask (org.apache.hadoop.hive.ql.exec.mr.MapRedTask)2 SparkTask (org.apache.hadoop.hive.ql.exec.spark.SparkTask)2 GenMapRedCtx (org.apache.hadoop.hive.ql.optimizer.GenMRProcContext.GenMapRedCtx)2 UnionParseContext (org.apache.hadoop.hive.ql.optimizer.unionproc.UnionProcContext.UnionParseContext)2 Serializable (java.io.Serializable)1 Operator (org.apache.hadoop.hive.ql.exec.Operator)1 TableScanOperator (org.apache.hadoop.hive.ql.exec.TableScanOperator)1 UnionOperator (org.apache.hadoop.hive.ql.exec.UnionOperator)1 TezTask (org.apache.hadoop.hive.ql.exec.tez.TezTask)1 UnionProcContext (org.apache.hadoop.hive.ql.optimizer.unionproc.UnionProcContext)1 ParseContext (org.apache.hadoop.hive.ql.parse.ParseContext)1 MapredWork (org.apache.hadoop.hive.ql.plan.MapredWork)1 OperatorDesc (org.apache.hadoop.hive.ql.plan.OperatorDesc)1