org.apache.tinkerpop.gremlin.process.computer

## Class GraphComputerTest.MapReduceB

- java.lang.Object
- - org.apache.tinkerpop.gremlin.process.computer.util.StaticMapReduce<Integer,Integer,Integer,Integer,List<Integer>>
  - - org.apache.tinkerpop.gremlin.process.computer.GraphComputerTest.MapReduceB

- All Implemented Interfaces:
    Cloneable, MapReduce<Integer,Integer,Integer,Integer,List<Integer>>
  Enclosing class:
    GraphComputerTest

      public static class GraphComputerTest.MapReduceB
      extends StaticMapReduce<Integer,Integer,Integer,Integer,List<Integer>>

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.apache.tinkerpop.gremlin.process.computer.MapReduce

      `MapReduce.MapEmitter<K,V>, MapReduce.NullObject, MapReduce.ReduceEmitter<OK,OV>, MapReduce.Stage`

  - ### Field Summary

    - ### Fields inherited from interface org.apache.tinkerpop.gremlin.process.computer.MapReduce

      `MAP_REDUCE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MapReduceB()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `doStage(MapReduce.Stage stage)` A MapReduce job can be map-only, map-reduce-only, or map-combine-reduce.
    `List<Integer>` | `generateFinalResult(Iterator<KeyValue<Integer,Integer>> 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.
    `String` | `getMemoryKey()` The results of the MapReduce job are associated with a memory-key to ultimately be stored in `Memory`.
    `Optional<Comparator<Integer>>` | `getReduceKeySort()` If a `Comparator` is provided, then all pairs leaving the `MapReduce.ReduceEmitter` are sorted.
    `void` | `map(Vertex vertex, MapReduce.MapEmitter<Integer,Integer> emitter)` The map() method is logically executed at all vertices in the graph in parallel.
    `void` | `reduce(Integer key, Iterator<Integer> values, MapReduce.ReduceEmitter<Integer,Integer> emitter)` The reduce() method is logically on the "machine" the respective key hashes to.

    - ### Methods inherited from class org.apache.tinkerpop.gremlin.process.computer.util.StaticMapReduce

      `clone, equals, hashCode, storeState, toString`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.apache.tinkerpop.gremlin.process.computer.MapReduce

      `addResultToMemory, combine, createMapReduce, getMapKeySort, loadState, workerEnd, workerStart`

- - ### Constructor Detail

    - #### MapReduceB

          public MapReduceB()

  - ### Method Detail

    - #### doStage

          public boolean doStage(MapReduce.Stage stage)

      Description copied from interface: `MapReduce`
      A MapReduce job can be map-only, map-reduce-only, or map-combine-reduce. Before executing the particular stage, this method is called to determine if the respective stage is defined. This method should return true if the respective stage as a non-default method implementation.
      Parameters:
        `stage` - the stage to check for definition.
      Returns:
        whether that stage should be executed.

    - #### map

          public void map(Vertex vertex,
                          MapReduce.MapEmitter<Integer,Integer> emitter)

      Description copied from interface: `MapReduce`
      The map() method is logically executed at all vertices in the graph in parallel. The map() method emits key/value pairs given some analysis of the data in the vertices (and/or its incident edges). All `MapReduce` classes must at least provide an implementation of `MapReduce#map(Vertex, MapEmitter)`.
      Parameters:
        `vertex` - the current vertex being map() processed.
        `emitter` - the component that allows for key/value pairs to be emitted to the next stage.

    - #### reduce

          public void reduce(Integer key,
                             Iterator<Integer> values,
                             MapReduce.ReduceEmitter<Integer,Integer> emitter)

      Description copied from interface: `MapReduce`
      The reduce() method is logically on the "machine" the respective key hashes to. The reduce() method combines all the values associated with the key and emits key/value pairs.
      Parameters:
        `key` - the key that has aggregated values
        `values` - the aggregated values associated with the key
        `emitter` - the component that allows for key/value pairs to be emitted as the final result.

    - #### getReduceKeySort

          public Optional<Comparator<Integer>> getReduceKeySort()

      Description copied from interface: `MapReduce`
      If a `Comparator` is provided, then all pairs leaving the `MapReduce.ReduceEmitter` are sorted. If sorting is not required, then `Optional.empty()` should be returned as sorting is computationally expensive. The default implementation returns `Optional.empty()`.
      Returns:
        an `Optional` of a comparator for sorting the reduce output.

    - #### getMemoryKey

          public String getMemoryKey()

      Description copied from interface: `MapReduce`
      The results of the MapReduce job are associated with a memory-key to ultimately be stored in `Memory`.
      Returns:
        the memory key of the generated result object.

    - #### generateFinalResult

          public List<Integer> generateFinalResult(Iterator<KeyValue<Integer,Integer>> keyValues)

      Description copied from interface: `MapReduce`
      The key/value pairs emitted by reduce() (or map() in a map-only job) can be iterated to generate a local JVM Java object.
      Parameters:
        `keyValues` - the key/value pairs that were emitted from reduce() (or map() in a map-only job)
      Returns:
        the resultant object formed from the emitted key/values.

Copyright © 2013–2020 Apache Software Foundation. All rights reserved.