Uploaded image for project: 'Tajo'
  1. Tajo
  2. TAJO-1973

Replace 'while' loop with 'foreach'

    Details

    • Type: Task
    • Status: Resolved
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.12.0, 0.11.1
    • Component/s: None
    • Labels:

      Description

      'While' loops which iterate over collections can be replaced with the 'foreach' iteration syntax, which is available in Java 5 and newer.

        Activity

        Hide
        githubbot ASF GitHub Bot added a comment -

        GitHub user dkhwangbo opened a pull request:

        https://github.com/apache/tajo/pull/858

        TAJO-1973: Replace 'while' loop with 'foreach'

        'While' loops which iterate over collections can be replaced with the 'foreach' iteration syntax, which is available in Java 5 and newer.

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

        $ git pull https://github.com/dkhwangbo/tajo TAJO-1973

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

        https://github.com/apache/tajo/pull/858.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 #858


        commit f4cee94de68bf3662c8f42056e70591d421fc619
        Author: Dongkyu Hwangbo <hwangbodk@gmail.com>
        Date: 2015-11-09T07:12:33Z

        initial commit

        commit ce3037ad54fe062f0ddb1c62d1bee6ec89b94a90
        Author: Dongkyu Hwangbo <hwangbodk@gmail.com>
        Date: 2015-11-09T07:21:15Z

        keep align

        commit 65cc4c51ea39730924b5c1f6fe6619b903e7bab6
        Author: Dongkyu Hwangbo <hwangbodk@gmail.com>
        Date: 2015-11-09T07:22:51Z

        keep align


        Show
        githubbot ASF GitHub Bot added a comment - GitHub user dkhwangbo opened a pull request: https://github.com/apache/tajo/pull/858 TAJO-1973 : Replace 'while' loop with 'foreach' 'While' loops which iterate over collections can be replaced with the 'foreach' iteration syntax, which is available in Java 5 and newer. You can merge this pull request into a Git repository by running: $ git pull https://github.com/dkhwangbo/tajo TAJO-1973 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/tajo/pull/858.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 #858 commit f4cee94de68bf3662c8f42056e70591d421fc619 Author: Dongkyu Hwangbo <hwangbodk@gmail.com> Date: 2015-11-09T07:12:33Z initial commit commit ce3037ad54fe062f0ddb1c62d1bee6ec89b94a90 Author: Dongkyu Hwangbo <hwangbodk@gmail.com> Date: 2015-11-09T07:21:15Z keep align commit 65cc4c51ea39730924b5c1f6fe6619b903e7bab6 Author: Dongkyu Hwangbo <hwangbodk@gmail.com> Date: 2015-11-09T07:22:51Z keep align
        Hide
        githubbot ASF GitHub Bot added a comment -

        Github user eminency commented on the pull request:

        https://github.com/apache/tajo/pull/858#issuecomment-160504248

        +1

        Show
        githubbot ASF GitHub Bot added a comment - Github user eminency commented on the pull request: https://github.com/apache/tajo/pull/858#issuecomment-160504248 +1
        Hide
        githubbot ASF GitHub Bot added a comment -

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

        https://github.com/apache/tajo/pull/858#discussion_r46115892

        — Diff: tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalog.java —
        @@ -274,10 +274,8 @@ public void testDropDatabaseWithAllTables() throws Exception {
        Map<String, List<String>> createdTablesMap = createBaseDatabaseAndTables();

        // Each time we drop one database, check all databases and their tables.

        • Iterator<String> it = new ArrayList<>(createdTablesMap.keySet()).iterator();
        • while(it.hasNext()) {
          + for (String databaseName : new ArrayList<>(createdTablesMap.keySet())) {
            • End diff –

        Creation of this array list looks redundant.

        Show
        githubbot ASF GitHub Bot added a comment - Github user jihoonson commented on a diff in the pull request: https://github.com/apache/tajo/pull/858#discussion_r46115892 — Diff: tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalog.java — @@ -274,10 +274,8 @@ public void testDropDatabaseWithAllTables() throws Exception { Map<String, List<String>> createdTablesMap = createBaseDatabaseAndTables(); // Each time we drop one database, check all databases and their tables. Iterator<String> it = new ArrayList<>(createdTablesMap.keySet()).iterator(); while(it.hasNext()) { + for (String databaseName : new ArrayList<>(createdTablesMap.keySet())) { End diff – Creation of this array list looks redundant.
        Hide
        githubbot ASF GitHub Bot added a comment -

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

        https://github.com/apache/tajo/pull/858#discussion_r46524585

        — Diff: tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalog.java —
        @@ -274,10 +274,8 @@ public void testDropDatabaseWithAllTables() throws Exception {
        Map<String, List<String>> createdTablesMap = createBaseDatabaseAndTables();

        // Each time we drop one database, check all databases and their tables.

        • Iterator<String> it = new ArrayList<>(createdTablesMap.keySet()).iterator();
        • while(it.hasNext()) {
          + for (String databaseName : new ArrayList<>(createdTablesMap.keySet())) {
            • End diff –

        Thanks for your reply.
        As my understanding, That line is written to convert Set to List because Set has no ordering. I have no idea with another way to get same result. Can I get some more details about your comment?

        Show
        githubbot ASF GitHub Bot added a comment - Github user dkhwangbo commented on a diff in the pull request: https://github.com/apache/tajo/pull/858#discussion_r46524585 — Diff: tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalog.java — @@ -274,10 +274,8 @@ public void testDropDatabaseWithAllTables() throws Exception { Map<String, List<String>> createdTablesMap = createBaseDatabaseAndTables(); // Each time we drop one database, check all databases and their tables. Iterator<String> it = new ArrayList<>(createdTablesMap.keySet()).iterator(); while(it.hasNext()) { + for (String databaseName : new ArrayList<>(createdTablesMap.keySet())) { End diff – Thanks for your reply. As my understanding, That line is written to convert Set to List because Set has no ordering. I have no idea with another way to get same result. Can I get some more details about your comment?
        Hide
        githubbot ASF GitHub Bot added a comment -

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

        https://github.com/apache/tajo/pull/858#discussion_r46547915

        — Diff: tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalog.java —
        @@ -274,10 +274,8 @@ public void testDropDatabaseWithAllTables() throws Exception {
        Map<String, List<String>> createdTablesMap = createBaseDatabaseAndTables();

        // Each time we drop one database, check all databases and their tables.

        • Iterator<String> it = new ArrayList<>(createdTablesMap.keySet()).iterator();
        • while(it.hasNext()) {
          + for (String databaseName : new ArrayList<>(createdTablesMap.keySet())) {
            • End diff –

        Oh, I found that my above comment has no relation about this issue.
        Creation of this array is needed because of 284 line in same file.

        Show
        githubbot ASF GitHub Bot added a comment - Github user dkhwangbo commented on a diff in the pull request: https://github.com/apache/tajo/pull/858#discussion_r46547915 — Diff: tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalog.java — @@ -274,10 +274,8 @@ public void testDropDatabaseWithAllTables() throws Exception { Map<String, List<String>> createdTablesMap = createBaseDatabaseAndTables(); // Each time we drop one database, check all databases and their tables. Iterator<String> it = new ArrayList<>(createdTablesMap.keySet()).iterator(); while(it.hasNext()) { + for (String databaseName : new ArrayList<>(createdTablesMap.keySet())) { End diff – Oh, I found that my above comment has no relation about this issue. Creation of this array is needed because of 284 line in same file.
        Hide
        githubbot ASF GitHub Bot added a comment -

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

        https://github.com/apache/tajo/pull/858#discussion_r47055756

        — Diff: tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalog.java —
        @@ -274,10 +274,8 @@ public void testDropDatabaseWithAllTables() throws Exception {
        Map<String, List<String>> createdTablesMap = createBaseDatabaseAndTables();

        // Each time we drop one database, check all databases and their tables.

        • Iterator<String> it = new ArrayList<>(createdTablesMap.keySet()).iterator();
        • while(it.hasNext()) {
          + for (String databaseName : new ArrayList<>(createdTablesMap.keySet())) {
            • End diff –

        Right. My misunderstanding.

        Show
        githubbot ASF GitHub Bot added a comment - Github user jihoonson commented on a diff in the pull request: https://github.com/apache/tajo/pull/858#discussion_r47055756 — Diff: tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalog.java — @@ -274,10 +274,8 @@ public void testDropDatabaseWithAllTables() throws Exception { Map<String, List<String>> createdTablesMap = createBaseDatabaseAndTables(); // Each time we drop one database, check all databases and their tables. Iterator<String> it = new ArrayList<>(createdTablesMap.keySet()).iterator(); while(it.hasNext()) { + for (String databaseName : new ArrayList<>(createdTablesMap.keySet())) { End diff – Right. My misunderstanding.
        Hide
        githubbot ASF GitHub Bot added a comment -

        Github user jihoonson commented on the pull request:

        https://github.com/apache/tajo/pull/858#issuecomment-163131941

        +1 LGTM

        Show
        githubbot ASF GitHub Bot added a comment - Github user jihoonson commented on the pull request: https://github.com/apache/tajo/pull/858#issuecomment-163131941 +1 LGTM
        Hide
        githubbot ASF GitHub Bot added a comment -

        Github user asfgit closed the pull request at:

        https://github.com/apache/tajo/pull/858

        Show
        githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/tajo/pull/858
        Hide
        jihoonson Jihoon Son added a comment -

        Committed to master and 0.11.1

        Show
        jihoonson Jihoon Son added a comment - Committed to master and 0.11.1
        Hide
        hudson Hudson added a comment -

        FAILURE: Integrated in Tajo-master-CODEGEN-build #624 (See https://builds.apache.org/job/Tajo-master-CODEGEN-build/624/)
        TAJO-1973: Replace 'while' loop with 'foreach'. (jihoonson: rev 5d6c1af954443fefa07767c476821bc6f8bb902a)

        • tajo-plan/src/main/java/org/apache/tajo/plan/serder/EvalNodeDeserializer.java
        • tajo-core/src/main/java/org/apache/tajo/querymaster/Stage.java
        • tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalog.java
        • tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/store/TestXMLCatalogSchemaManager.java
        • CHANGES
        • tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/optimizer/Shrinker.java
        • tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/commons/JSRInlinerAdapter.java
        • tajo-common/src/test/java/org/apache/tajo/validation/TestValidators.java
        • tajo-plan/src/main/java/org/apache/tajo/plan/serder/LogicalNodeDeserializer.java
        Show
        hudson Hudson added a comment - FAILURE: Integrated in Tajo-master-CODEGEN-build #624 (See https://builds.apache.org/job/Tajo-master-CODEGEN-build/624/ ) TAJO-1973 : Replace 'while' loop with 'foreach'. (jihoonson: rev 5d6c1af954443fefa07767c476821bc6f8bb902a) tajo-plan/src/main/java/org/apache/tajo/plan/serder/EvalNodeDeserializer.java tajo-core/src/main/java/org/apache/tajo/querymaster/Stage.java tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalog.java tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/store/TestXMLCatalogSchemaManager.java CHANGES tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/optimizer/Shrinker.java tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/commons/JSRInlinerAdapter.java tajo-common/src/test/java/org/apache/tajo/validation/TestValidators.java tajo-plan/src/main/java/org/apache/tajo/plan/serder/LogicalNodeDeserializer.java
        Hide
        hudson Hudson added a comment -

        SUCCESS: Integrated in Tajo-master-build #1019 (See https://builds.apache.org/job/Tajo-master-build/1019/)
        TAJO-1973: Replace 'while' loop with 'foreach'. (jihoonson: rev 5d6c1af954443fefa07767c476821bc6f8bb902a)

        • tajo-core/src/main/java/org/apache/tajo/querymaster/Stage.java
        • tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/optimizer/Shrinker.java
        • tajo-plan/src/main/java/org/apache/tajo/plan/serder/LogicalNodeDeserializer.java
        • tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/store/TestXMLCatalogSchemaManager.java
        • tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/commons/JSRInlinerAdapter.java
        • tajo-plan/src/main/java/org/apache/tajo/plan/serder/EvalNodeDeserializer.java
        • tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalog.java
        • CHANGES
        • tajo-common/src/test/java/org/apache/tajo/validation/TestValidators.java
        Show
        hudson Hudson added a comment - SUCCESS: Integrated in Tajo-master-build #1019 (See https://builds.apache.org/job/Tajo-master-build/1019/ ) TAJO-1973 : Replace 'while' loop with 'foreach'. (jihoonson: rev 5d6c1af954443fefa07767c476821bc6f8bb902a) tajo-core/src/main/java/org/apache/tajo/querymaster/Stage.java tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/optimizer/Shrinker.java tajo-plan/src/main/java/org/apache/tajo/plan/serder/LogicalNodeDeserializer.java tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/store/TestXMLCatalogSchemaManager.java tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/commons/JSRInlinerAdapter.java tajo-plan/src/main/java/org/apache/tajo/plan/serder/EvalNodeDeserializer.java tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalog.java CHANGES tajo-common/src/test/java/org/apache/tajo/validation/TestValidators.java
        Hide
        hudson Hudson added a comment -

        ABORTED: Integrated in Tajo-0.11.1-build #133 (See https://builds.apache.org/job/Tajo-0.11.1-build/133/)
        TAJO-1973: Replace 'while' loop with 'foreach'. (jihoonson: rev 79b2e873e86e492d8a0354aa6f58ab5815308bcb)

        • tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalog.java
        • tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/commons/JSRInlinerAdapter.java
        • tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/optimizer/Shrinker.java
        • tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/store/TestXMLCatalogSchemaManager.java
        • tajo-core/src/main/java/org/apache/tajo/querymaster/Stage.java
        • tajo-plan/src/main/java/org/apache/tajo/plan/serder/EvalNodeDeserializer.java
        • CHANGES
        • tajo-plan/src/main/java/org/apache/tajo/plan/serder/LogicalNodeDeserializer.java
        • tajo-common/src/test/java/org/apache/tajo/validation/TestValidators.java
        Show
        hudson Hudson added a comment - ABORTED: Integrated in Tajo-0.11.1-build #133 (See https://builds.apache.org/job/Tajo-0.11.1-build/133/ ) TAJO-1973 : Replace 'while' loop with 'foreach'. (jihoonson: rev 79b2e873e86e492d8a0354aa6f58ab5815308bcb) tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalog.java tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/commons/JSRInlinerAdapter.java tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/optimizer/Shrinker.java tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/store/TestXMLCatalogSchemaManager.java tajo-core/src/main/java/org/apache/tajo/querymaster/Stage.java tajo-plan/src/main/java/org/apache/tajo/plan/serder/EvalNodeDeserializer.java CHANGES tajo-plan/src/main/java/org/apache/tajo/plan/serder/LogicalNodeDeserializer.java tajo-common/src/test/java/org/apache/tajo/validation/TestValidators.java

          People

          • Assignee:
            dkhwangbo Dongkyu Hwangbo
            Reporter:
            dkhwangbo Dongkyu Hwangbo
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development