All Known Subinterfaces:
Memory.Admin
All Known Implementing Classes:
EmptyMemory, ImmutableMemory, MapMemory, TinkerMemory, TinkerWorkerMemory

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
    Description
    static interface 
    The Admin interface is used by the GraphComputer to update the Memory.
    static class 
     
  • Method Summary

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

    • 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

      Throws:
      IllegalArgumentException
      IllegalStateException
    • add

      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. It is up to the implementation to determine the states in which this method can be called.
      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