You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@storm.apache.org by sureshms <gi...@git.apache.org> on 2015/10/30 19:48:11 UTC

[GitHub] storm pull request: STORM-1152 Change map keySet iteration to entr...

GitHub user sureshms opened a pull request:

    https://github.com/apache/storm/pull/836

    STORM-1152 Change map keySet iteration to entrySet iteration for effi…

    keySet to entrySet iteration changes along with other minor comments and code cleanup.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/sureshms/incubator-storm STORM-1152

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/storm/pull/836.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #836
    
----
commit ef4e289b3828ba996f8d55d89b022068d4fda0b1
Author: Suresh Srinivas <su...@yahoo-inc.com>
Date:   2015-10-30T18:45:08Z

    STORM-1152 Change map keySet iteration to entrySet iteration for efficiency

----


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

[GitHub] storm pull request: STORM-1152 Change map keySet iteration to entr...

Posted by sureshms <gi...@git.apache.org>.
Github user sureshms commented on a diff in the pull request:

    https://github.com/apache/storm/pull/836#discussion_r43553925
  
    --- Diff: storm-core/src/jvm/backtype/storm/serialization/SerializationFactory.java ---
    @@ -81,8 +81,9 @@ public static Kryo getKryo(Map conf) {
             kryoFactory.preRegister(k, conf);
     
             boolean skipMissing = (Boolean) conf.get(Config.TOPOLOGY_SKIP_MISSING_KRYO_REGISTRATIONS);
    -        for(String klassName: registrations.keySet()) {
    -            String serializerClassName = registrations.get(klassName);
    +        for(Map.Entry<String, String> entry: registrations.entrySet()) {
    +            String klassName = entry.getKey();
    --- End diff --
    
    There is another variable of type Class klass that is used in that part of the code. So the name klassName is consistent with it. Any way the next version of the patch just uses entry.getKey() directly.


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

[GitHub] storm pull request: STORM-1152 Change map keySet iteration to entr...

Posted by harshach <gi...@git.apache.org>.
Github user harshach commented on the pull request:

    https://github.com/apache/storm/pull/836#issuecomment-152675912
  
    +1


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

[GitHub] storm pull request: STORM-1152 Change map keySet iteration to entr...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/storm/pull/836


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

[GitHub] storm pull request: STORM-1152 Change map keySet iteration to entr...

Posted by hmcl <gi...@git.apache.org>.
Github user hmcl commented on the pull request:

    https://github.com/apache/storm/pull/836#issuecomment-152676783
  
    +1


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

[GitHub] storm pull request: STORM-1152 Change map keySet iteration to entr...

Posted by hmcl <gi...@git.apache.org>.
Github user hmcl commented on the pull request:

    https://github.com/apache/storm/pull/836#issuecomment-152646032
  
    +1 LGTM. A few pinpoints only related with readability of the code that are left to the discretion of the implementer.


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

[GitHub] storm pull request: STORM-1152 Change map keySet iteration to entr...

Posted by hmcl <gi...@git.apache.org>.
Github user hmcl commented on a diff in the pull request:

    https://github.com/apache/storm/pull/836#discussion_r43548241
  
    --- Diff: storm-core/src/jvm/backtype/storm/serialization/SerializationFactory.java ---
    @@ -81,8 +81,9 @@ public static Kryo getKryo(Map conf) {
             kryoFactory.preRegister(k, conf);
     
             boolean skipMissing = (Boolean) conf.get(Config.TOPOLOGY_SKIP_MISSING_KRYO_REGISTRATIONS);
    -        for(String klassName: registrations.keySet()) {
    -            String serializerClassName = registrations.get(klassName);
    +        for(Map.Entry<String, String> entry: registrations.entrySet()) {
    +            String klassName = entry.getKey();
    --- End diff --
    
    any reason for this variable not be called className?


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

[GitHub] storm pull request: STORM-1152 Change map keySet iteration to entr...

Posted by sureshms <gi...@git.apache.org>.
Github user sureshms commented on a diff in the pull request:

    https://github.com/apache/storm/pull/836#discussion_r43554133
  
    --- Diff: storm-core/src/jvm/backtype/storm/utils/TransferDrainer.java ---
    @@ -30,18 +31,20 @@
       private HashMap<Integer, ArrayList<ArrayList<TaskMessage>>> bundles = new HashMap();
       
       public void add(HashMap<Integer, ArrayList<TaskMessage>> taskTupleSetMap) {
    -    for (Integer task : taskTupleSetMap.keySet()) {
    -      addListRefToMap(this.bundles, task, taskTupleSetMap.get(task));
    +    for (Map.Entry<Integer, ArrayList<TaskMessage>> entry : taskTupleSetMap.entrySet()) {
    +      Integer task = entry.getKey();
    +      addListRefToMap(this.bundles, task, entry.getValue());
    --- End diff --
    
    Good idea to further simplify the code.


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

[GitHub] storm pull request: STORM-1152 Change map keySet iteration to entr...

Posted by hmcl <gi...@git.apache.org>.
Github user hmcl commented on a diff in the pull request:

    https://github.com/apache/storm/pull/836#discussion_r43548584
  
    --- Diff: storm-core/src/jvm/backtype/storm/utils/TransferDrainer.java ---
    @@ -30,18 +31,20 @@
       private HashMap<Integer, ArrayList<ArrayList<TaskMessage>>> bundles = new HashMap();
       
       public void add(HashMap<Integer, ArrayList<TaskMessage>> taskTupleSetMap) {
    -    for (Integer task : taskTupleSetMap.keySet()) {
    -      addListRefToMap(this.bundles, task, taskTupleSetMap.get(task));
    +    for (Map.Entry<Integer, ArrayList<TaskMessage>> entry : taskTupleSetMap.entrySet()) {
    +      Integer task = entry.getKey();
    +      addListRefToMap(this.bundles, task, entry.getValue());
    --- End diff --
    
    Perhaps this could be simplified to  addListRefToMap(this.bundles, entry.getKey(), entry.getValue());


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

[GitHub] storm pull request: STORM-1152 Change map keySet iteration to entr...

Posted by hmcl <gi...@git.apache.org>.
Github user hmcl commented on a diff in the pull request:

    https://github.com/apache/storm/pull/836#discussion_r43549300
  
    --- Diff: storm-core/src/jvm/storm/trident/spout/OpaquePartitionedTridentSpoutExecutor.java ---
    @@ -162,9 +162,9 @@ public void commit(TransactionAttempt attempt) {
                 
                 Long txid = attempt.getTransactionId();
                 Map<String, Object> metas = _cachedMetas.remove(txid);
    -            for(String partitionId: metas.keySet()) {
    -                Object meta = metas.get(partitionId);
    -                _partitionStates.get(partitionId).rotatingState.overrideState(txid, meta);
    +            for(Entry<String, Object> entry: metas.entrySet()) {
    +                Object meta = entry.getValue();
    --- End diff --
    
    Unless the variable is created to make the code easier to read, this could be simplified to   _partitionStates.get(entry.getKey()).rotatingState.overrideState(txid,  entry.getValue());


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

[GitHub] storm pull request: STORM-1152 Change map keySet iteration to entr...

Posted by hmcl <gi...@git.apache.org>.
Github user hmcl commented on a diff in the pull request:

    https://github.com/apache/storm/pull/836#discussion_r43549539
  
    --- Diff: storm-core/src/jvm/storm/trident/topology/TridentTopologyBuilder.java ---
    @@ -248,8 +250,9 @@ public StormTopology buildTopology() {
         }
         
         private void markBatchGroups(String component, Map<String, String> batchGroups) {
    -        for(String stream: batchGroups.keySet()) {
    -            _batchIds.put(new GlobalStreamId(component, stream), batchGroups.get(stream));
    +        for(Map.Entry<String, String> entry: batchGroups.entrySet()) {
    +            String stream = entry.getKey();
    +            _batchIds.put(new GlobalStreamId(component, stream), entry.getValue());
    --- End diff --
    
    Unless the variable is created to make the code easier to read, this could be simplified to 
    _batchIds.put(new GlobalStreamId(component, entry.getKey()), entry.getValue());


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

[GitHub] storm pull request: STORM-1152 Change map keySet iteration to entr...

Posted by hmcl <gi...@git.apache.org>.
Github user hmcl commented on a diff in the pull request:

    https://github.com/apache/storm/pull/836#discussion_r43549404
  
    --- Diff: storm-core/src/jvm/storm/trident/topology/TridentTopologyBuilder.java ---
    @@ -233,8 +234,9 @@ public StormTopology buildTopology() {
                 }
                 
                 Map<String, Set<String>> batchToComponents = getBoltBatchToComponentSubscriptions(id);
    -            for(String b: batchToComponents.keySet()) {
    -                for(String comp: batchToComponents.get(b)) {
    +            for(Map.Entry<String, Set<String>> entry: batchToComponents.entrySet()) {
    +                String b = entry.getKey();
    +                for(String comp: entry.getValue()) {
                         d.directGrouping(comp, TridentBoltExecutor.COORD_STREAM(b));
    --- End diff --
    
    Unless the variable is created to make the code easier to read, this could be simplified to 
    d.directGrouping(comp, TridentBoltExecutor.COORD_STREAM(entry.getKey()));


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