sanha commented on a change in pull request #102: [NEMO-180] Java Annotation
for Prerequisite Execution Properties
URL: https://github.com/apache/incubator-nemo/pull/102#discussion_r210848660
##########
File path:
compiler/optimizer/src/main/java/edu/snu/nemo/compiler/optimizer/pass/compiletime/annotating/AnnotatingPass.java
##########
@@ -17,42 +17,38 @@
import edu.snu.nemo.common.ir.executionproperty.ExecutionProperty;
import edu.snu.nemo.compiler.optimizer.pass.compiletime.CompileTimePass;
+import edu.snu.nemo.compiler.optimizer.pass.compiletime.Requires;
-import java.util.Collections;
+import java.util.Arrays;
+import java.util.HashSet;
import java.util.Set;
/**
* A compile-time pass that annotates the IR DAG with execution properties.
* It is ensured by the compiler that the shape of the IR DAG itself is not
modified by an AnnotatingPass.
*/
public abstract class AnnotatingPass extends CompileTimePass {
- private final Class<? extends ExecutionProperty>
keyOfExecutionPropertyToModify;
+ private final Set<Class<? extends ExecutionProperty>>
keyOfExecutionPropertyToModify;
private final Set<Class<? extends ExecutionProperty>>
prerequisiteExecutionProperties;
/**
* Constructor.
- * @param keyOfExecutionPropertyToModify key of execution property to modify.
- * @param prerequisiteExecutionProperties prerequisite execution properties.
+ * @param cls the annotating pass class.
*/
- public AnnotatingPass(final Class<? extends ExecutionProperty>
keyOfExecutionPropertyToModify,
- final Set<Class<? extends ExecutionProperty>>
prerequisiteExecutionProperties) {
- this.keyOfExecutionPropertyToModify = keyOfExecutionPropertyToModify;
- this.prerequisiteExecutionProperties = prerequisiteExecutionProperties;
- }
+ public AnnotatingPass(final Class<? extends AnnotatingPass> cls) {
+ final Annotates annotates = cls.getAnnotation(Annotates.class);
+ this.keyOfExecutionPropertyToModify = new
HashSet<>(Arrays.asList(annotates.value()));
- /**
- * Constructor.
- * @param keyOfExecutionPropertyToModify key of execution property to modify.
- */
- public AnnotatingPass(final Class<? extends ExecutionProperty>
keyOfExecutionPropertyToModify) {
- this(keyOfExecutionPropertyToModify, Collections.emptySet());
+ final Requires requires = cls.getAnnotation(Requires.class);
+ this.prerequisiteExecutionProperties = requires == null
+ ? new HashSet<>() : new HashSet<>(Arrays.asList(requires.value()));
}
/**
* Getter for key of execution property to modify.
* @return key of execution property to modify.
*/
- public final Class<? extends ExecutionProperty>
getExecutionPropertyToModify() {
+ public final Set<Class<? extends ExecutionProperty>>
getExecutionPropertyToModify() {
Review comment:
Please update the comment.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services