Interface Memory
-
- All Known Subinterfaces:
Memory.Admin
public interface Memory
The Memory of aGraphComputer
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
Memory.Admin
The Admin interface is used by theGraphComputer
to update the Memory.static class
Memory.Exceptions
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
add(String key, Object value)
Set the value of the provided key.default Map<String,Object>
asMap()
A helper method that generates aMap
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 theGraphComputer
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
-
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 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:
IllegalArgumentException
IllegalStateException
-
asMap
default Map<String,Object> asMap()
A helper method that generates aMap
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 theGraphComputer
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
-
-