public final class TraverserMapReduce extends StaticMapReduce<Comparable,Traverser<?>,Comparable,Traverser<?>,Iterator<Traverser<?>>>
MapReduce.MapEmitter<K,V>, MapReduce.NullObject, MapReduce.ReduceEmitter<OK,OV>, MapReduce.Stage
Modifier and Type | Field and Description |
---|---|
static String |
TRAVERSERS |
MAP_REDUCE
Constructor and Description |
---|
TraverserMapReduce(Traversal.Admin<?,?> traversal) |
Modifier and Type | Method and Description |
---|---|
void |
combine(Comparable comparable,
Iterator<Traverser<?>> values,
MapReduce.ReduceEmitter<Comparable,Traverser<?>> emitter)
The combine() method is logically executed at all "machines" in parallel.
|
boolean |
doStage(MapReduce.Stage stage)
A MapReduce job can be map-only, map-reduce-only, or map-combine-reduce.
|
Iterator<Traverser<?>> |
generateFinalResult(Iterator<KeyValue<Comparable,Traverser<?>>> keyValues)
The key/value pairs emitted by reduce() (or map() in a map-only job) can be iterated to generate a local JVM Java object.
|
Optional<Comparator<Comparable>> |
getMapKeySort()
If a
Comparator is provided, then all pairs leaving the MapReduce.MapEmitter are sorted. |
String |
getMemoryKey()
The results of the MapReduce job are associated with a memory-key to ultimately be stored in
Memory . |
void |
loadState(Graph graph,
Configuration configuration)
When it is necessary to load the state of a MapReduce job, this method is called.
|
void |
map(Vertex vertex,
MapReduce.MapEmitter<Comparable,Traverser<?>> emitter)
The map() method is logically executed at all vertices in the graph in parallel.
|
void |
reduce(Comparable comparable,
Iterator<Traverser<?>> values,
MapReduce.ReduceEmitter<Comparable,Traverser<?>> emitter)
The reduce() method is logically on the "machine" the respective key hashes to.
|
clone, equals, hashCode, storeState, toString
finalize, getClass, notify, notifyAll, wait, wait, wait
addResultToMemory, createMapReduce, getReduceKeySort, workerEnd, workerStart
public static final String TRAVERSERS
public TraverserMapReduce(Traversal.Admin<?,?> traversal)
public void loadState(Graph graph, Configuration configuration)
MapReduce
graph
- the graph the MapReduce job will run againstconfiguration
- the configuration to load the state of the MapReduce job from.public boolean doStage(MapReduce.Stage stage)
MapReduce
stage
- the stage to check for definition.public void map(Vertex vertex, MapReduce.MapEmitter<Comparable,Traverser<?>> emitter)
MapReduce
vertex
- the current vertex being map() processed.emitter
- the component that allows for key/value pairs to be emitted to the next stage.public Optional<Comparator<Comparable>> getMapKeySort()
MapReduce
Comparator
is provided, then all pairs leaving the MapReduce.MapEmitter
are sorted.
The sorted results are either fed sorted to the combine/reduce-stage or as the final output.
If sorting is not required, then Optional.empty()
should be returned as sorting is computationally expensive.
The default implementation returns Optional.empty()
.Optional
of a comparator for sorting the map output.public void combine(Comparable comparable, Iterator<Traverser<?>> values, MapReduce.ReduceEmitter<Comparable,Traverser<?>> emitter)
MapReduce
comparable
- the key that has aggregated valuesvalues
- the aggregated values associated with the keyemitter
- the component that allows for key/value pairs to be emitted to the reduce stage.public void reduce(Comparable comparable, Iterator<Traverser<?>> values, MapReduce.ReduceEmitter<Comparable,Traverser<?>> emitter)
MapReduce
comparable
- the key that has aggregated valuesvalues
- the aggregated values associated with the keyemitter
- the component that allows for key/value pairs to be emitted as the final result.public Iterator<Traverser<?>> generateFinalResult(Iterator<KeyValue<Comparable,Traverser<?>>> keyValues)
MapReduce
keyValues
- the key/value pairs that were emitted from reduce() (or map() in a map-only job)Copyright © 2013–2015 Apache Software Foundation. All rights reserved.