tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jihoon...@apache.org
Subject tajo git commit: TAJO-1973: Replace 'while' loop with 'foreach'.
Date Wed, 09 Dec 2015 06:46:47 GMT
Repository: tajo
Updated Branches:
  refs/heads/master 17af809cc -> 5d6c1af95


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

Closes #858

Signed-off-by: Jihoon Son <jihoonson@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/tajo/repo
Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/5d6c1af9
Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/5d6c1af9
Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/5d6c1af9

Branch: refs/heads/master
Commit: 5d6c1af954443fefa07767c476821bc6f8bb902a
Parents: 17af809
Author: Dongkyu Hwangbo <hwangbodk@gmail.com>
Authored: Wed Dec 9 15:46:20 2015 +0900
Committer: Jihoon Son <jihoonson@apache.org>
Committed: Wed Dec 9 15:46:20 2015 +0900

----------------------------------------------------------------------
 CHANGES                                                   |  3 +++
 .../test/java/org/apache/tajo/catalog/TestCatalog.java    |  4 +---
 .../tajo/catalog/store/TestXMLCatalogSchemaManager.java   | 10 ++++------
 .../java/org/apache/tajo/validation/TestValidators.java   | 10 ++++------
 .../src/main/java/org/apache/tajo/querymaster/Stage.java  |  4 +---
 .../org/apache/tajo/plan/serder/EvalNodeDeserializer.java |  7 ++-----
 .../apache/tajo/plan/serder/LogicalNodeDeserializer.java  |  5 +----
 .../tajo/org/objectweb/asm/commons/JSRInlinerAdapter.java |  4 +---
 .../apache/tajo/org/objectweb/asm/optimizer/Shrinker.java |  8 ++------
 9 files changed, 19 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/5d6c1af9/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index e54e661..4be2c91 100644
--- a/CHANGES
+++ b/CHANGES
@@ -113,6 +113,9 @@ Release 0.12.0 - unreleased
 
   TASKS
 
