public class DefaultTraversalSideEffects extends Object implements TraversalSideEffects
TraversalSideEffects.Exceptions
Modifier and Type | Field and Description |
---|---|
protected Map<String,Object> |
objectMap |
protected Supplier |
sackInitialValue |
protected UnaryOperator |
sackSplitOperator |
protected Map<String,Supplier> |
supplierMap |
SIDE_EFFECTS
Constructor and Description |
---|
DefaultTraversalSideEffects() |
Modifier and Type | Method and Description |
---|---|
DefaultTraversalSideEffects |
clone()
Cloning is used to duplicate the sideEffects typically in OLAP environments.
|
<V> Optional<V> |
get(String key)
Get the sideEffect associated with the provided key.
|
<V> V |
getOrCreate(String key,
Supplier<V> orCreate)
If the sideEffect contains an object associated with the key, return it.
|
<V> Optional<Supplier<V>> |
getRegisteredSupplier(String key)
Get the registered
Supplier associated with the specified key. |
<S> Optional<Supplier<S>> |
getSackInitialValue()
If sacks are enabled, get the initial value of the
Traverser sack. |
<S> Optional<UnaryOperator<S>> |
getSackSplitOperator()
If sacks are enabled and a split operator has been specified, then get it.
|
Set<String> |
keys()
The keys of the sideEffect which includes registered
Supplier keys. |
void |
mergeInto(TraversalSideEffects sideEffects)
Add the current
TraversalSideEffects data and suppliers to the provided TraversalSideEffects . |
void |
registerSupplier(String key,
Supplier supplier)
Register a
Supplier with the provided key. |
void |
registerSupplierIfAbsent(String key,
Supplier supplier)
A helper method to register a
Supplier if it has not already been registered. |
void |
remove(String key)
Remove both the value and registered
Supplier associated with provided key. |
void |
set(String key,
Object value)
Set the specified key to the specified value.
|
void |
setLocalVertex(Vertex vertex)
In a distributed
GraphComputer traversal, the sideEffects of the traversal are not a single object within a single JVM. |
<S> void |
setSack(Supplier<S> initialValue,
Optional<UnaryOperator<S>> splitOperator)
Set the initial value of each
Traverser "sack" along with the operator for splitting sacks. |
String |
toString() |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach
protected UnaryOperator sackSplitOperator
protected Supplier sackInitialValue
public void registerSupplier(String key, Supplier supplier)
Supplier
with the provided key.
When sideEffects get() are called, if no object exists and there exists a registered supplier for the key, the object is generated.
Registered suppliers are used for the lazy generation of sideEffect data.registerSupplier
in interface TraversalSideEffects
key
- the key to register the supplier withsupplier
- the supplier that will generate an object when get() is called if it hasn't already been createdpublic <V> Optional<Supplier<V>> getRegisteredSupplier(String key)
Supplier
associated with the specified key.getRegisteredSupplier
in interface TraversalSideEffects
V
- The object type of the supplierkey
- the key associated with the supplierpublic void registerSupplierIfAbsent(String key, Supplier supplier)
Supplier
if it has not already been registered.registerSupplierIfAbsent
in interface TraversalSideEffects
key
- the key of the supplier to registersupplier
- the supplier to register if the key has not already been registeredpublic <S> void setSack(Supplier<S> initialValue, Optional<UnaryOperator<S>> splitOperator)
TraversalSideEffects
Traverser
"sack" along with the operator for splitting sacks.
If no operator is provided, then a direct memory copy is assumed (this is typically good for primitive types and strings).setSack
in interface TraversalSideEffects
S
- the sack typeinitialValue
- the initial value supplier of the traverser sacksplitOperator
- the split operator for splitting traverser sackspublic <S> Optional<Supplier<S>> getSackInitialValue()
TraversalSideEffects
Traverser
sack.getSackInitialValue
in interface TraversalSideEffects
S
- the sack typepublic <S> Optional<UnaryOperator<S>> getSackSplitOperator()
TraversalSideEffects
Traverser
happens.getSackSplitOperator
in interface TraversalSideEffects
S
- the sack typepublic void set(String key, Object value)
Supplier
is provided, it is NOT assumed to be a supplier as set by registerSupplier().set
in interface TraversalSideEffects
key
- the keyvalue
- the valuepublic <V> Optional<V> get(String key) throws IllegalArgumentException
Optional
.
Else if the sideEffect has a registered Supplier
for that key, generate the object, store the object in the sideEffects, and return it.get
in interface TraversalSideEffects
V
- the type of the value to retrievekey
- the key to get the value forIllegalArgumentException
- if the key does not reference an object or a registered supplier.public <V> V getOrCreate(String key, Supplier<V> orCreate)
Supplier
.getOrCreate
in interface TraversalSideEffects
V
- the return type of the objectkey
- the key of the object to getorCreate
- if the object doesn't exist as an object or suppliable object, then generate it with the specified supplierpublic void remove(String key)
Supplier
associated with provided key.remove
in interface TraversalSideEffects
key
- the key of the value and registered supplier to removepublic Set<String> keys()
Supplier
keys.
In essence, that which is possible to get().keys
in interface TraversalSideEffects
public void setLocalVertex(Vertex vertex)
GraphComputer
traversal, the sideEffects of the traversal are not a single object within a single JVM.
Instead, the sideEffects are distributed across the graph and the pieces are stored on the computing vertices.
This method is necessary to call when the Traversal
is processing the Traverser
s at a particular Vertex
.setLocalVertex
in interface TraversalSideEffects
vertex
- the vertex where the traversal is currently executing.public void mergeInto(TraversalSideEffects sideEffects)
TraversalSideEffects
TraversalSideEffects
data and suppliers to the provided TraversalSideEffects
.mergeInto
in interface TraversalSideEffects
sideEffects
- the sideEffects to add this traversal's sideEffect data to.public DefaultTraversalSideEffects clone()
TraversalSideEffects
clone
in interface TraversalSideEffects
clone
in class Object
Copyright © 2013–2015 Apache Software Foundation. All rights reserved.