Class AbstractComputation<OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable,​EDATA_T extends org.apache.hadoop.io.Writable,​IN_MSG_T extends org.apache.hadoop.io.Writable,​OUT_MSG_T extends org.apache.hadoop.io.Writable>

  • Type Parameters:
    OID_T - original vertex id.
    VDATA_T - vertex data type.
    EDATA_T - edata type.
    IN_MSG_T - incoming msg type.
    OUT_MSG_T - outgoing msg type.
    All Implemented Interfaces:
    org.apache.giraph.aggregators.AggregatorUsage, org.apache.giraph.conf.GiraphConfigurationSettable<OID_T,​VDATA_T,​EDATA_T>, org.apache.giraph.conf.ImmutableClassesGiraphConfigurable<OID_T,​VDATA_T,​EDATA_T>, org.apache.giraph.conf.TypesHolder<OID_T,​VDATA_T,​EDATA_T,​IN_MSG_T,​OUT_MSG_T>, org.apache.giraph.graph.Computation<OID_T,​VDATA_T,​EDATA_T,​IN_MSG_T,​OUT_MSG_T>, org.apache.giraph.worker.WorkerAggregatorUsage, org.apache.giraph.worker.WorkerBroadcastUsage, org.apache.giraph.worker.WorkerGlobalCommUsage, org.apache.giraph.worker.WorkerIndexUsage<OID_T>, org.apache.giraph.worker.WorkerReduceUsage
    Direct Known Subclasses:
    org.apache.giraph.graph.BasicComputation

    public abstract class AbstractComputation<OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable,​EDATA_T extends org.apache.hadoop.io.Writable,​IN_MSG_T extends org.apache.hadoop.io.Writable,​OUT_MSG_T extends org.apache.hadoop.io.Writable>
    extends WorkerAggregatorDelegator<OID_T,​VDATA_T,​EDATA_T>
    implements org.apache.giraph.graph.Computation<OID_T,​VDATA_T,​EDATA_T,​IN_MSG_T,​OUT_MSG_T>
    Implement all methods in Computation other than compute, which left for user to define.
    • Constructor Detail

      • AbstractComputation

        public AbstractComputation()
    • Method Detail

      • setFragment

        public void setFragment​(IFragment fragment)
      • incStep

        public void incStep()
        Called by our framework after each super step.
      • preSuperstep

        public void preSuperstep()
        Prepare for computation. This method is executed exactly once prior to Computation.compute(Vertex, Iterable) being called for any of the vertices in the partition.
        Specified by:
        preSuperstep in interface org.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable,​EDATA_T extends org.apache.hadoop.io.Writable,​IN_MSG_T extends org.apache.hadoop.io.Writable,​OUT_MSG_T extends org.apache.hadoop.io.Writable>
      • postSuperstep

        public void postSuperstep()
        Finish computation. This method is executed exactly once after computation for all vertices in the partition is complete.
        Specified by:
        postSuperstep in interface org.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable,​EDATA_T extends org.apache.hadoop.io.Writable,​IN_MSG_T extends org.apache.hadoop.io.Writable,​OUT_MSG_T extends org.apache.hadoop.io.Writable>
      • getSuperstep

        public long getSuperstep()
        Retrieves the current superstep.
        Specified by:
        getSuperstep in interface org.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable,​EDATA_T extends org.apache.hadoop.io.Writable,​IN_MSG_T extends org.apache.hadoop.io.Writable,​OUT_MSG_T extends org.apache.hadoop.io.Writable>
        Returns:
        Current superstep
      • getTotalNumVertices

        public long getTotalNumVertices()
        Get the total (all workers) number of vertices that existed in the previous superstep.
        Specified by:
        getTotalNumVertices in interface org.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable,​EDATA_T extends org.apache.hadoop.io.Writable,​IN_MSG_T extends org.apache.hadoop.io.Writable,​OUT_MSG_T extends org.apache.hadoop.io.Writable>
        Returns:
        Total number of vertices (-1 if first superstep)
      • getTotalNumEdges

        public long getTotalNumEdges()
        Get the total (all workers) number of edges that existed in the previous superstep.
        Specified by:
        getTotalNumEdges in interface org.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable,​EDATA_T extends org.apache.hadoop.io.Writable,​IN_MSG_T extends org.apache.hadoop.io.Writable,​OUT_MSG_T extends org.apache.hadoop.io.Writable>
        Returns:
        Total number of edges (-1 if first superstep)
      • getContext

        public org.apache.hadoop.mapreduce.Mapper.Context getContext()
        Get the mapper context
        Specified by:
        getContext in interface org.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable,​EDATA_T extends org.apache.hadoop.io.Writable,​IN_MSG_T extends org.apache.hadoop.io.Writable,​OUT_MSG_T extends org.apache.hadoop.io.Writable>
        Returns:
        Mapper context
      • getWorkerContext

        public WorkerContext getWorkerContext()
        Get the worker context
        Specified by:
        getWorkerContext in interface org.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable,​EDATA_T extends org.apache.hadoop.io.Writable,​IN_MSG_T extends org.apache.hadoop.io.Writable,​OUT_MSG_T extends org.apache.hadoop.io.Writable>
        Returns:
        WorkerContext context
      • setWorkerContext

        public void setWorkerContext​(WorkerContext workerContext)
      • addVertexRequest

        public void addVertexRequest​(OID_T id,
                                     VDATA_T value,
                                     org.apache.giraph.edge.OutEdges<OID_T,​EDATA_T> edges)
                              throws IOException
        Specified by:
        addVertexRequest in interface org.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable,​EDATA_T extends org.apache.hadoop.io.Writable,​IN_MSG_T extends org.apache.hadoop.io.Writable,​OUT_MSG_T extends org.apache.hadoop.io.Writable>
        Throws:
        IOException
      • addVertexRequest

        public void addVertexRequest​(OID_T id,
                                     VDATA_T value)
                              throws IOException
        Specified by:
        addVertexRequest in interface org.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable,​EDATA_T extends org.apache.hadoop.io.Writable,​IN_MSG_T extends org.apache.hadoop.io.Writable,​OUT_MSG_T extends org.apache.hadoop.io.Writable>
        Throws:
        IOException
      • removeVertexRequest

        public void removeVertexRequest​(OID_T vertexId)
                                 throws IOException
        Specified by:
        removeVertexRequest in interface org.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable,​EDATA_T extends org.apache.hadoop.io.Writable,​IN_MSG_T extends org.apache.hadoop.io.Writable,​OUT_MSG_T extends org.apache.hadoop.io.Writable>
        Throws:
        IOException
      • addEdgeRequest

        public void addEdgeRequest​(OID_T sourceVertexId,
                                   org.apache.giraph.edge.Edge<OID_T,​EDATA_T> edge)
                            throws IOException
        Specified by:
        addEdgeRequest in interface org.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable,​EDATA_T extends org.apache.hadoop.io.Writable,​IN_MSG_T extends org.apache.hadoop.io.Writable,​OUT_MSG_T extends org.apache.hadoop.io.Writable>
        Throws:
        IOException
      • removeEdgesRequest

        public void removeEdgesRequest​(OID_T sourceVertexId,
                                       OID_T targetVertexId)
                                throws IOException
        Specified by:
        removeEdgesRequest in interface org.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable,​EDATA_T extends org.apache.hadoop.io.Writable,​IN_MSG_T extends org.apache.hadoop.io.Writable,​OUT_MSG_T extends org.apache.hadoop.io.Writable>
        Throws:
        IOException
      • sendMessage

        public void sendMessage​(OID_T id,
                                OUT_MSG_T message)
        Specified by:
        sendMessage in interface org.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable,​EDATA_T extends org.apache.hadoop.io.Writable,​IN_MSG_T extends org.apache.hadoop.io.Writable,​OUT_MSG_T extends org.apache.hadoop.io.Writable>
      • sendMessageToAllEdges

        public void sendMessageToAllEdges​(org.apache.giraph.graph.Vertex<OID_T,​VDATA_T,​EDATA_T> vertex,
                                          OUT_MSG_T message)
        Specified by:
        sendMessageToAllEdges in interface org.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable,​EDATA_T extends org.apache.hadoop.io.Writable,​IN_MSG_T extends org.apache.hadoop.io.Writable,​OUT_MSG_T extends org.apache.hadoop.io.Writable>
      • sendMessageToMultipleEdges

        public void sendMessageToMultipleEdges​(Iterator<OID_T> vertexIdIterator,
                                               OUT_MSG_T message)
        Specified by:
        sendMessageToMultipleEdges in interface org.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable,​EDATA_T extends org.apache.hadoop.io.Writable,​IN_MSG_T extends org.apache.hadoop.io.Writable,​OUT_MSG_T extends org.apache.hadoop.io.Writable>
      • getWorkerCount

        public int getWorkerCount()
        Get number of workers
        Specified by:
        getWorkerCount in interface org.apache.giraph.worker.WorkerIndexUsage<OID_T extends org.apache.hadoop.io.WritableComparable>
        Returns:
        Number of workers
      • getMyWorkerIndex

        public int getMyWorkerIndex()
        Get index for this worker
        Specified by:
        getMyWorkerIndex in interface org.apache.giraph.worker.WorkerIndexUsage<OID_T extends org.apache.hadoop.io.WritableComparable>
        Returns:
        Index of this worker
      • getWorkerForVertex

        public int getWorkerForVertex​(OID_T vertexId)
        Get worker index which will contain vertex with given id, if such vertex exists.
        Specified by:
        getWorkerForVertex in interface org.apache.giraph.worker.WorkerIndexUsage<OID_T extends org.apache.hadoop.io.WritableComparable>
        Parameters:
        vertexId - vertex id
        Returns:
        worker index
      • initialize

        public void initialize​(org.apache.giraph.graph.GraphState graphState,
                               org.apache.giraph.comm.WorkerClientRequestProcessor<OID_T,​VDATA_T,​EDATA_T> workerClientRequestProcessor,
                               org.apache.giraph.bsp.CentralizedServiceWorker<OID_T,​VDATA_T,​EDATA_T> serviceWorker,
                               org.apache.giraph.worker.WorkerGlobalCommUsage workerGlobalCommUsage)
        Specified by:
        initialize in interface org.apache.giraph.graph.Computation<OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable,​EDATA_T extends org.apache.hadoop.io.Writable,​IN_MSG_T extends org.apache.hadoop.io.Writable,​OUT_MSG_T extends org.apache.hadoop.io.Writable>