Interface Memory
- 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 ClassesModifier and TypeInterfaceDescriptionstatic interfaceThe Admin interface is used by theGraphComputerto update the Memory.static class -
Method Summary
Modifier and TypeMethodDescriptionvoidSet the value of the provided key.asMap()A helper method that generates aMapof the memory key/values.default booleanWhether the key exists in the memory.<R> RGet the value associated with the provided key.intGet the current iteration number.longGet the amount of milliseconds theGraphComputerhas been executing thus far.default booleanA helper method that states whether the current iteration is 0.keys()The set of keys currently associated with this memory.void
-
Method Details
-
exists
Whether the key exists in the memory.- Parameters:
key- key to search the memory for.- Returns:
- whether the key exists
-
keys
The set of keys currently associated with this memory.- Returns:
- the memory's key set.
-
get
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
-
add
Set the value of the provided key. This is typically called in setup() and/or terminate() of theVertexProgram. 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 forvalue- the value to set for the key- Throws:
IllegalArgumentExceptionIllegalStateException
-
asMap
A helper method that generates aMapof 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 theGraphComputerhas 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
-