Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 
 package org.apache.hadoop.hive.ql.optimizer.physical;
 
 import java.util.Map;
 
An implementation of PhysicalPlanResolver. It iterator each task with a rule dispatcher for its reducer operator tree, for task with join op in reducer, it will try to add a conditional task associated a list of skew join tasks.
 
 public class SkewJoinResolver implements PhysicalPlanResolver {
   @Override
     Dispatcher disp = new SkewJoinTaskDispatcher(pctx);
     GraphWalker ogw = new DefaultGraphWalker(disp);
     ArrayList<NodetopNodes = new ArrayList<Node>();
     topNodes.addAll(pctx.rootTasks);
     ogw.startWalking(topNodesnull);
     return pctx;
   }

  
Iterator a task with a rule dispatcher for its reducer operator tree.
 
   class SkewJoinTaskDispatcher implements Dispatcher {
 
     private PhysicalContext physicalContext;
 
     public SkewJoinTaskDispatcher(PhysicalContext context) {
       super();
        = context;
     }
 
     @Override
     public Object dispatch(Node ndStack<NodestackObject... nodeOutputs)
         throws SemanticException {
       Task<? extends Serializabletask = (Task<? extends Serializable>) nd;
 
       if (!task.isMapRedTask() || task instanceof ConditionalTask
           || ((MapredWorktask.getWork()).getReducer() == null) {
         return null;
       }
 
       SkewJoinProcCtx skewJoinProcContext = new SkewJoinProcCtx(task,
           .getParseContext());
 
       Map<RuleNodeProcessoropRules = new LinkedHashMap<RuleNodeProcessor>();
       opRules.put(new RuleRegExp("R1""JOIN%"), SkewJoinProcFactory
           .getJoinProc());
 
       // The dispatcher fires the processor corresponding to the closest
       // matching rule and passes the context along
       Dispatcher disp = new DefaultRuleDispatcher(SkewJoinProcFactory
           .getDefaultProc(), opRulesskewJoinProcContext);
       GraphWalker ogw = new DefaultGraphWalker(disp);
 
       // iterator the reducer operator tree
       ArrayList<NodetopNodes = new ArrayList<Node>();
       topNodes.add(((MapredWorktask.getWork()).getReducer());
       ogw.startWalking(topNodesnull);
       return null;
     }
 
      return ;
    }
    public void setPhysicalContext(PhysicalContext physicalContext) {
      this. = physicalContext;
    }
  }

  
A container of current task and parse context.
  public static class SkewJoinProcCtx implements NodeProcessorCtx {
    private Task<? extends SerializablecurrentTask;
    private ParseContext parseCtx;
    public SkewJoinProcCtx(Task<? extends Serializabletask,
        ParseContext parseCtx) {
       = task;
      this. = parseCtx;
    }
    public Task<? extends SerializablegetCurrentTask() {
      return ;
    }
    public void setCurrentTask(Task<? extends SerializablecurrentTask) {
      this. = currentTask;
    }
    public ParseContext getParseCtx() {
      return ;
    }
    public void setParseCtx(ParseContext parseCtx) {
      this. = parseCtx;
    }
  }
New to GrepCode? Check out our FAQ X