+    TAJO-1973: Replace 'while' loop with 'foreach'. (Contributed by Dongkyu Hwangbo, i
+    committed by jihoon)
+
     TAJO-1855: Add document for tablespace configuration to the Configuration chapter.
     (Contributed by Jongyoung Park. Committed by jihoon)
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/5d6c1af9/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalog.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalog.java
b/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalog.java
index 2a23e94..fe4b4a7 100644
--- a/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalog.java
+++ b/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/TestCatalog.java
@@ -274,10 +274,8 @@ public class TestCatalog {
     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())) {
       // drop one database
-      String databaseName = it.next();
       assertTrue(catalog.existDatabase(databaseName));
       catalog.dropDatabase(databaseName);
       createdTablesMap.remove(databaseName);

http://git-wip-us.apache.org/repos/asf/tajo/blob/5d6c1af9/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/store/TestXMLCatalogSchemaManager.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/store/TestXMLCatalogSchemaManager.java
b/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/store/TestXMLCatalogSchemaManager.java
index a405426..138ca00 100644
--- a/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/store/TestXMLCatalogSchemaManager.java
+++ b/tajo-catalog/tajo-catalog-server/src/test/java/org/apache/tajo/catalog/store/TestXMLCatalogSchemaManager.java
@@ -131,18 +131,16 @@ public class TestXMLCatalogSchemaManager {
     @Override
     protected boolean matchesSafely(Iterable<? extends T> item, org.hamcrest.Description
mismatchDescription) {
       boolean isFirst = true;
-      Iterator<? extends T> iterator = item.iterator();
-      
-      while (iterator.hasNext()) {
-        T obj = iterator.next();
+
+      for (T obj : item) {
         if (this.matcher.matches(obj)) {
           return true;
         }
-        
+
         if (!isFirst) {
           mismatchDescription.appendText(", ");
         }
-        
+
         this.matcher.describeMismatch(obj, mismatchDescription);
         isFirst = false;
       }

http://git-wip-us.apache.org/repos/asf/tajo/blob/5d6c1af9/tajo-common/src/test/java/org/apache/tajo/validation/TestValidators.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/org/apache/tajo/validation/TestValidators.java b/tajo-common/src/test/java/org/apache/tajo/validation/TestValidators.java
index a0204f7..8db6e3a 100644
--- a/tajo-common/src/test/java/org/apache/tajo/validation/TestValidators.java
+++ b/tajo-common/src/test/java/org/apache/tajo/validation/TestValidators.java
@@ -77,18 +77,16 @@ public class TestValidators {
     @Override
     protected boolean matchesSafely(Iterable<? extends T> item, Description mismatchDescription)
{
       boolean isFirst = true;
-      Iterator<? extends T> iterator = item.iterator();
-      
-      while (iterator.hasNext()) {
-        T obj = iterator.next();
+
+      for (T obj : item) {
         if (this.matcher.matches(obj)) {
           return true;
         }
-        
+
         if (!isFirst) {
           mismatchDescription.appendText(", ");
         }
-        
+
         this.matcher.describeMismatch(obj, mismatchDescription);
         isFirst = false;
       }

http://git-wip-us.apache.org/repos/asf/tajo/blob/5d6c1af9/tajo-core/src/main/java/org/apache/tajo/querymaster/Stage.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/querymaster/Stage.java b/tajo-core/src/main/java/org/apache/tajo/querymaster/Stage.java
index 0aaf92b..254df64 100644
--- a/tajo-core/src/main/java/org/apache/tajo/querymaster/Stage.java
+++ b/tajo-core/src/main/java/org/apache/tajo/querymaster/Stage.java
@@ -655,9 +655,7 @@ public class Stage implements EventHandler<StageEvent> {
     List<ColumnStats> columnStatses = Lists.newArrayList();
 
     MasterPlan masterPlan = stage.getMasterPlan();
-    Iterator<ExecutionBlock> it = masterPlan.getChilds(stage.getBlock()).iterator();
-    while (it.hasNext()) {
-      ExecutionBlock block = it.next();
+    for (ExecutionBlock block : masterPlan.getChilds(stage.getBlock())) {
       Stage childStage = stage.context.getStage(block.getId());
       TableStats[] childStatArray = new TableStats[]{
           childStage.getInputStats(), childStage.getResultStats()

http://git-wip-us.apache.org/repos/asf/tajo/blob/5d6c1af9/tajo-plan/src/main/java/org/apache/tajo/plan/serder/EvalNodeDeserializer.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/serder/EvalNodeDeserializer.java
b/tajo-plan/src/main/java/org/apache/tajo/plan/serder/EvalNodeDeserializer.java
index fa952ab..3b369a1 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/serder/EvalNodeDeserializer.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/serder/EvalNodeDeserializer.java
@@ -72,10 +72,7 @@ public class EvalNodeDeserializer {
     // So, it sequentially transforms each serialized node into a EvalNode instance in a
postfix order of
     // the original eval tree.
 
-    Iterator<PlanProto.EvalNode> it = nodeList.iterator();
-    while (it.hasNext()) {
-      PlanProto.EvalNode protoNode = it.next();
-
+    for (PlanProto.EvalNode protoNode : nodeList) {
       EvalType type = EvalType.valueOf(protoNode.getType().name());
 
       if (EvalType.isUnaryOperator(type)) {
@@ -214,7 +211,7 @@ public class EvalNodeDeserializer {
 
               if (evalContext != null && funcDesc.getInvocation().hasPythonAggregation())
{
                 evalContext.addScriptEngine(current, new PythonScriptEngine(funcDesc,
-                    aggFunc.isFirstPhase()  , aggFunc.isLastPhase()));
+                    aggFunc.isFirstPhase(), aggFunc.isLastPhase()));
               }
 
             } else {

http://git-wip-us.apache.org/repos/asf/tajo/blob/5d6c1af9/tajo-plan/src/main/java/org/apache/tajo/plan/serder/LogicalNodeDeserializer.java
----------------------------------------------------------------------
diff --git a/tajo-plan/src/main/java/org/apache/tajo/plan/serder/LogicalNodeDeserializer.java
b/tajo-plan/src/main/java/org/apache/tajo/plan/serder/LogicalNodeDeserializer.java
index bccde90..e9f58d9 100644
--- a/tajo-plan/src/main/java/org/apache/tajo/plan/serder/LogicalNodeDeserializer.java
+++ b/tajo-plan/src/main/java/org/apache/tajo/plan/serder/LogicalNodeDeserializer.java
@@ -74,10 +74,7 @@ public class LogicalNodeDeserializer {
     // So, it sequentially transforms each serialized node into a LogicalNode instance in
a postfix order of
     // the original logical node tree.
 
-    Iterator<PlanProto.LogicalNode> it = nodeList.iterator();
-    while (it.hasNext()) {
-      PlanProto.LogicalNode protoNode = it.next();
-
+    for (PlanProto.LogicalNode protoNode : nodeList) {
       switch (protoNode.getType()) {
       case ROOT:
         current = convertRoot(nodeMap, protoNode);

http://git-wip-us.apache.org/repos/asf/tajo/blob/5d6c1af9/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/commons/JSRInlinerAdapter.java
----------------------------------------------------------------------
diff --git a/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/commons/JSRInlinerAdapter.java
b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/commons/JSRInlinerAdapter.java
index 10d966b..a8c38f9 100644
--- a/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/commons/JSRInlinerAdapter.java
+++ b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/commons/JSRInlinerAdapter.java
@@ -167,9 +167,7 @@ public class JSRInlinerAdapter extends MethodNode implements Opcodes {
             markSubroutines();
             if (LOGGING) {
                 log(mainSubroutine.toString());
-                Iterator<BitSet> it = subroutineHeads.values().iterator();
-                while (it.hasNext()) {
-                    BitSet sub = it.next();
+                for (BitSet sub : subroutineHeads.values()) {
                     log(sub.toString());
                 }
             }

http://git-wip-us.apache.org/repos/asf/tajo/blob/5d6c1af9/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/optimizer/Shrinker.java
----------------------------------------------------------------------
diff --git a/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/optimizer/Shrinker.java
b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/optimizer/Shrinker.java
index 2ce4c3b..cc2f131 100644
--- a/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/optimizer/Shrinker.java
+++ b/tajo-thirdparty/asm/src/main/java/org/apache/tajo/org/objectweb/asm/optimizer/Shrinker.java
@@ -87,9 +87,7 @@ public class Shrinker {
             }
         });
 
-        Iterator<String> i = unused.iterator();
-        while (i.hasNext()) {
-            String s = i.next();
+        for (String s : unused) {
             if (!s.endsWith("/remove")) {
                 System.out.println("INFO: unused mapping " + s);
             }
@@ -117,9 +115,7 @@ public class Shrinker {
 
             cr = new ClassReader(cw.toByteArray());
             cw = new ClassWriter(0);
-            Iterator<Constant> i = constants.iterator();
-            while (i.hasNext()) {
-                Constant c = i.next();
+            for (Constant c : constants) {
                 c.write(cw);
             }
             cr.accept(cw, ClassReader.SKIP_DEBUG);


Mime
View raw message