-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NEMO-338] SkewSamplingPass #193
Merged
Merged
Changes from 24 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
c35039f
init
5fc685d
save
99592da
nit
3ee41bb
chkpt
ec12b39
chkpt
f284cf0
save
c6f8b7c
chkpt
24bbded
save
c88107a
backend
fd38ac9
refactor
87cebbc
itcase chkpt
6906214
save
868eebf
save
323a342
reuse code
4d0197d
ready for checkstyle
62f82b0
checkstyle
a67154a
one test left
4a9a125
nits
7202882
nit
f6ea04a
nits
43aa13e
all comments except the last
johnyangk a5c1c9d
save edge extensions
johnyangk 1231463
simplify builder.build()
johnyangk 91cdf03
checkstyle
johnyangk 208a7a1
comment
johnyangk f5d6985
merge master
johnyangk 7ab75af
checkstyle
johnyangk ed6f81b
second comments
johnyangk fe9af90
add todo
johnyangk bab9a44
nit
johnyangk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,14 +16,22 @@ | |
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.nemo.common.util; | ||
package org.apache.nemo.common; | ||
|
||
import org.apache.nemo.common.ir.edge.IREdge; | ||
import org.apache.nemo.common.ir.edge.executionproperty.*; | ||
import org.apache.nemo.common.ir.vertex.IRVertex; | ||
|
||
import java.util.Collection; | ||
import java.util.function.IntPredicate; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* Class to hold the utility methods. | ||
*/ | ||
public final class Util { | ||
// Assume that this tag is never used in user application | ||
public static final String CONTROL_EDGE_TAG = "CONTROL_EDGE"; | ||
|
||
/** | ||
* Private constructor for utility class. | ||
|
@@ -42,7 +50,7 @@ private Util() { | |
* @return whether or not we can say that they are equal. | ||
*/ | ||
public static boolean checkEqualityOfIntPredicates(final IntPredicate firstPredicate, | ||
final IntPredicate secondPredicate, final int noOfTimes) { | ||
final IntPredicate secondPredicate, final int noOfTimes) { | ||
for (int value = 0; value <= noOfTimes; value++) { | ||
if (firstPredicate.test(value) != secondPredicate.test(value)) { | ||
return false; | ||
|
@@ -51,4 +59,96 @@ public static boolean checkEqualityOfIntPredicates(final IntPredicate firstPredi | |
return true; | ||
} | ||
|
||
/** | ||
* @param edgeToClone to copy execution properties from. | ||
* @param newSrc of the new edge. | ||
* @param newDst of the new edge. | ||
* @return the new edge. | ||
*/ | ||
public static IREdge cloneEdge(final IREdge edgeToClone, | ||
final IRVertex newSrc, | ||
final IRVertex newDst) { | ||
return cloneEdge( | ||
edgeToClone.getPropertyValue(CommunicationPatternProperty.class).get(), edgeToClone, newSrc, 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. | ||
* | ||
* @param commPattern to use. | ||
* @param edgeToClone to copy execution properties from. | ||
* @param newSrc of the new edge. | ||
* @param newDst of the new edge. | ||
* @return the new edge. | ||
*/ | ||
public static IREdge cloneEdge(final CommunicationPatternProperty.Value commPattern, | ||
final IREdge edgeToClone, | ||
final IRVertex newSrc, | ||
final IRVertex newDst) { | ||
final IREdge clone = new IREdge(commPattern, newSrc, newDst); | ||
|
||
if (edgeToClone.getPropertySnapshot().containsKey(EncoderProperty.class)) { | ||
clone.setProperty(edgeToClone.getPropertySnapshot().get(EncoderProperty.class)); | ||
} else { | ||
clone.setProperty(EncoderProperty.of(edgeToClone.getPropertyValue(EncoderProperty.class) | ||
.orElseThrow(IllegalStateException::new))); | ||
} | ||
|
||
if (edgeToClone.getPropertySnapshot().containsKey(DecoderProperty.class)) { | ||
clone.setProperty(edgeToClone.getPropertySnapshot().get(DecoderProperty.class)); | ||
} else { | ||
clone.setProperty(DecoderProperty.of(edgeToClone.getPropertyValue(DecoderProperty.class) | ||
.orElseThrow(IllegalStateException::new))); | ||
} | ||
|
||
edgeToClone.getPropertyValue(AdditionalOutputTagProperty.class).ifPresent(tag -> { | ||
clone.setProperty(AdditionalOutputTagProperty.of(tag)); | ||
}); | ||
|
||
edgeToClone.getPropertyValue(PartitionerProperty.class).ifPresent(p -> { | ||
if (p.right() == PartitionerProperty.NUM_EQUAL_TO_DST_PARALLELISM) { | ||
clone.setProperty(PartitionerProperty.of(p.left())); | ||
} else { | ||
clone.setProperty(PartitionerProperty.of(p.left(), p.right())); | ||
} | ||
}); | ||
|
||
edgeToClone.getPropertyValue(KeyExtractorProperty.class).ifPresent(ke -> { | ||
clone.setProperty(KeyExtractorProperty.of(ke)); | ||
}); | ||
|
||
return clone; | ||
} | ||
|
||
/** | ||
* 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. | ||
* | ||
* @param src vertex. | ||
* @param dst vertex. | ||
* @return the control edge. | ||
*/ | ||
public static IREdge createControlEdge(final IRVertex src, final IRVertex dst) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add some method level comment for this method. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
final IREdge controlEdge = new IREdge(CommunicationPatternProperty.Value.BroadCast, src, dst); | ||
controlEdge.setPropertyPermanently(AdditionalOutputTagProperty.of(CONTROL_EDGE_TAG)); | ||
return controlEdge; | ||
} | ||
|
||
/** | ||
* @param vertices to stringify ids of. | ||
* @return the string of ids. | ||
*/ | ||
public static String stringifyIRVertexIds(final Collection<IRVertex> vertices) { | ||
return vertices.stream().map(IRVertex::getId).collect(Collectors.toSet()).toString(); | ||
} | ||
|
||
/** | ||
* @param edges to stringify ids of. | ||
* @return the string of ids. | ||
*/ | ||
public static String stringifyIREdgeIds(final Collection<IREdge> edges) { | ||
return edges.stream().map(IREdge::getId).collect(Collectors.toSet()).toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this code needed? The result will be the same without this if clause.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is needed. Please see: https://github.com/apache/incubator-nemo/blob/master/common/src/main/java/org/apache/nemo/common/ir/edge/executionproperty/PartitionerProperty.java#L66