Package org.apache.nemo.common.dag
Class DAGBuilder<V extends Vertex,E extends Edge<V>>
- java.lang.Object
-
- org.apache.nemo.common.dag.DAGBuilder<V,E>
-
- Type Parameters:
V
- the vertex type.E
- the edge type.
- All Implemented Interfaces:
java.io.Serializable
public final class DAGBuilder<V extends Vertex,E extends Edge<V>> extends java.lang.Object implements java.io.Serializable
DAG Builder.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DAGBuilder()
Constructor of DAGBuilder: it initializes everything.DAGBuilder(DAG<V,E> dag)
Constructor of DAGBuilder with a DAG to start from.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DAGBuilder<V,E>
addVertex(V v)
Add vertex to the builder.DAGBuilder<V,E>
addVertex(V v, java.util.Stack<LoopVertex> loopVertexStack)
Add vertex to the builder, using the LoopVertex stack.DAGBuilder<V,E>
addVertex(V v, DAG<V,E> dag)
Add vertex to the builder, using the information from the given DAG.DAG<V,E>
build()
Build the DAG.DAG<V,E>
buildWithoutSourceCheck()
Build the DAG without source check.DAG<V,E>
buildWithoutSourceSinkCheck()
Build the DAG without source and sink check.DAGBuilder<V,E>
connectSplitterVertexWithoutReplacing(E edgeToReference, E edgeToInsert)
This method adds a information in SplitterVertex's LoopEdge - InternalEdge relationship and connects the Edge without replacing existing mapping relationships.DAGBuilder<V,E>
connectSplitterVertexWithReplacing(E originalEdge, E edgeToInsert)
This method replaces current SplitterVertex's LoopEdge - InternalEdge relationship with the new relationship and connects the Edge.DAGBuilder<V,E>
connectVertices(E edge)
Connect vertices at the edge.boolean
contains(java.util.function.Predicate<V> predicate)
check if the DAGBuilder contains any vertex that satisfies the predicate.boolean
contains(V vertex)
check if the DAGBuilder contains the vertex.boolean
isEmpty()
Checks whether the DAGBuilder is empty.DAGBuilder<V,E>
removeVertex(V v)
Remove the vertex from the list.
-
-
-
Method Detail
-
addVertex
public DAGBuilder<V,E> addVertex(V v)
Add vertex to the builder.- Parameters:
v
- vertex to add.- Returns:
- the builder.
-
addVertex
public DAGBuilder<V,E> addVertex(V v, java.util.Stack<LoopVertex> loopVertexStack)
Add vertex to the builder, using the LoopVertex stack.- Parameters:
v
- vertex to add.loopVertexStack
- LoopVertex stack to retrieve the information from.- Returns:
- the builder.
-
addVertex
public DAGBuilder<V,E> addVertex(V v, DAG<V,E> dag)
Add vertex to the builder, using the information from the given DAG.- Parameters:
v
- vertex to add.dag
- DAG to observe and get the LoopVertex-related information from.- Returns:
- the builder.
-
removeVertex
public DAGBuilder<V,E> removeVertex(V v)
Remove the vertex from the list.- Parameters:
v
- vertex to remove.- Returns:
- the builder.
-
connectVertices
public DAGBuilder<V,E> connectVertices(E edge)
Connect vertices at the edge.- Parameters:
edge
- edge to add. Note: the two vertices of the edge should already be added to the DAGBuilder.- Returns:
- the builder.
-
connectSplitterVertexWithReplacing
public DAGBuilder<V,E> connectSplitterVertexWithReplacing(E originalEdge, E edgeToInsert)
This method replaces current SplitterVertex's LoopEdge - InternalEdge relationship with the new relationship and connects the Edge. The changes which invokes this method should not be caused by SplitterVertex itself. Therefore, this method should be used when there are changes in vertices before / after SplitterVertex. CAUTION: TaskSizeSplitterVertex must only appear in IRDAG.originalEdge
andedgeToInsert
should have same source and destination. Relation to be Erased: originalEdge - internalEdge Relation to insert: edgeToInsert - newInternalEdge- Parameters:
originalEdge
- edge connected to SplitterVertex, and is to be replaced.edgeToInsert
- edge connected to SplitterVertex, and is to be inserted.- Returns:
- itself.
-
connectSplitterVertexWithoutReplacing
public DAGBuilder<V,E> connectSplitterVertexWithoutReplacing(E edgeToReference, E edgeToInsert)
This method adds a information in SplitterVertex's LoopEdge - InternalEdge relationship and connects the Edge without replacing existing mapping relationships. The changes which invokes this method should not be caused by SplitterVertex itself. Therefore, this method should be used when there are changes in vertices before / after SplitterVertex. SinceedgeToInsert
should also have a mapping relationship to originalVertices of SplitterVertex, we giveedgeToReference
together to copy the mapping information. Therefore, these two parameters must have at least one common source or destination. Relation to reference: edgeToReference - internalEdge Relation to add: edgeToInsert - newInternalEdge CAUTION: TaskSizeSplitterVertex must only appear in IRDAG. Use case example: when inserting trigger vertices before / after splitterVertex.- Parameters:
edgeToReference
- edge connected to SplitterVertex, and to reference.edgeToInsert
- edge connected to SplitterVertex, and to insert.- Returns:
- itself.
-
isEmpty
public boolean isEmpty()
Checks whether the DAGBuilder is empty.- Returns:
- whether the DAGBuilder is empty or not.
-
contains
public boolean contains(V vertex)
check if the DAGBuilder contains the vertex.- Parameters:
vertex
- vertex that it searches for.- Returns:
- whether or not the builder contains it.
-
contains
public boolean contains(java.util.function.Predicate<V> predicate)
check if the DAGBuilder contains any vertex that satisfies the predicate.- Parameters:
predicate
- predicate to test each vertices with.- Returns:
- whether or not the builder contains it.
-
buildWithoutSourceSinkCheck
public DAG<V,E> buildWithoutSourceSinkCheck()
Build the DAG without source and sink check.- Returns:
- the DAG contained by the builder.
-
buildWithoutSourceCheck
public DAG<V,E> buildWithoutSourceCheck()
Build the DAG without source check.- Returns:
- the DAG contained by the builder.
-
-