Github user paul-rogers commented on a diff in the pull request:

    https://github.com/apache/drill/pull/868#discussion_r130187202
  
    --- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/server/options/TypeValidators.java
 ---
    @@ -217,19 +236,52 @@ public void validate(final OptionValue v, final 
OptionSet manager) {
         }
       }
     
    +  /** Max width is a special validator which computes and validates
    +   *  the maxwidth. If the maxwidth is already set in system/session
    +   * the value is returned or else it is computed dynamically based on
    +   * the available number of processors and cpu load average
    +   */
    +  public static class MaxWidthValidator extends TypeValidator{
    +
    +    public MaxWidthValidator(String name) {
    +      this(name, false);
    +    }
    +
    +    public MaxWidthValidator(String name, boolean isAdminOption) {
    +      super(name, Kind.LONG, isAdminOption);
    +    }
    +
    +    public void loadDefault(DrillConfig bootConfig) {
    +      OptionValue value = OptionValue.createLong(OptionType.SYSTEM, 
getOptionName(), bootConfig.getLong(getConfigProperty()), OptionScope.BOOT);
    +      setDefaultValue(value);
    +    }
    +
    +    public int computeMaxWidth(double cpuLoadAverage, long maxWidth) {
    +      // if maxwidth is already set return it
    +      if (maxWidth != 0) {
    +        return (int) maxWidth;
    +      }
    +      // else compute the value and return
    +      else {
    +        int maxWidthPerNode;
    +        int availProc = Runtime.getRuntime().availableProcessors();
    +        maxWidthPerNode = (int) Math.max(1, Math.min(availProc, 
Math.round(availProc * cpuLoadAverage)));
    --- End diff --
    
    `int maxWidthPerNode = ...`
    or even just
    `return (int) ...`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to