Class VertexImpl<VID_T,​OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable,​EDATA_T extends org.apache.hadoop.io.Writable>

  • All Implemented Interfaces:
    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.graph.Vertex<OID_T,​VDATA_T,​EDATA_T>

    public class VertexImpl<VID_T,​OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable,​EDATA_T extends org.apache.hadoop.io.Writable>
    extends org.apache.giraph.conf.DefaultImmutableClassesGiraphConfigurable<OID_T,​VDATA_T,​EDATA_T>
    implements org.apache.giraph.graph.Vertex<OID_T,​VDATA_T,​EDATA_T>
    • Constructor Detail

      • VertexImpl

        public VertexImpl()
        Usually the default constructor is only used when we load vertex with vif.
    • Method Detail

      • setVertexDataManager

        public void setVertexDataManager​(VertexDataManager vertexDataManager)
      • initialize

        public void initialize​(OID_T id,
                               VDATA_T value,
                               Iterable<org.apache.giraph.edge.Edge<OID_T,​EDATA_T>> edges)
        Initialize id, value, and edges. This method (or the alternative form initialize(id, value)) must be called after instantiation, unless readFields() is called.
        Specified by:
        initialize in interface org.apache.giraph.graph.Vertex<VID_T,​OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable>
        Parameters:
        id - Vertex id
        value - Vertex value
        edges - Iterable of edges
      • initialize

        public void initialize​(OID_T id,
                               VDATA_T value)
        Initialize id and value. Vertex edges will be empty. This method (or the alternative form initialize(id, value, edges)) must be called after instantiation, unless readFields() is called.
        Specified by:
        initialize in interface org.apache.giraph.graph.Vertex<VID_T,​OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable>
        Parameters:
        id - Vertex id
        value - Vertex value
      • getId

        public OID_T getId()
        Get the vertex id.
        Specified by:
        getId in interface org.apache.giraph.graph.Vertex<VID_T,​OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable>
        Returns:
        My vertex id.
      • getValue

        public VDATA_T getValue()
        Get the vertex value (data stored with vertex)
        Specified by:
        getValue in interface org.apache.giraph.graph.Vertex<VID_T,​OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable>
        Returns:
        Vertex value
      • setValue

        public void setValue​(VDATA_T value)
        Set the vertex data (immediately visible in the computation)
        Specified by:
        setValue in interface org.apache.giraph.graph.Vertex<VID_T,​OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable>
        Parameters:
        value - Vertex data to be set
      • voteToHalt

        public void voteToHalt()
        After this is called, the compute() code will no longer be called for this vertex unless a message is sent to it. Then the compute() code will be called once again until this function is called. The application finishes only when all vertices vote to halt.
        Specified by:
        voteToHalt in interface org.apache.giraph.graph.Vertex<VID_T,​OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable>
      • getNumEdges

        public int getNumEdges()
        Get the number of outgoing edges on this vertex.
        Specified by:
        getNumEdges in interface org.apache.giraph.graph.Vertex<VID_T,​OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable>
        Returns:
        the total number of outbound edges from this vertex
      • getEdges

        public Iterable<org.apache.giraph.edge.Edge<OID_T,​EDATA_T>> getEdges()
        Get a read-only view of the out-edges of this vertex. Note: edge objects returned by this iterable may be invalidated as soon as the next element is requested. Thus, keeping a reference to an edge almost always leads to undesired behavior. Accessing the edges with other methods (e.g., addEdge()) during iteration leads to undefined behavior.
        Specified by:
        getEdges in interface org.apache.giraph.graph.Vertex<VID_T,​OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable>
        Returns:
        the out edges (sort order determined by subclass implementation).
      • setEdges

        public void setEdges​(Iterable<org.apache.giraph.edge.Edge<OID_T,​EDATA_T>> edges)
        Set the outgoing edges for this vertex.
        Specified by:
        setEdges in interface org.apache.giraph.graph.Vertex<VID_T,​OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable>
        Parameters:
        edges - Iterable of edges
      • getMutableEdges

        public Iterable<org.apache.giraph.edge.MutableEdge<OID_T,​EDATA_T>> getMutableEdges()
        Get an iterable of out-edges that can be modified in-place. This can mean changing the current edge value or removing the current edge (by using the iterator version). Note: accessing the edges with other methods (e.g., addEdge()) during iteration leads to undefined behavior.
        Specified by:
        getMutableEdges in interface org.apache.giraph.graph.Vertex<VID_T,​OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable>
        Returns:
        An iterable of mutable out-edges
      • getEdgeValue

        public EDATA_T getEdgeValue​(OID_T targetVertexId)
        Return the value of the first edge with the given target vertex id, or null if there is no such edge. Note: edge value objects returned by this method may be invalidated by the next call. Thus, keeping a reference to an edge value almost always leads to undesired behavior.
        Specified by:
        getEdgeValue in interface org.apache.giraph.graph.Vertex<VID_T,​OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable>
        Parameters:
        targetVertexId - Target vertex id
        Returns:
        Edge value (or null if missing)
      • setEdgeValue

        public void setEdgeValue​(OID_T targetVertexId,
                                 EDATA_T edgeValue)
        If an edge to the target vertex exists, set it to the given edge value. This only makes sense with strict graphs.
        Specified by:
        setEdgeValue in interface org.apache.giraph.graph.Vertex<VID_T,​OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable>
        Parameters:
        targetVertexId - Target vertex id
        edgeValue - Edge value
      • getAllEdgeValues

        public Iterable<EDATA_T> getAllEdgeValues​(OID_T targetVertexId)
        Get an iterable over the values of all edges with the given target vertex id. This only makes sense for multigraphs (i.e. graphs with parallel edges). Note: edge value objects returned by this method may be invalidated as soon as the next element is requested. Thus, keeping a reference to an edge value almost always leads to undesired behavior.
        Specified by:
        getAllEdgeValues in interface org.apache.giraph.graph.Vertex<VID_T,​OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable>
        Parameters:
        targetVertexId - Target vertex id
        Returns:
        Iterable of edge values
      • addEdge

        public void addEdge​(org.apache.giraph.edge.Edge<OID_T,​EDATA_T> edge)
        Add an edge for this vertex (happens immediately)
        Specified by:
        addEdge in interface org.apache.giraph.graph.Vertex<VID_T,​OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable>
        Parameters:
        edge - Edge to add
      • removeEdges

        public void removeEdges​(OID_T targetVertexId)
        Removes all edges pointing to the given vertex id.
        Specified by:
        removeEdges in interface org.apache.giraph.graph.Vertex<VID_T,​OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable>
        Parameters:
        targetVertexId - the target vertex id
      • unwrapMutableEdges

        public void unwrapMutableEdges()
        If a MutableEdgesWrapper was used to provide a mutable iterator, copy any remaining edges to the new OutEdges data structure and keep a direct reference to it (thus discarding the wrapper). Called by the Giraph infrastructure after computation.
        Specified by:
        unwrapMutableEdges in interface org.apache.giraph.graph.Vertex<VID_T,​OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable>
      • wakeUp

        public void wakeUp()
        Re-activate vertex if halted.
        Specified by:
        wakeUp in interface org.apache.giraph.graph.Vertex<VID_T,​OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable>
      • isHalted

        public boolean isHalted()
        Is this vertex done?
        Specified by:
        isHalted in interface org.apache.giraph.graph.Vertex<VID_T,​OID_T extends org.apache.hadoop.io.WritableComparable,​VDATA_T extends org.apache.hadoop.io.Writable>
        Returns:
        True if halted, false otherwise.
      • getLocalId

        public long getLocalId()
      • setLocalId

        public void setLocalId​(int lid)