apex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gauravgopi123 <...@git.apache.org>
Subject [GitHub] incubator-apex-core pull request: APEX-103: Add module and dag int...
Date Thu, 03 Dec 2015 05:08:24 GMT
Github user gauravgopi123 commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-core/pull/148#discussion_r46513179
  
    --- Diff: api/src/main/java/com/datatorrent/api/Module.java ---
    @@ -21,8 +21,136 @@
     import org.apache.hadoop.classification.InterfaceStability;
     import org.apache.hadoop.conf.Configuration;
     
    +import com.datatorrent.api.Context.PortContext;
    +import com.datatorrent.api.Operator.InputPort;
    +import com.datatorrent.api.Operator.OutputPort;
    +import com.datatorrent.api.Operator.Unifier;
    +
    +/**
    + * A Module is a component which can be added to the DAG similar to the operator,
    + * using addModule API. The module should implement populateDAG method, which
    + * will be called by the platform, and DAG populated by the module will be
    + * replaced in place of the module.
    + *
    + */
     @InterfaceStability.Evolving
     public interface Module
     {
       void populateDAG(DAG dag, Configuration conf);
    +
    +  /**
    +   * These ports allow platform to short circuit module port to the operator port.
    +   * i.e When a module is expanded, it can specify  which operator's port is used
    +   * to replaced the module port in the final DAG.
    +   * @param <T> data type accepted at the input port.
    +   */
    +  public final class ProxyInputPort<T> implements InputPort<T>
    +  {
    +    InputPort<T> inputPort;
    +
    +    public void set(InputPort<T> port)
    +    {
    +      inputPort = port;
    +    }
    +
    +    public InputPort<T> get()
    +    {
    +      return inputPort;
    +    }
    +
    +    @Override
    +    public void setup(PortContext context)
    +    {
    +      if (inputPort != null) {
    +        inputPort.setup(context);
    +      }
    +    }
    +
    +    @Override
    +    public void teardown()
    +    {
    +      if (inputPort != null) {
    +        inputPort.teardown();
    +      }
    +    }
    +
    +    @Override
    +    public Sink<T> getSink()
    +    {
    +      if (inputPort != null) {
    +        return inputPort.getSink();
    +      }
    +      return null;
    +    }
    +
    +    @Override
    +    public void setConnected(boolean connected)
    +    {
    +      if (inputPort != null) {
    +        inputPort.setConnected(connected);
    +      }
    +    }
    +
    +    @Override
    +    public StreamCodec<T> getStreamCodec()
    +    {
    +      if (inputPort != null) {
    +        return inputPort.getStreamCodec();
    +      }
    +      return null;
    +    }
    +  }
    +
    +  /**
    +   * Similar to ProxyInputPort, but on output side.
    +   * @param <T> datatype emitted on the port.
    +   */
    +  public final class ProxyOutputPort<T> implements OutputPort<T>
    +  {
    +    OutputPort<T> outputPort;
    +
    +    public void set(OutputPort<T> port)
    +    {
    +      outputPort = port;
    +    }
    +
    +    public OutputPort<T> get()
    +    {
    +      return outputPort;
    +    }
    +
    +    @Override
    +    public void setup(PortContext context)
    +    {
    +      if (outputPort != null) {
    +        outputPort.setup(context);
    +      }
    +    }
    +
    +    @Override
    +    public void teardown()
    +    {
    +      if (outputPort != null) {
    +        outputPort.teardown();
    +      }
    +    }
    +
    +    @Override
    +    public void setSink(Sink<Object> s)
    +    {
    +      if (outputPort != null) {
    +        outputPort.setSink(s);
    +      }
    +    }
    +
    +    @Override
    +    public Unifier<T> getUnifier()
    +    {
    +      if (outputPort != null) {
    +        return outputPort.getUnifier();
    +      }
    +      return null;
    --- End diff --
    
    why not use  `return outputPort != null ? outputPort.getUnifier() : null;`  Similar changes
at other places


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