wonook commented on a change in pull request #190: [NEMO-328] Refactor IRDAG
URL: https://github.com/apache/incubator-nemo/pull/190#discussion_r250467718
 
 

 ##########
 File path: common/src/main/java/org/apache/nemo/common/ir/IRDAG.java
 ##########
 @@ -0,0 +1,286 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.nemo.common.ir;
+
+import org.apache.nemo.common.KeyExtractor;
+import org.apache.nemo.common.Pair;
+import org.apache.nemo.common.dag.DAG;
+import org.apache.nemo.common.dag.DAGBuilder;
+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 org.apache.nemo.common.ir.vertex.system.MessageAggregationVertex;
+import org.apache.nemo.common.ir.vertex.system.MessageBarrierVertex;
+import org.apache.nemo.common.ir.vertex.system.StreamVertex;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Consumer;
+import java.util.function.Function;
+
+/**
+ * An IRDAG object captures a high-level data processing application (e.g., 
Spark/Beam application).
+ * - IRVertex: A data-parallel operation. (e.g., map)
+ * - IREdge: A data dependency between two operations. (e.g., shuffle)
+ *
+ * Largely two types of IRDAG optimization(modification) methods are provided.
+ * All of these methods preserve application semantics.
+ * - Annotation: setProperty(), getPropertyValue() on each IRVertex/IREdge
+ * - Reshaping: insert(), delete() on the IRDAG
+ */
+public final class IRDAG {
+  private static final Logger LOG = 
LoggerFactory.getLogger(IRDAG.class.getName());
+  private final AtomicInteger metricCollectionId;
+
+  private DAG<IRVertex, IREdge> dag; // internal DAG, can be updated by 
reshaping methods.
+
+  /**
+   * @param dag underlying DAG.
+   */
+  public IRDAG(final DAG<IRVertex, IREdge> dag) {
+    this.dag = dag;
+    this.metricCollectionId = new AtomicInteger(0);
+  }
+
+  ////////////////////////////////////////////////// Methods for querying the 
DAG topology.
+
+  /**
+   * Visits the current DAG snapshot in a topologically sorted order.
+   * @param function that visits each vertex.
+   */
+  public void topologicalDo(final Consumer<IRVertex> function) {
+    dag.topologicalDo(function);
+  }
+
+  /**
+   * Get vertices of the current DAG snapshot.
+   * @return vertices.
+   */
+  public List<IRVertex> getVertices() {
+    return dag.getVertices();
+  }
+
+  /**
+   * Get incoming edges in the current DAG snapshot.
+   * @param v to query.
+   * @return incoming edges.
+   */
+  public List<IREdge> getIncomingEdgesOf(final IRVertex v) {
+    return dag.getIncomingEdgesOf(v);
+  }
+
+  /**
+   * Get outgoing edges in the current DAG snapshot.
+   * @param v to query.
+   * @return outgoing edges.
+   */
+  public List<IREdge> getOutgoingEdgesOf(final IRVertex v) {
+    return dag.getOutgoingEdgesOf(v);
+  }
+
+  /**
+   * Get vertices in the current DAG snapshot. (sorted)
+   * @return vertices in a topologically sorted order.
+   */
+  public List<IRVertex> getTopologicalSort() {
+    return dag.getTopologicalSort();
+  }
+
+  /**
+   * Get the current underlying DAG for direct access.
+   * @return underlying DAG.
+   */
+  public DAG<IRVertex, IREdge> getCurrentDAGSnapshot() {
 
 Review comment:
   How is this a 'snapshot'?

----------------------------------------------------------------
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

Reply via email to