Class ComputeContext<CONFIG extends PregelConfig>


  • public final class ComputeContext<CONFIG extends PregelConfig>
    extends NodeCentricContext<CONFIG>
    A context that is used during the computation. It allows an implementation to send messages to other nodes and change the state of the currently processed node.
    • Method Detail

      • doubleNodeValue

        public double doubleNodeValue​(java.lang.String key)
        Returns the node value for the given node schema key.
        Throws:
        java.lang.IllegalArgumentException - if the key does not exist or the value is not a double
      • longNodeValue

        public long longNodeValue​(java.lang.String key)
        Returns the node value for the given node schema key.
        Throws:
        java.lang.IllegalArgumentException - if the key does not exist or the value is not a long
      • longArrayNodeValue

        public long[] longArrayNodeValue​(java.lang.String key)
        Returns the node value for the given node schema key.
        Throws:
        java.lang.IllegalArgumentException - if the key does not exist or the value is not a long array
      • longArrayNodeValue

        public long[] longArrayNodeValue​(java.lang.String key,
                                         long id)
        Returns the node value for the given node-id and node schema key.
        Throws:
        java.lang.IllegalArgumentException - if the key does not exist or the value is not a long array
      • doubleArrayNodeValue

        public double[] doubleArrayNodeValue​(java.lang.String key)
        Returns the node value for the given node schema key.
        Throws:
        java.lang.IllegalArgumentException - if the key does not exist or the value is not a double array
      • voteToHalt

        public void voteToHalt()
        Notify the execution framework that this node intends to stop the computation. If the node voted to halt and has not received new messages in the next superstep, the compute method will not be called for that node. If a node receives messages, the vote to halt flag will be ignored.
      • isInitialSuperstep

        public boolean isInitialSuperstep()
        Indicates if the current superstep is the first superstep.
      • superstep

        public int superstep()
        Returns the current superstep (0-based).
      • sendToNeighbors

        public void sendToNeighbors​(double message)
        Sends the given message to all neighbors of the node.
      • sendTo

        public void sendTo​(long targetNodeId,
                           double message)
        Sends the given message to the target node. The target node can be any existing node id in the graph.
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - if the node is in the not in id space