static double adjustMemoryReserveFraction(long memoryRequested, HiveConf conf) {
    // User specified fraction always takes precedence
    if (conf.getFloatVar(ConfVars.TEZ_TASK_SCALE_MEMORY_RESERVE_FRACTION) > 0) {
      return conf.getFloatVar(ConfVars.TEZ_TASK_SCALE_MEMORY_RESERVE_FRACTION);
    }

    float tezHeapFraction = conf.getFloatVar(ConfVars.TEZ_CONTAINER_MAX_JAVA_HEAP_FRACTION);
    float tezMinReserveFraction = conf.getFloatVar(ConfVars.TEZ_TASK_SCALE_MEMORY_RESERVE_FRACTION_MIN);
    float tezMaxReserveFraction = conf.getFloatVar(ConfVars.TEZ_TASK_SCALE_MEMORY_RESERVE_FRACTION_MAX);

    Resource resource = getContainerResource(conf);
    long containerSize = (long) resource.getMemory() * 1024 * 1024;
    String javaOpts = getContainerJavaOpts(conf);
    long xmx = parseRightmostXmx(javaOpts);

    if (xmx <= 0) {
      xmx = (long) (tezHeapFraction * containerSize);
    }

    long actualMemToBeAllocated = (long) (tezMinReserveFraction * xmx);

    if (actualMemToBeAllocated < memoryRequested) {
      LOG.warn("The actual amount of memory to be allocated " + actualMemToBeAllocated +
          " is less than the amount of requested memory for Map Join conversion " + memoryRequested);
      float frac = (float) memoryRequested / xmx;
      LOG.info("Fraction after calculation: " + frac);
      if (frac <= tezMinReserveFraction) {
        return tezMinReserveFraction;
      } else if (frac > tezMinReserveFraction && frac < tezMaxReserveFraction) {
        LOG.info("Will adjust Tez setting " + TezConfiguration.TEZ_TASK_SCALE_MEMORY_RESERVE_FRACTION +
            " to " + frac + " to allocate more memory");
        return frac;
      } else {  // frac >= tezMaxReserveFraction
        return tezMaxReserveFraction;
      }
    }

    return tezMinReserveFraction;  // the default fraction
  }
TODO This method is temporary. Ideally Hive should only need to pass to Tez the amount of memory
     it requires to do the map join, and Tez should take care of figuring out how much to allocate
Adjust the percentage of memory to be reserved for the processor from Tez
based on the actual requested memory by the Map Join, i.e. HIVE_CONVERT_JOIN_NOCONDITIONAL_TASK_THRESHOLD
@return the adjusted percentage
ql/src/java/org/apache/hadoop/hive/ql/exec/tez/DagUtils.java