Package org.apache.storm.scheduler.resource.normalization

## Class ResourceMapArrayBridge

- java.lang.Object
- - org.apache.storm.scheduler.resource.normalization.ResourceMapArrayBridge

-     public class ResourceMapArrayBridge
      extends Object

  Provides translation between normalized resource maps and resource value arrays. Some operations use resource value arrays instead of the full normalized resource map as an optimization. See `NormalizedResources`.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ResourceMapArrayBridge()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `double[]` | `empty()` | Create an array that has all values 0.
    `Map<String,​Integer>` | `getResourceNamesToArrayIndex()` |
    `Map<String,​Double>` | `translateFromResourceArray​(double[] resources)` | Translates an array of resource values to a normalized resource map.
    `double[]` | `translateToResourceArray​(Map<String,​Double> normalizedResources)` | Translates a normalized resource map to an array of resource values.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ResourceMapArrayBridge

          public ResourceMapArrayBridge()

  - ### Method Detail

    - #### translateToResourceArray

          public double[] translateToResourceArray​(Map<String,​Double> normalizedResources)

      Translates a normalized resource map to an array of resource values. Each resource name will be assigned an index in the array, which is guaranteed to be consistent with subsequent invocations of this method. Note that CPU and memory resources are not translated by this method, as they are expected to be captured elsewhere.
      Parameters:
        `normalizedResources` - The resources to translate to an array
      Returns:
        The array of resource values

    - #### empty

          public double[] empty()

      Create an array that has all values 0.
      Returns:
        the empty array.

    - #### translateFromResourceArray

          public Map<String,​Double> translateFromResourceArray​(double[] resources)

      Translates an array of resource values to a normalized resource map.
      Parameters:
        `resources` - The resource array to translate
      Returns:
        The normalized resource map

    - #### getResourceNamesToArrayIndex

          public Map<String,​Integer> getResourceNamesToArrayIndex()