Package com.alibaba.graphscope.graph
Interface GiraphEdgeManager<OID_T extends org.apache.hadoop.io.WritableComparable,EDATA_T extends org.apache.hadoop.io.Writable>
-
- Type Parameters:
OID_T
- vertex id typeEDATA_T
- edge data type.
- All Known Implementing Classes:
DefaultImmutableEdgeManager
public interface GiraphEdgeManager<OID_T extends org.apache.hadoop.io.WritableComparable,EDATA_T extends org.apache.hadoop.io.Writable>
An abstraction for edge management. Including edge id, value get and edge mutation.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addEdge(org.apache.giraph.edge.Edge<OID_T,EDATA_T> edge)
Add an edge for this vertex (happens immediately)Iterable<EDATA_T>
getAllEdgeValues(OID_T targetVertexId)
Get an iterable over the values of all edges with the given target vertex id.Iterable<org.apache.giraph.edge.Edge<OID_T,EDATA_T>>
getEdges(long lid)
Get a read-only view of the out-edges of this vertex.EDATA_T
getEdgeValue(long lid, OID_T targetVertexId)
Return the value of the first edge with the given target vertex id, or null if there is no such edge.Iterable<org.apache.giraph.edge.MutableEdge<OID_T,EDATA_T>>
getMutableEdges()
Get an iterable of out-edges that can be modified in-place.int
getNumEdges(long lid)
Get the number of outgoing edges on a vertex with its lid.void
removeEdges(OID_T targetVertexId)
Removes all edges pointing to the given vertex id.void
setEdges(Iterable<org.apache.giraph.edge.Edge<OID_T,EDATA_T>> edges)
Set the outgoing edges for this vertex.void
setEdgeValue(OID_T targetVertexId, EDATA_T edgeValue)
If an edge to the target vertex exists, set it to the given edge value.void
unwrapMutableEdges()
If aMutableEdgesWrapper
was used to provide a mutable iterator, copy any remaining edges to the newOutEdges
data structure and keep a direct reference to it (thus discarding the wrapper).
-
-
-
Method Detail
-
getNumEdges
int getNumEdges(long lid)
Get the number of outgoing edges on a vertex with its lid.- Returns:
- the total number of outbound edges from this vertex
-
getEdges
Iterable<org.apache.giraph.edge.Edge<OID_T,EDATA_T>> getEdges(long lid)
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.- Returns:
- the out edges (sort order determined by subclass implementation).
-
setEdges
void setEdges(Iterable<org.apache.giraph.edge.Edge<OID_T,EDATA_T>> edges)
Set the outgoing edges for this vertex.- Parameters:
edges
- Iterable of edges
-
getMutableEdges
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.- Returns:
- An iterable of mutable out-edges
-
getEdgeValue
EDATA_T getEdgeValue(long lid, 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.- Parameters:
targetVertexId
- Target vertex id- Returns:
- EDATA_T edge value (or null if missing)
-
setEdgeValue
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.- Parameters:
targetVertexId
- Target vertex idedgeValue
- EDATA_T edge value
-
getAllEdgeValues
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.- Parameters:
targetVertexId
- Target vertex id- Returns:
- Iterable of edge values
-
addEdge
void addEdge(org.apache.giraph.edge.Edge<OID_T,EDATA_T> edge)
Add an edge for this vertex (happens immediately)- Parameters:
edge
- Edge to add
-
removeEdges
void removeEdges(OID_T targetVertexId)
Removes all edges pointing to the given vertex id.- Parameters:
targetVertexId
- the target vertex id
-
unwrapMutableEdges
void unwrapMutableEdges()
If aMutableEdgesWrapper
was used to provide a mutable iterator, copy any remaining edges to the newOutEdges
data structure and keep a direct reference to it (thus discarding the wrapper). Called by the Giraph infrastructure after computation.
-
-