T
- The type of the vertex to be observed.S
- The type of the class implementing VertexAggregatorpublic interface VertexAggregator<T extends Vertex,S extends VertexAggregator<T,S>>
extends java.io.Serializable
VertexSelection.aggregate(SerializableSupplier)
parameter for VertexSelection
selections.
An VertexAggregator is given zero or more observations of vertices, which it can use to update an internal state. These states are then merged together to form the final state of the aggregator. Although aggregators are created and merged in parallel, the actual implementation of an VertexAggregator does not need to be threadsafe.
The second type parameter argument should be the type of the implementing class, for example:
class MyAggregator implements VertexAggregator<MyVertex, MyAggregator> {
// ...
}
Modifier and Type | Method and Description |
---|---|
void |
merge(S other)
Given another aggregator of the same type, modify this aggregator's internal state to be the
combination of the two.
|
void |
observe(T vertex)
Take an observation of a single vertex of type
T . |
void observe(T vertex)
T
. The aggregator should modify its
state in response to the observation.
For example, a summing aggregator would add 1 to an internal count field.
vertex
- An vertex instance.void merge(S other)
For example, a summing aggregator would add the count contained in to this instance.
other
- Another aggregator instance of the same type, to merge into this instance.