private static BaseWork getBaseWork(Configuration conf, String name) {

    Path path = getPlanPath(conf, name);
    LOG.debug("PLAN PATH = {}", path);
    if (path == null) { // Map/reduce plan may not be generated
      return null;
    }

    BaseWork gWork = gWorkMap.get(conf).get(path);
    if (gWork != null) {
      LOG.debug("Found plan in cache for name: {}", name);
      return gWork;
    }

    InputStream in = null;
    Kryo kryo = SerializationUtilities.borrowKryo();
    try {
      String engine = HiveConf.getVar(conf, ConfVars.HIVE_EXECUTION_ENGINE);
      Path localPath = path;
      LOG.debug("local path = {}", localPath);
      final long serializedSize;
      final String planMode;
      if (HiveConf.getBoolVar(conf, ConfVars.HIVE_RPC_QUERY_PLAN)) {
        String planStringPath = path.toUri().getPath();
        LOG.debug("Loading plan from string: {}", planStringPath);
        String planString = conf.getRaw(planStringPath);
        if (planString == null) {
          LOG.info("Could not find plan string in conf");
          return null;
        }
        serializedSize = planString.length();
        planMode = "RPC";
        byte[] planBytes = Base64.getDecoder().decode(planString);
        in = new ByteArrayInputStream(planBytes);
        in = new InflaterInputStream(in);
      } else {
        LOG.debug("Open file to read in plan: {}", localPath);
        FileSystem fs = localPath.getFileSystem(conf);
        in = fs.open(localPath);
        serializedSize = fs.getFileStatus(localPath).getLen();
        planMode = "FILE";
      }

      if(MAP_PLAN_NAME.equals(name)){
        if (ExecMapper.class.getName().equals(conf.get(MAPRED_MAPPER_CLASS))){
          gWork = SerializationUtilities.deserializePlan(kryo, in, MapWork.class);
        } else if(MergeFileMapper.class.getName().equals(conf.get(MAPRED_MAPPER_CLASS))) {
          gWork = SerializationUtilities.deserializePlan(kryo, in, MergeFileWork.class);
        } else if(ColumnTruncateMapper.class.getName().equals(conf.get(MAPRED_MAPPER_CLASS))) {
          gWork = SerializationUtilities.deserializePlan(kryo, in, ColumnTruncateWork.class);
        } else {
          throw new RuntimeException("unable to determine work from configuration ."
              + MAPRED_MAPPER_CLASS + " was "+ conf.get(MAPRED_MAPPER_CLASS));
        }
      } else if (REDUCE_PLAN_NAME.equals(name)) {
        if(ExecReducer.class.getName().equals(conf.get(MAPRED_REDUCER_CLASS))) {
          gWork = SerializationUtilities.deserializePlan(kryo, in, ReduceWork.class);
        } else {
          throw new RuntimeException("unable to determine work from configuration ."
              + MAPRED_REDUCER_CLASS +" was "+ conf.get(MAPRED_REDUCER_CLASS));
        }
      } else if (name.contains(MERGE_PLAN_NAME)) {
        if (name.startsWith(MAPNAME)) {
          gWork = SerializationUtilities.deserializePlan(kryo, in, MapWork.class);
        } else if (name.startsWith(REDUCENAME)) {
          gWork = SerializationUtilities.deserializePlan(kryo, in, ReduceWork.class);
        } else {
          throw new RuntimeException("Unknown work type: " + name);
        }
      }
      LOG.info("Deserialized plan (via {}) - name: {} size: {}", planMode,
          gWork.getName(), humanReadableByteCount(serializedSize));
      gWorkMap.get(conf).put(path, gWork);
      return gWork;
    } catch (FileNotFoundException fnf) {
      // happens. e.g.: no reduce work.
      LOG.debug("No plan file found: {}", path, fnf);
      return null;
    } catch (Exception e) {
      String msg = "Failed to load plan: " + path;
      LOG.error(msg, e);
      throw new RuntimeException(msg, e);
    } finally {
      SerializationUtilities.releaseKryo(kryo);
      IOUtils.closeStream(in);
    }
  }
Returns the Map or Reduce plan
Side effect: the BaseWork returned is also placed in the gWorkMap
@param conf
@param name
@return BaseWork based on the name supplied will return null if name is null
@throws RuntimeException if the configuration files are not proper or if plan can not be loaded
ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java