Package org.apache.nemo.common
Class Util
- java.lang.Object
-
- org.apache.nemo.common.Util
-
public final class Util extends java.lang.Object
Class to hold the utility methods.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
checkEqualityOfIntPredicates(java.util.function.IntPredicate firstPredicate, java.util.function.IntPredicate secondPredicate, int noOfTimes)
Check the equality of two intPredicates.static IREdge
cloneEdge(CommunicationPatternProperty.Value commPattern, IREdge edgeToClone, IRVertex newSrc, IRVertex newDst)
Creates a new edge with several execution properties same as the given edge.static IREdge
cloneEdge(IREdge edgeToClone, IRVertex newSrc, IRVertex newDst)
static IREdge
createControlEdge(IRVertex src, IRVertex dst)
A control edge enforces an execution ordering between the source vertex and the destination vertex.static java.lang.String
fetchProjectRootPath()
Finds the project root path.static long
getObjectSize(java.lang.Object o)
Get the object byte size.static boolean
isControlEdge(IREdge edge)
static boolean
isUtilityVertex(IRVertex v)
static java.util.List<Pair<java.lang.Integer,ResourceSpecification>>
parseResourceSpecificationString(java.lang.String resourceSpecificationString)
Utility method for parsing the resource specification string.static void
premain(java.lang.String args, java.lang.instrument.Instrumentation inst)
Method for the instrumentation: for getting the object size.static java.lang.String
restoreEdgeId(java.lang.Integer numericId)
Method to restore String ID from the numeric ID.static java.lang.String
restoreVertexId(java.lang.Integer numericId)
Method to restore String ID from the numeric ID.static java.lang.String
stringifyIREdgeIds(java.util.Collection<IREdge> edges)
static java.lang.String
stringifyIRVertexIds(java.util.Collection<IRVertex> vertices)
-
-
-
Method Detail
-
fetchProjectRootPath
public static java.lang.String fetchProjectRootPath()
Finds the project root path.- Returns:
- the project root path.
-
checkEqualityOfIntPredicates
public static boolean checkEqualityOfIntPredicates(java.util.function.IntPredicate firstPredicate, java.util.function.IntPredicate secondPredicate, int noOfTimes)
Check the equality of two intPredicates. Check if the both the predicates either passes together or fails together for each integer in the range [0,noOfTimes]- Parameters:
firstPredicate
- the first IntPredicate.secondPredicate
- the second IntPredicate.noOfTimes
- Number to check the IntPredicates from.- Returns:
- whether or not we can say that they are equal.
-
cloneEdge
public static IREdge cloneEdge(IREdge edgeToClone, IRVertex newSrc, IRVertex newDst)
- Parameters:
edgeToClone
- to copy execution properties from.newSrc
- of the new edge.newDst
- of the new edge.- Returns:
- the new edge.
-
cloneEdge
public static IREdge cloneEdge(CommunicationPatternProperty.Value commPattern, IREdge edgeToClone, IRVertex newSrc, IRVertex newDst)
Creates a new edge with several execution properties same as the given edge. The copied execution properties include those minimally required for execution, such as encoder/decoders.- Parameters:
commPattern
- to use.edgeToClone
- to copy execution properties from.newSrc
- of the new edge.newDst
- of the new edge.- Returns:
- the new edge.
-
createControlEdge
public static IREdge createControlEdge(IRVertex src, IRVertex dst)
A control edge enforces an execution ordering between the source vertex and the destination vertex. The additional output tag property of control edges is set such that no actual data element is transferred via the edges. This minimizes the run-time overhead of executing control edges.- Parameters:
src
- vertex.dst
- vertex.- Returns:
- the control edge.
-
isControlEdge
public static boolean isControlEdge(IREdge edge)
-
isUtilityVertex
public static boolean isUtilityVertex(IRVertex v)
-
stringifyIRVertexIds
public static java.lang.String stringifyIRVertexIds(java.util.Collection<IRVertex> vertices)
- Parameters:
vertices
- to stringify ids of.- Returns:
- the string of ids.
-
stringifyIREdgeIds
public static java.lang.String stringifyIREdgeIds(java.util.Collection<IREdge> edges)
- Parameters:
edges
- to stringify ids of.- Returns:
- the string of ids.
-
restoreVertexId
public static java.lang.String restoreVertexId(java.lang.Integer numericId)
Method to restore String ID from the numeric ID.- Parameters:
numericId
- the numeric id.- Returns:
- the restored string ID.
-
restoreEdgeId
public static java.lang.String restoreEdgeId(java.lang.Integer numericId)
Method to restore String ID from the numeric ID.- Parameters:
numericId
- the numeric id.- Returns:
- the restored string ID.
-
parseResourceSpecificationString
public static java.util.List<Pair<java.lang.Integer,ResourceSpecification>> parseResourceSpecificationString(java.lang.String resourceSpecificationString)
Utility method for parsing the resource specification string.- Parameters:
resourceSpecificationString
- the input resource specification string.- Returns:
- the parsed list of resource specifications. The Integer indicates how many of the specified nodes are required, followed by the ResourceSpecification that indicates the specifications of the nodes.
-
premain
public static void premain(java.lang.String args, java.lang.instrument.Instrumentation inst)
Method for the instrumentation: for getting the object size.- Parameters:
args
- arguments.inst
- the instrumentation.
-
getObjectSize
public static long getObjectSize(java.lang.Object o)
Get the object byte size.- Parameters:
o
- object to measure.- Returns:
- the bytes of the object.
-
-