org.apache.tinkerpop.gremlin.process.computer

## Interface Memory

- All Known Subinterfaces:
    Memory.Admin

      public interface Memory

  The Memory of a `GraphComputer` is a global data structure where by vertices can communicate information with one another. Moreover, it also contains global information about the state of the computation such as runtime and the current iteration. The Memory data is logically updated in parallel using associative/commutative methods which have embarrassingly parallel implementations.
  Author:
    Marko A. Rodriguez (http://markorodriguez.com)

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static interface` | `Memory.Admin` The Admin interface is used by the `GraphComputer` to update the Memory.
    `static class` | `Memory.Exceptions`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(String key, Object value)` Set the value of the provided key.
    `default Map<String,Object>` | `asMap()` A helper method that generates a `Map` of the memory key/values.
    `default boolean` | `exists(String key)` Whether the key exists in the memory.
    `<R> R` | `get(String key)` Get the value associated with the provided key.
    `int` | `getIteration()` Get the current iteration number.
    `long` | `getRuntime()` Get the amount of milliseconds the `GraphComputer` has been executing thus far.
    `default boolean` | `isInitialIteration()` A helper method that states whether the current iteration is 0.
    `Set<String>` | `keys()` The set of keys currently associated with this memory.
    `void` | `set(String key, Object value)`

- - ### Method Detail

    - #### exists

          default boolean exists(String key)

      Whether the key exists in the memory.
      Parameters:
        `key` - key to search the memory for.
      Returns:
        whether the key exists

    - #### keys

          Set<String> keys()

      The set of keys currently associated with this memory.
      Returns:
        the memory's key set.

    - #### get

          <R> R get(String key)
             throws IllegalArgumentException

      Get the value associated with the provided key.
      Type Parameters:
        `R` - the type of the value
      Parameters:
        `key` - the key of the value
      Returns:
        the value
      Throws:
        `IllegalArgumentException` - is thrown if the key does not exist

    - #### set

          void set(String key,
                   Object value)
            throws IllegalArgumentException,
                   IllegalStateException

      Throws:
        `IllegalArgumentException`
        `IllegalStateException`

    - #### add

          void add(String key,
                   Object value)
            throws IllegalArgumentException,
                   IllegalStateException

      Set the value of the provided key. This is typically called in setup() and/or terminate() of the `VertexProgram`. If this is called during execute(), there is no guarantee as to the ultimately stored value as call order is indeterminate.
      Parameters:
        `key` - they key to set a value for
        `value` - the value to set for the key
      Throws:
        `IllegalArgumentException`
        `IllegalStateException`

    - #### asMap

          default Map<String,Object> asMap()

      A helper method that generates a `Map` of the memory key/values.
      Returns:
        the map representation of the memory key/values

    - #### getIteration

          int getIteration()

      Get the current iteration number.
      Returns:
        the current iteration

    - #### getRuntime

          long getRuntime()

      Get the amount of milliseconds the `GraphComputer` has been executing thus far.
      Returns:
        the total time in milliseconds

    - #### isInitialIteration

          default boolean isInitialIteration()

      A helper method that states whether the current iteration is 0.
      Returns:
        whether this is the first iteration

Copyright © 2013–2018 Apache Software Foundation. All rights reserved.