public static Integer getMapMemoryMb(String javaOpts, Configuration conf) {
    """
	visible for testing (can't annotate as can't depend on Guava)
    """
    String[] javaOptsArray = javaOpts.split(" ");
    Integer upperLimitMemory = null;
    for (String opts : javaOptsArray) {
      if (opts.contains("-Xmx")) {
        Integer memoryMb = Integer.valueOf(opts.substring(4, opts.length() - 1));
        switch (opts.charAt(opts.length() - 1)) {
          case 'm':
          case 'M':
            break;
          case 'k':
          case 'K':
            memoryMb = memoryMb / (1024);
            break;
          case 'g':
          case 'G':
            memoryMb = memoryMb * 1024;
            break;
          default:
            memoryMb = Integer.valueOf(opts.substring(4, opts.length())) / (1024 * 1024);
            break;
        }
        // Add 25% to Java heap as MAP_MEMORY_MB is the total physical memory for the map task
        upperLimitMemory = ((int) (memoryMb * 0.25)) + memoryMb;
        // dont break as there could be multiple -Xmx, we need to honor the last
      }
    }
    if (upperLimitMemory != null) {
      String defaultMapMemoryString = conf.get(MAPREDUCE_MAP_MEMORY_MB);
      if (defaultMapMemoryString != null) {
        Integer defaultMapMemory = Integer.valueOf(defaultMapMemoryString);
        upperLimitMemory = (upperLimitMemory > defaultMapMemory ? upperLimitMemory : defaultMapMemory);
      }
    }
    return upperLimitMemory;
  }
public static Integer getMapMemoryMb(String javaOpts, Configuration conf) {
    String[] javaOptsArray = javaOpts.split(" ");
    Integer upperLimitMemory = null;
    for (String opts : javaOptsArray) {
      if (opts.contains("-Xmx")) {
        Integer memoryMb = Integer.valueOf(opts.substring(4, opts.length() - 1));
        switch (opts.charAt(opts.length() - 1)) {
          case 'm':
          case 'M':
            break;
          case 'k':
          case 'K':
            memoryMb = memoryMb / (1024);
            break;
          case 'g':
          case 'G':
            memoryMb = memoryMb * 1024;
            break;
          default:
            memoryMb = Integer.valueOf(opts.substring(4, opts.length())) / (1024 * 1024);
            break;
        }
        // Add 25% to Java heap as MAP_MEMORY_MB is the total physical memory for the map task
        upperLimitMemory = ((int) (memoryMb * 0.25)) + memoryMb;
        // dont break as there could be multiple -Xmx, we need to honor the last
      }
    }
    if (upperLimitMemory != null) {
      String defaultMapMemoryString = conf.get(MAPREDUCE_MAP_MEMORY_MB);
      if (defaultMapMemoryString != null) {
        Integer defaultMapMemory = Integer.valueOf(defaultMapMemoryString);
        upperLimitMemory = (upperLimitMemory > defaultMapMemory ? upperLimitMemory : defaultMapMemory);
      }
    }
    return upperLimitMemory;
  }
public static Integer getMapMemoryMb ( String javaOpts , Configuration conf ) { String [ ] javaOptsArray = javaOpts . split ( " " ) ; Integer upperLimitMemory = null ; for ( String opts : javaOptsArray ) { if ( opts . contains ( "-Xmx" ) ) { Integer memoryMb = Integer . valueOf ( opts . substring ( 4 , opts . length ( ) - 1 ) ) ; switch ( opts . charAt ( opts . length ( ) - 1 ) ) { case ' ' : case ' ' : break ; case ' ' : case ' ' : memoryMb = memoryMb / ( 1024 ) ; break ; case ' ' : case ' ' : memoryMb = memoryMb * 1024 ; break ; default : memoryMb = Integer . valueOf ( opts . substring ( 4 , opts . length ( ) ) ) / ( 1024 * 1024 ) ; break ; } // Add 25% to Java heap as MAP_MEMORY_MB is the total physical memory for the map task upperLimitMemory = ( ( int ) ( memoryMb * 0.25 ) ) + memoryMb ; // dont break as there could be multiple -Xmx, we need to honor the last } } if ( upperLimitMemory != null ) { String defaultMapMemoryString = conf . get ( MAPREDUCE_MAP_MEMORY_MB ) ; if ( defaultMapMemoryString != null ) { Integer defaultMapMemory = Integer . valueOf ( defaultMapMemoryString ) ; upperLimitMemory = ( upperLimitMemory > defaultMapMemory ? upperLimitMemory : defaultMapMemory ) ; } } return upperLimitMemory ; }
visible for testing (can't annotate as can't depend on Guava)
visible for testing ( can t annotate as can t depend on Guava )