apex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tushargosavi <...@git.apache.org>
Subject [GitHub] incubator-apex-core pull request: APEXCORE-3 Module Support REBASE...
Date Mon, 21 Dec 2015 17:29:03 GMT
Github user tushargosavi commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-core/pull/189#discussion_r48168838
  
    --- Diff: engine/src/main/java/com/datatorrent/stram/plan/logical/LogicalPlan.java ---
    @@ -1116,13 +1320,78 @@ public StreamMeta addStream(String id)
       public <T> StreamMeta addStream(String id, Operator.OutputPort<? extends T>
source, Operator.InputPort<? super T>... sinks)
       {
         StreamMeta s = addStream(id);
    -    s.setSource(source);
    -    for (Operator.InputPort<?> sink: sinks) {
    -      s.addSink(sink);
    +    id = s.id;
    +    ArrayListMultimap<Operator.OutputPort<?>, Operator.InputPort<?>>
streamMap = ArrayListMultimap.create();
    +    if (!(source instanceof ProxyOutputPort)) {
    +      s.setSource(source);
    +    }
    +    for (Operator.InputPort<?> sink : sinks) {
    +      if (source instanceof ProxyOutputPort || sink instanceof ProxyInputPort) {
    +        streamMap.put(source, sink);
    +        streamLinks.put(id, streamMap);
    +      } else {
    +        if (s.getSource() == null) {
    +          s.setSource(source);
    +        }
    +        s.addSink(sink);
    +      }
         }
         return s;
       }
     
    +  /**
    +   * This will be called once the Logical Dag is expanded, and the proxy input and proxy
output ports are populated with the actual ports that they refer to
    +   * This method adds sources and sinks for the StreamMeta objects which were left empty
in the addStream call.
    +   */
    +  public void applyStreamLinks()
    +  {
    +    for (String id : streamLinks.keySet()) {
    +      StreamMeta s = getStream(id);
    +      for (Map.Entry<Operator.OutputPort<?>, Operator.InputPort<?>>
pair : streamLinks.get(id).entries()) {
    +        if (s.getSource() == null) {
    +          Operator.OutputPort<?> outputPort = pair.getKey();
    +          while (outputPort instanceof ProxyOutputPort) {
    +            outputPort = ((ProxyOutputPort<?>)outputPort).get();
    +          }
    +          s.setSource(outputPort);
    +        }
    +
    +        Operator.InputPort<?> inputPort = pair.getValue();
    +        while (inputPort instanceof ProxyInputPort) {
    +          inputPort = ((ProxyInputPort<?>)inputPort).get();
    +        }
    +        s.addSink(inputPort);
    +      }
    +    }
    +  }
    +
    +  @SuppressWarnings({ "unchecked", "rawtypes" })
    +  private void addDAGToCurrentDAG(ModuleMeta moduleMeta)
    +  {
    +    LogicalPlan subDag = moduleMeta.getDag();
    +    String subDAGName = moduleMeta.getName();
    +    String name;
    +    for (OperatorMeta operatorMeta : subDag.getAllOperators()) {
    +      name = subDAGName + MODULE_NAMESPACE_SEPARATOR + operatorMeta.getName();
    +      this.addOperator(name, operatorMeta.getOperator());
    +      OperatorMeta operatorMetaNew = this.getOperatorMeta(name);
    +      operatorMetaNew.setModuleName(operatorMeta.getModuleName() == null ? subDAGName
: subDAGName + MODULE_NAMESPACE_SEPARATOR + operatorMeta.getModuleName());
    +    }
    +
    +    for (StreamMeta streamMeta : subDag.getAllStreams()) {
    +      OutputPortMeta sourceMeta = streamMeta.getSource();
    +      List<InputPort<?>> ports = new LinkedList<>();
    +      for (InputPortMeta inputPortMeta : streamMeta.getSinks()) {
    +        ports.add(inputPortMeta.getPortObject());
    +      }
    +      InputPort[] inputPorts = ports.toArray(new InputPort[]{});
    +
    +      name = subDAGName + MODULE_NAMESPACE_SEPARATOR + streamMeta.getName();
    +      StreamMeta streamMetaNew = this.addStream(name, sourceMeta.getPortObject(), inputPorts);
    +      streamMetaNew.setModuleName(streamMeta.getModuleName() == null ? subDAGName : subDAGName
+ "_" + streamMeta.getModuleName());
    --- End diff --
    
    The module name for operators will be different in case of nested modules. For example
if 
    Operator O1 comes from module M1, and Operator O2 Come from module M2, which is inside
module M1. Then O1 module name is "M1" and O2 module name is "M1$M2".
    
    While adding module M1 in to parent DAG, O1 module name was null and O2 module name was
"M2".  When O1 got added to parent dag its module name becomes "M1", and O2's module names
becomes "M1$M2"


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message