[ 
https://issues.apache.org/jira/browse/APEXCORE-272?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15074274#comment-15074274
 ] 

ASF GitHub Bot commented on APEXCORE-272:
-----------------------------------------

Github user gauravgopi123 commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-core/pull/191#discussion_r48569034
  
    --- Diff: 
engine/src/main/java/com/datatorrent/stram/plan/logical/LogicalPlan.java ---
    @@ -907,6 +912,51 @@ else if (field.getType() == float.class || 
field.getType() == Float.class ||
             getValue(OperatorContext.METRICS_DIMENSIONS_SCHEME));
         }
     
    +    /**
    +     * Copy attribute from source attributeMap to destination attributeMap.
    +     *
    +     * @param dest  destination attribute map.
    +     * @param source source attribute map.
    +     */
    +    private void copyAttributes(AttributeMap dest, AttributeMap source)
    +    {
    +      for (Entry<Attribute<?>, ?> a : source.entrySet()) {
    +        dest.put((Attribute<Object>)a.getKey(), a.getValue());
    +      }
    +    }
    +
    +    /**
    +     * Copy attribute of operator and port from provided operatorMeta. 
This function requires
    +     * operatorMeta argument is for the same operator.
    +     *
    +     * @param operatorMeta copy attribute from this OperatorMeta to the 
object.
    +     */
    +    private void copyFrom(OperatorMeta operatorMeta)
    +    {
    +      if (operator != operatorMeta.getOperator()) {
    +        throw new IllegalArgumentException("Operator meta is not for the 
same operator ");
    +      }
    +
    +      // copy operator attributes
    +      copyAttributes(attributes, operatorMeta.getAttributes());
    +
    +      // copy Input port attributes
    +      for (Map.Entry<InputPort<?>, InputPortMeta> entry : 
operatorMeta.getPortMapping().inPortMap.entrySet()) {
    +        InputPort<?> key = entry.getKey();
    +        InputPortMeta dest = getPortMapping().inPortMap.get(key);
    +        InputPortMeta source = entry.getValue();
    --- End diff --
    
    same you don't need source declared. Directly use it in copyAttributes.


> Attributes added to operator inside Module is not preserved.
> ------------------------------------------------------------
>
>                 Key: APEXCORE-272
>                 URL: https://issues.apache.org/jira/browse/APEXCORE-272
>             Project: Apache Apex Core
>          Issue Type: Bug
>            Reporter: Tushar Gosavi
>            Assignee: Tushar Gosavi
>
> Attributes added to operator within a Module is not preserved.
> for example
> {code}
> class M implements Module {
>   public void populateDAG(DAG dag, Configuration conf) {
>      DummyOperator o1 = dag.addOperator("O1", new DummyOperator());
>      o1.setOperatorProp(level1ModuleProp);
>      dag.getMeta(o1).getAttributes().put(Context.OperatorContext.MEMORY_MB, 
> 512);
>   }
> {code}
> The above code when module is expanded attribute set on operator o1 is lost.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to