asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mb...@apache.org
Subject [3/3] asterixdb git commit: [NO ISSUE][HYR][*DB] Minor refactoring / address SonarQube comments
Date Thu, 26 Oct 2017 15:14:01 GMT
[NO ISSUE][HYR][*DB] Minor refactoring / address SonarQube comments

Change-Id: Icf10b6df0fdc006675d8f0da6fd06d50200c6b6a
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2098
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Murtadha Hubail <mhubail@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/8ecbff11
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/8ecbff11
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/8ecbff11

Branch: refs/heads/master
Commit: 8ecbff115bba1971ded20296fc6ff87e7c359394
Parents: fa1b5e8
Author: Michael Blow <michael.blow@couchbase.com>
Authored: Wed Oct 25 11:54:32 2017 -0400
Committer: Michael Blow <mblow@apache.org>
Committed: Thu Oct 26 08:13:33 2017 -0700

----------------------------------------------------------------------
 .../PushAggregateIntoNestedSubplanRule.java     |   4 +-
 .../rules/am/InvertedIndexAccessMethod.java     |  12 +-
 .../subplan/InlineAllNtsInSubplanVisitor.java   | 137 +++++++++----------
 ...ineSubplanInputForNestedTupleSourceRule.java |   8 +-
 .../translator/AbstractLangTranslator.java      |  11 +-
 .../LangExpressionToPlanTranslator.java         |   8 +-
 .../apache/asterix/api/common/APIFramework.java |  17 +--
 .../api/http/server/VersionApiServlet.java      |   4 +-
 .../apache/asterix/app/nc/RecoveryManager.java  |   2 +-
 .../replication/AutoFaultToleranceStrategy.java |   9 +-
 .../app/replication/NodeFailbackPlan.java       |   8 +-
 .../asterix/app/translator/QueryTranslator.java |   5 +-
 .../apache/asterix/utils/FeedOperations.java    |  17 ++-
 .../common/context/DatasetLifecycleManager.java |   7 +-
 .../external/indexing/IndexingScheduler.java    |  75 ++++------
 .../library/ExternalLibraryManager.java         |   5 +-
 .../external/classad/test/ClassAdToADMTest.java |   6 +-
 .../asterix/fuzzyjoin/FuzzyJoinMemory.java      |  17 ++-
 .../asterix/fuzzyjoin/FuzzyJoinTokenize.java    |   5 +-
 .../VariableSubstitutionEnvironment.java        |   4 +-
 .../extension/grammar/GrammarExtensionMojo.java |   2 +-
 .../asterix/lexergenerator/LexerNode.java       |  36 ++---
 .../apache/asterix/metadata/MetadataCache.java  |   4 +-
 .../management/ReplicationManager.java          |  12 +-
 .../recovery/RemoteRecoveryManager.java         |  16 +--
 .../runtime/utils/ClusterStateManager.java      |   8 +-
 .../testframework/template/TemplateHelper.java  |  12 +-
 .../PersistentLocalResourceRepository.java      |   6 +-
 .../asterix/aoya/AsterixApplicationMaster.java  |   8 +-
 .../algebra/expressions/ConstantExpression.java |   6 +-
 .../visitors/FDsAndEquivClassesVisitor.java     |  26 ++--
 .../visitors/IsomorphismOperatorVisitor.java    |  24 ++--
 .../IsomorphismVariableMappingVisitor.java      |  12 +-
 ...pressionDeepCopyWithNewVariablesVisitor.java |   7 +-
 ...OperatorDeepCopyWithNewVariablesVisitor.java |  19 ++-
 .../UnorderedPartitionedProperty.java           |   8 +-
 .../core/jobgen/impl/PlanCompiler.java          |  13 +-
 .../algebricks/core/utils/DotFormatBuilder.java |   9 +-
 .../client/impl/JobActivityGraphBuilder.java    |   8 +-
 .../hyracks/api/job/JobSpecification.java       |  34 ++---
 .../rewriter/ActivityClusterGraphRewriter.java  | 102 ++++++--------
 .../api/rewriter/runtime/SuperActivity.java     |  24 ++--
 .../hyracks/api/util/ErrorMessageUtil.java      |   8 +-
 .../hyracks/api/util/ExecutionTimeProfiler.java |   5 +-
 .../control/cc/ClusterControllerService.java    |  11 +-
 .../hyracks/control/cc/cluster/NodeManager.java |   8 +-
 .../cc/executor/ActivityClusterPlanner.java     |   8 +-
 .../control/cc/executor/JobExecutor.java        |  20 ++-
 .../apache/hyracks/control/cc/job/JobRun.java   |  27 ++--
 .../cc/web/StateDumpRESTAPIFunction.java        |  12 +-
 .../control/common/config/ConfigManager.java    |  28 ++--
 .../job/profiling/om/AbstractProfile.java       |  16 +--
 .../common/job/profiling/om/JobProfile.java     |   7 +-
 .../common/job/profiling/om/JobletProfile.java  |   8 +-
 .../org/apache/hyracks/control/nc/Joblet.java   |   4 +-
 .../AbstractTupleMemoryManagerTest.java         |  12 +-
 .../tests/unit/AbstractExternalGroupbyTest.java |  10 +-
 .../scheduler/RackAwareNcCollectionBuilder.java |  88 +++++-------
 .../hyracks/hdfs/scheduler/Scheduler.java       |  10 +-
 .../hyracks/maven/license/LicenseMojo.java      |   7 +-
 .../storage/common/buffercache/BufferCache.java |  12 +-
 61 files changed, 447 insertions(+), 611 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushAggregateIntoNestedSubplanRule.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushAggregateIntoNestedSubplanRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushAggregateIntoNestedSubplanRule.java
index 1b1bc93..2b98762 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushAggregateIntoNestedSubplanRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushAggregateIntoNestedSubplanRule.java
@@ -111,9 +111,7 @@ public class PushAggregateIntoNestedSubplanRule implements IAlgebraicRewriteRule
             }
         }
         // Removes subplans.
-        for (Map.Entry<AbstractOperatorWithNestedPlans, List<ILogicalPlan>> entry : nspToSubplanListMap.entrySet()) {
-            entry.getKey().getNestedPlans().removeAll(entry.getValue());
-        }
+        nspToSubplanListMap.forEach((key, value) -> key.getNestedPlans().removeAll(value));
     }
 
     private boolean collectVarsBottomUp(Mutable<ILogicalOperator> opRef, IOptimizationContext context,

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/InvertedIndexAccessMethod.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/InvertedIndexAccessMethod.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/InvertedIndexAccessMethod.java
index 19c6da7..8e09164 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/InvertedIndexAccessMethod.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/InvertedIndexAccessMethod.java
@@ -653,11 +653,11 @@ public class InvertedIndexAccessMethod implements IAccessMethod {
         // Replace the variables in the join condition based on the mapping of variables
         // in the new probe subtree.
         Map<LogicalVariable, LogicalVariable> varMapping = firstDeepCopyVisitor.getInputToOutputVariableMapping();
-        for (Map.Entry<LogicalVariable, LogicalVariable> varMapEntry : varMapping.entrySet()) {
-            if (varMapEntry.getKey() != varMapEntry.getValue()) {
-                joinCond.substituteVar(varMapEntry.getKey(), varMapEntry.getValue());
+        varMapping.forEach((key, value) -> {
+            if (key != value) {
+                joinCond.substituteVar(key, value);
             }
-        }
+        });
         return originalProbeSubTreeRootRef;
     }
 
@@ -726,9 +726,7 @@ public class InvertedIndexAccessMethod implements IAccessMethod {
         // condition since we deep-copied one of the scanner subtrees which
         // changed variables.
         AbstractBinaryJoinOperator joinOp = (AbstractBinaryJoinOperator) joinRef.getValue();
-        for (Map.Entry<LogicalVariable, LogicalVariable> entry : copyVarMap.entrySet()) {
-            joinOp.getCondition().getValue().substituteVar(entry.getKey(), entry.getValue());
-        }
+        copyVarMap.forEach((key, value) -> joinOp.getCondition().getValue().substituteVar(key, value));
         joinOp.getInputs().clear();
         joinOp.getInputs().add(new MutableObject<ILogicalOperator>(scanSubTree));
         // Make sure that the build input (which may be materialized causing blocking) comes from

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/subplan/InlineAllNtsInSubplanVisitor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/subplan/InlineAllNtsInSubplanVisitor.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/subplan/InlineAllNtsInSubplanVisitor.java
index 961dcc1..9a49472 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/subplan/InlineAllNtsInSubplanVisitor.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/subplan/InlineAllNtsInSubplanVisitor.java
@@ -53,10 +53,10 @@ import org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceE
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.AggregateOperator;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.AssignOperator;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.DataSourceScanOperator;
+import org.apache.hyracks.algebricks.core.algebra.operators.logical.DelegateOperator;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.DistinctOperator;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.EmptyTupleSourceOperator;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.ExchangeOperator;
-import org.apache.hyracks.algebricks.core.algebra.operators.logical.DelegateOperator;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.GroupByOperator;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.InnerJoinOperator;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.IntersectOperator;
@@ -86,43 +86,43 @@ import org.apache.hyracks.algebricks.core.algebra.properties.FunctionalDependenc
 import org.apache.hyracks.algebricks.core.algebra.util.OperatorManipulationUtil;
 import org.apache.hyracks.algebricks.core.algebra.visitors.IQueryOperatorVisitor;
 
-/*
-    This visitor inlines all nested tuple source operators in the query
-    plan rooted at the operator being visited, with a deep copy of the query
-    plan rooted at the input <code>subplanInputOperator</code>.
-
-    The visitor ensures that the variables used to correlate between the
-    query plan rooted at <code>subplanInputOperator</code> are propagated
-    to the operator being visited.
-
-    ----------------------------------
-    Here is an abstract example.
-    The original query plan:
-    --Op1
-      --Subplan{
-        --AggregateOp
-          --NestedOp
-            .....
-              --Nested-Tuple-Source
-        }
-        --InputOp
-          .....
-
-    After we call NestedOp.accept(....) with this visitor. We will get an
-    intermediate plan that looks like:
-    --Op1
-      --Subplan{
-        --AggregateOp
-          --NestedOp
-            .....
-              --InputOp'
-                ....
-        }
-        --InputOp
-          .....
-     The plan rooted at InputOp' is a deep copy of the plan rooted at InputOp
-     with a different set of variables.
-
+/**
+ *   This visitor inlines all nested tuple source operators in the query
+ *   plan rooted at the operator being visited, with a deep copy of the query
+ *   plan rooted at the input <code>subplanInputOperator</code>.
+ *
+ *   The visitor ensures that the variables used to correlate between the
+ *   query plan rooted at <code>subplanInputOperator</code> are propagated
+ *   to the operator being visited.
+ *
+ *   ----------------------------------
+ *   Here is an abstract example.
+ *   The original query plan:
+ *   --Op1
+ *     --Subplan{
+ *       --AggregateOp
+ *         --NestedOp
+ *           .....
+ *             --Nested-Tuple-Source
+ *       }
+ *       --InputOp
+ *         .....
+ *
+ *   After we call NestedOp.accept(....) with this visitor. We will get an
+ *   intermediate plan that looks like:
+ *   --Op1
+ *     --Subplan{
+ *       --AggregateOp
+ *         --NestedOp
+ *           .....
+ *             --InputOp'
+ *               ....
+ *       }
+ *       --InputOp
+ *         .....
+ *    The plan rooted at InputOp' is a deep copy of the plan rooted at InputOp
+ *    with a different set of variables.
+ *
  */
 class InlineAllNtsInSubplanVisitor implements IQueryOperatorVisitor<ILogicalOperator, Void> {
     // The optimization context.
@@ -218,8 +218,8 @@ class InlineAllNtsInSubplanVisitor implements IQueryOperatorVisitor<ILogicalOper
         for (LogicalVariable keyVar : correlatedKeyVars) {
             if (!groupKeyVars.contains(keyVar)) {
                 LogicalVariable newVar = context.newVar();
-                op.getGroupByList().add(new Pair<LogicalVariable, Mutable<ILogicalExpression>>(newVar,
-                        new MutableObject<ILogicalExpression>(new VariableReferenceExpression(keyVar))));
+                op.getGroupByList()
+                        .add(new Pair<>(newVar, new MutableObject<>(new VariableReferenceExpression(keyVar))));
                 addedGroupKeyMapping.put(keyVar, newVar);
             }
         }
@@ -237,9 +237,7 @@ class InlineAllNtsInSubplanVisitor implements IQueryOperatorVisitor<ILogicalOper
         }
 
         // Updates the var mapping for added group-by keys.
-        for (Map.Entry<LogicalVariable, LogicalVariable> entry : addedGroupKeyMapping.entrySet()) {
-            updateInputToOutputVarMapping(entry.getKey(), entry.getValue(), false);
-        }
+        addedGroupKeyMapping.forEach((key, value) -> updateInputToOutputVarMapping(key, value, false));
         return op;
     }
 
@@ -260,23 +258,23 @@ class InlineAllNtsInSubplanVisitor implements IQueryOperatorVisitor<ILogicalOper
         ILogicalOperator assignOp = assignOpAndRecordVar.first;
         LogicalVariable recordVar = assignOpAndRecordVar.second;
         ILogicalOperator inputOp = op.getInputs().get(0).getValue();
-        assignOp.getInputs().add(new MutableObject<ILogicalOperator>(inputOp));
+        assignOp.getInputs().add(new MutableObject<>(inputOp));
 
         // Rewrites limit to a group-by with limit as its nested operator.
         Pair<ILogicalOperator, LogicalVariable> gbyOpAndAggVar = wrapLimitInGroupBy(op, recordVar, inputLiveVars);
         ILogicalOperator gbyOp = gbyOpAndAggVar.first;
         LogicalVariable aggVar = gbyOpAndAggVar.second;
-        gbyOp.getInputs().add(new MutableObject<ILogicalOperator>(assignOp));
+        gbyOp.getInputs().add(new MutableObject<>(assignOp));
 
         // Adds an unnest operators on top of the group-by operator.
         Pair<ILogicalOperator, LogicalVariable> unnestOpAndUnnestVar = createUnnestForAggregatedList(aggVar);
         ILogicalOperator unnestOp = unnestOpAndUnnestVar.first;
         LogicalVariable unnestVar = unnestOpAndUnnestVar.second;
-        unnestOp.getInputs().add(new MutableObject<ILogicalOperator>(gbyOp));
+        unnestOp.getInputs().add(new MutableObject<>(gbyOp));
 
         // Adds field accesses to recover input live variables.
         ILogicalOperator fieldAccessAssignOp = createFieldAccessAssignOperator(unnestVar, inputLiveVars);
-        fieldAccessAssignOp.getInputs().add(new MutableObject<ILogicalOperator>(unnestOp));
+        fieldAccessAssignOp.getInputs().add(new MutableObject<>(unnestOp));
 
         OperatorManipulationUtil.computeTypeEnvironmentBottomUp(fieldAccessAssignOp, context);
         return fieldAccessAssignOp;
@@ -288,10 +286,10 @@ class InlineAllNtsInSubplanVisitor implements IQueryOperatorVisitor<ILogicalOper
         List<Mutable<ILogicalExpression>> recordConstructorArgs = new ArrayList<>();
         for (LogicalVariable inputLiveVar : inputLiveVars) {
             if (!correlatedKeyVars.contains(inputLiveVar)) {
-                recordConstructorArgs.add(new MutableObject<ILogicalExpression>(new ConstantExpression(
+                recordConstructorArgs.add(new MutableObject<>(new ConstantExpression(
                         new AsterixConstantValue(new AString(Integer.toString(inputLiveVar.getId()))))));
                 recordConstructorArgs
-                        .add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(inputLiveVar)));
+                        .add(new MutableObject<>(new VariableReferenceExpression(inputLiveVar)));
             }
         }
         LogicalVariable recordVar = context.newVar();
@@ -300,7 +298,7 @@ class InlineAllNtsInSubplanVisitor implements IQueryOperatorVisitor<ILogicalOper
                         FunctionUtil.getFunctionInfo(BuiltinFunctions.OPEN_RECORD_CONSTRUCTOR),
                         recordConstructorArgs));
         AssignOperator assignOp = new AssignOperator(recordVar, recordExprRef);
-        return new Pair<ILogicalOperator, LogicalVariable>(assignOp, recordVar);
+        return new Pair<>(assignOp, recordVar);
     }
 
     private Pair<ILogicalOperator, LogicalVariable> wrapLimitInGroupBy(ILogicalOperator op, LogicalVariable recordVar,
@@ -345,7 +343,7 @@ class InlineAllNtsInSubplanVisitor implements IQueryOperatorVisitor<ILogicalOper
 
         // Adds a nested tuple source operator as the input operator to the
         // limit operator.
-        NestedTupleSourceOperator nts = new NestedTupleSourceOperator(new MutableObject<ILogicalOperator>(gbyOp));
+        NestedTupleSourceOperator nts = new NestedTupleSourceOperator(new MutableObject<>(gbyOp));
         currentOp.getInputs().add(new MutableObject<>(nts));
 
         // Sets the root of the added nested plan to the aggregate operator.
@@ -365,15 +363,15 @@ class InlineAllNtsInSubplanVisitor implements IQueryOperatorVisitor<ILogicalOper
     private Pair<ILogicalOperator, LogicalVariable> createUnnestForAggregatedList(LogicalVariable aggVar) {
         LogicalVariable unnestVar = context.newVar();
         // Creates an unnest function expression.
-        Mutable<ILogicalExpression> unnestArg = new MutableObject<ILogicalExpression>(
+        Mutable<ILogicalExpression> unnestArg = new MutableObject<>(
                 new VariableReferenceExpression(aggVar));
-        List<Mutable<ILogicalExpression>> unnestArgList = new ArrayList<Mutable<ILogicalExpression>>();
+        List<Mutable<ILogicalExpression>> unnestArgList = new ArrayList<>();
         unnestArgList.add(unnestArg);
-        Mutable<ILogicalExpression> unnestExpr = new MutableObject<ILogicalExpression>(
+        Mutable<ILogicalExpression> unnestExpr = new MutableObject<>(
                 new UnnestingFunctionCallExpression(
                         FunctionUtil.getFunctionInfo(BuiltinFunctions.SCAN_COLLECTION), unnestArgList));
         ILogicalOperator unnestOp = new UnnestOperator(unnestVar, unnestExpr);
-        return new Pair<ILogicalOperator, LogicalVariable>(unnestOp, unnestVar);
+        return new Pair<>(unnestOp, unnestVar);
     }
 
     private ILogicalOperator createFieldAccessAssignOperator(LogicalVariable recordVar,
@@ -388,17 +386,16 @@ class InlineAllNtsInSubplanVisitor implements IQueryOperatorVisitor<ILogicalOper
                 fieldAccessVars.add(newVar);
                 // fieldAcess expr
                 List<Mutable<ILogicalExpression>> argRefs = new ArrayList<>();
-                argRefs.add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(recordVar)));
-                argRefs.add(new MutableObject<ILogicalExpression>(new ConstantExpression(
+                argRefs.add(new MutableObject<>(new VariableReferenceExpression(recordVar)));
+                argRefs.add(new MutableObject<>(new ConstantExpression(
                         new AsterixConstantValue(new AString(Integer.toString(inputLiveVar.getId()))))));
-                fieldAccessExprs.add(new MutableObject<ILogicalExpression>(new ScalarFunctionCallExpression(
+                fieldAccessExprs.add(new MutableObject<>(new ScalarFunctionCallExpression(
                         FunctionUtil.getFunctionInfo(BuiltinFunctions.FIELD_ACCESS_BY_NAME), argRefs)));
                 // Updates variable mapping for ancestor operators.
                 updateInputToOutputVarMapping(inputLiveVar, newVar, false);
             }
         }
-        AssignOperator fieldAccessAssignOp = new AssignOperator(fieldAccessVars, fieldAccessExprs);
-        return fieldAccessAssignOp;
+        return new AssignOperator(fieldAccessVars, fieldAccessExprs);
     }
 
     @Override
@@ -429,15 +426,13 @@ class InlineAllNtsInSubplanVisitor implements IQueryOperatorVisitor<ILogicalOper
         correlatedKeyVars.clear();
         correlatedKeyVars.addAll(primaryOpAndVars.second);
         // Update key variables and input-output-var mapping.
-        for (Map.Entry<LogicalVariable, LogicalVariable> entry : varMap.entrySet()) {
-            LogicalVariable oldVar = entry.getKey();
-            LogicalVariable newVar = entry.getValue();
+        varMap.forEach((oldVar, newVar) -> {
             if (correlatedKeyVars.contains(oldVar)) {
                 correlatedKeyVars.remove(oldVar);
                 correlatedKeyVars.add(newVar);
             }
             updateInputToOutputVarMapping(oldVar, newVar, true);
-        }
+        });
         return primaryOpAndVars.first;
     }
 
@@ -454,8 +449,8 @@ class InlineAllNtsInSubplanVisitor implements IQueryOperatorVisitor<ILogicalOper
         List<Pair<IOrder, Mutable<ILogicalExpression>>> orderExprList = new ArrayList<>();
         // Adds keyVars to the prefix of sorting columns.
         for (LogicalVariable keyVar : correlatedKeyVars) {
-            orderExprList.add(new Pair<IOrder, Mutable<ILogicalExpression>>(OrderOperator.ASC_ORDER,
-                    new MutableObject<ILogicalExpression>(new VariableReferenceExpression(keyVar))));
+            orderExprList.add(
+                    new Pair<>(OrderOperator.ASC_ORDER, new MutableObject<>(new VariableReferenceExpression(keyVar))));
         }
         orderExprList.addAll(op.getOrderExpressions());
 
@@ -636,7 +631,7 @@ class InlineAllNtsInSubplanVisitor implements IQueryOperatorVisitor<ILogicalOper
             return op;
         }
         GroupByOperator gbyOp = new GroupByOperator();
-        // Creates a copy of correlatedKeyVars, to fix the ConcurrentModificationExcetpion in ASTERIXDB-1581.
+        // Creates a copy of correlatedKeyVars, to fix the ConcurrentModificationException in ASTERIXDB-1581.
         List<LogicalVariable> copyOfCorrelatedKeyVars = new ArrayList<>(correlatedKeyVars);
         for (LogicalVariable keyVar : copyOfCorrelatedKeyVars) {
             // This limits the visitor can only be applied to a nested logical
@@ -652,7 +647,7 @@ class InlineAllNtsInSubplanVisitor implements IQueryOperatorVisitor<ILogicalOper
         ILogicalOperator inputOp = op.getInputs().get(0).getValue();
         gbyOp.getInputs().add(new MutableObject<>(inputOp));
 
-        NestedTupleSourceOperator nts = new NestedTupleSourceOperator(new MutableObject<ILogicalOperator>(gbyOp));
+        NestedTupleSourceOperator nts = new NestedTupleSourceOperator(new MutableObject<>(gbyOp));
         op.getInputs().clear();
         op.getInputs().add(new MutableObject<>(nts));
 
@@ -718,7 +713,7 @@ class InlineAllNtsInSubplanVisitor implements IQueryOperatorVisitor<ILogicalOper
             subplanInputVarToCurrentVarMap.put(oldVar, newVar);
             currentVarToSubplanInputVarMap.put(newVar, oldVar);
         } else {
-            varMapIntroducedByRewriting.add(new Pair<LogicalVariable, LogicalVariable>(oldVar, newVar));
+            varMapIntroducedByRewriting.add(new Pair<>(oldVar, newVar));
         }
     }
 
@@ -726,8 +721,8 @@ class InlineAllNtsInSubplanVisitor implements IQueryOperatorVisitor<ILogicalOper
             List<Pair<IOrder, Mutable<ILogicalExpression>>> orderExprs) {
         List<Pair<IOrder, Mutable<ILogicalExpression>>> clonedOrderExprs = new ArrayList<>();
         for (Pair<IOrder, Mutable<ILogicalExpression>> orderExpr : orderExprs) {
-            clonedOrderExprs.add(new Pair<IOrder, Mutable<ILogicalExpression>>(orderExpr.first,
-                    new MutableObject<ILogicalExpression>(orderExpr.second.getValue().cloneExpression())));
+            clonedOrderExprs.add(
+                    new Pair<>(orderExpr.first, new MutableObject<>(orderExpr.second.getValue().cloneExpression())));
         }
         return clonedOrderExprs;
     }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/subplan/InlineSubplanInputForNestedTupleSourceRule.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/subplan/InlineSubplanInputForNestedTupleSourceRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/subplan/InlineSubplanInputForNestedTupleSourceRule.java
index 0bda955..8ab8b1d 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/subplan/InlineSubplanInputForNestedTupleSourceRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/subplan/InlineSubplanInputForNestedTupleSourceRule.java
@@ -48,9 +48,9 @@ import org.apache.hyracks.algebricks.core.algebra.operators.logical.GroupByOpera
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.LeftOuterJoinOperator;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.NestedTupleSourceOperator;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.OrderOperator;
+import org.apache.hyracks.algebricks.core.algebra.operators.logical.OrderOperator.IOrder;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.SelectOperator;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.SubplanOperator;
-import org.apache.hyracks.algebricks.core.algebra.operators.logical.OrderOperator.IOrder;
 import org.apache.hyracks.algebricks.core.algebra.operators.logical.visitors.VariableUtilities;
 import org.apache.hyracks.algebricks.core.algebra.plan.ALogicalPlanImpl;
 import org.apache.hyracks.algebricks.core.algebra.util.OperatorManipulationUtil;
@@ -324,9 +324,7 @@ public class InlineSubplanInputForNestedTupleSourceRule implements IAlgebraicRew
                     childrenRef,
                     context);
             changed = changed || resultFromChild.first;
-            for (Map.Entry<LogicalVariable, LogicalVariable> entry : resultFromChild.second.entrySet()) {
-                LogicalVariable oldVar = entry.getKey();
-                LogicalVariable newVar = entry.getValue();
+            resultFromChild.second.forEach((oldVar, newVar) -> {
                 if (liveVars.contains(oldVar)) {
                     // Maps live variables for its ancestors.
                     replacedVarMapForAncestor.put(oldVar, newVar);
@@ -337,7 +335,7 @@ public class InlineSubplanInputForNestedTupleSourceRule implements IAlgebraicRew
                         oldVar = newVar;
                     }
                 }
-            }
+            });
             replacedVarMap.putAll(resultFromChild.second);
         }
         VariableUtilities.substituteVariables(op, replacedVarMap, context);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/AbstractLangTranslator.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/AbstractLangTranslator.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/AbstractLangTranslator.java
index c3f01e8..db6f985 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/AbstractLangTranslator.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/AbstractLangTranslator.java
@@ -154,13 +154,14 @@ public abstract class AbstractLangTranslator {
                 DatasetDecl datasetStmt = (DatasetDecl) stmt;
                 Map<String, String> hints = datasetStmt.getHints();
                 if (hints != null && !hints.isEmpty()) {
-                    Pair<Boolean, String> validationResult = null;
-                    StringBuffer errorMsgBuffer = new StringBuffer();
+                    StringBuilder errorMsgBuffer = new StringBuilder();
                     for (Entry<String, String> hint : hints.entrySet()) {
-                        validationResult = DatasetHints.validate(appCtx, hint.getKey(), hint.getValue());
+                        Pair<Boolean, String> validationResult = DatasetHints.validate(appCtx, hint.getKey(),
+                                hint.getValue());
                         if (!validationResult.first) {
-                            errorMsgBuffer.append("Dataset: " + datasetStmt.getName().getValue()
-                                    + " error in processing hint: " + hint.getKey() + " " + validationResult.second);
+                            errorMsgBuffer.append("Dataset: ").append(datasetStmt.getName().getValue())
+                                    .append(" error in processing hint: ").append(hint.getKey()).append(" ")
+                                    .append(validationResult.second);
                             errorMsgBuffer.append(" \n");
                         }
                     }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java
index 66a1073..d5f41df 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java
@@ -25,7 +25,6 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicLong;
@@ -39,7 +38,6 @@ import org.apache.asterix.common.exceptions.CompilationException;
 import org.apache.asterix.common.exceptions.MetadataException;
 import org.apache.asterix.common.functions.FunctionConstants;
 import org.apache.asterix.common.functions.FunctionSignature;
-import org.apache.asterix.external.util.ExternalDataUtils;
 import org.apache.asterix.lang.aql.util.RangeMapBuilder;
 import org.apache.asterix.lang.common.base.Expression;
 import org.apache.asterix.lang.common.base.Expression.Kind;
@@ -82,7 +80,6 @@ import org.apache.asterix.metadata.declared.MetadataProvider;
 import org.apache.asterix.metadata.declared.ResultSetDataSink;
 import org.apache.asterix.metadata.declared.ResultSetSinkId;
 import org.apache.asterix.metadata.entities.Dataset;
-import org.apache.asterix.metadata.entities.Feed;
 import org.apache.asterix.metadata.entities.Function;
 import org.apache.asterix.metadata.entities.InternalDatasetDetails;
 import org.apache.asterix.metadata.functions.ExternalFunctionCompilerUtil;
@@ -96,7 +93,6 @@ import org.apache.asterix.om.types.ARecordType;
 import org.apache.asterix.om.types.IAType;
 import org.apache.asterix.translator.CompiledStatements.CompiledInsertStatement;
 import org.apache.asterix.translator.CompiledStatements.CompiledLoadFromFileStatement;
-import org.apache.asterix.translator.CompiledStatements.CompiledSubscribeFeedStatement;
 import org.apache.asterix.translator.CompiledStatements.CompiledUpsertStatement;
 import org.apache.asterix.translator.CompiledStatements.ICompiledDmlStatement;
 import org.apache.asterix.translator.util.PlanTranslationUtil;
@@ -1487,12 +1483,12 @@ class LangExpressionToPlanTranslator
 
                 // Updates mapping like <$a, $b> in varMap to <$a, $c>, where there is a mapping <$b, $c>
                 // in childVarMap.
-                for (Map.Entry<LogicalVariable, LogicalVariable> entry : varMap.entrySet()) {
+                varMap.entrySet().forEach(entry -> {
                     LogicalVariable newVar = childVarMap.get(entry.getValue());
                     if (newVar != null) {
                         entry.setValue(newVar);
                     }
-                }
+                });
                 varMap.putAll(childVarMap);
                 ++childIndex;
             }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/APIFramework.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/APIFramework.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/APIFramework.java
index 4b78b93..567d587 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/APIFramework.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/APIFramework.java
@@ -427,9 +427,7 @@ public class APIFramework {
         int perNodeParallelismMax = parallelism / numNodes + 1;
         List<String> allNodes = new ArrayList<>();
         Set<String> selectedNodesWithOneMorePartition = new HashSet<>();
-        for (Map.Entry<String, NodeControllerInfo> entry : ncMap.entrySet()) {
-            allNodes.add(entry.getKey());
-        }
+        ncMap.forEach((key, value) -> allNodes.add(key));
         Random random = new Random();
         for (int index = numNodesWithOneMorePartition; index >= 1; --index) {
             int pick = random.nextInt(index);
@@ -439,9 +437,8 @@ public class APIFramework {
 
         // Generates cluster locations, which has duplicates for a node if it contains more than one partitions.
         List<String> locations = new ArrayList<>();
-        for (Map.Entry<String, NodeControllerInfo> entry : ncMap.entrySet()) {
-            String nodeId = entry.getKey();
-            int availableCores = entry.getValue().getNumAvailableCores();
+        ncMap.forEach((nodeId, value) -> {
+            int availableCores = value.getNumAvailableCores();
             int nodeParallelism =
                     selectedNodesWithOneMorePartition.contains(nodeId) ? perNodeParallelismMax : perNodeParallelismMin;
             int coresToUse =
@@ -449,17 +446,13 @@ public class APIFramework {
             for (int count = 0; count < coresToUse; ++count) {
                 locations.add(nodeId);
             }
-        }
+        });
         return new AlgebricksAbsolutePartitionConstraint(locations.toArray(new String[0]));
     }
 
     // Gets the total number of available cores in the cluster.
     private static int getTotalNumCores(Map<String, NodeControllerInfo> ncMap) {
-        int sum = 0;
-        for (Map.Entry<String, NodeControllerInfo> entry : ncMap.entrySet()) {
-            sum += entry.getValue().getNumAvailableCores();
-        }
-        return sum;
+        return ncMap.values().stream().mapToInt(NodeControllerInfo::getNumAvailableCores).sum();
     }
 
     // Gets the frame limit.

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/VersionApiServlet.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/VersionApiServlet.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/VersionApiServlet.java
index 81e0cfd..8d028a5 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/VersionApiServlet.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/server/VersionApiServlet.java
@@ -50,9 +50,7 @@ public class VersionApiServlet extends AbstractServlet {
         ICcApplicationContext props = (ICcApplicationContext) ctx.get(ASTERIX_APP_CONTEXT_INFO_ATTR);
         Map<String, String> buildProperties = props.getBuildProperties().getAllProps();
         ObjectNode responseObject = OBJECT_MAPPER.createObjectNode();
-        for (Map.Entry<String, String> e : buildProperties.entrySet()) {
-            responseObject.put(e.getKey(), e.getValue());
-        }
+        buildProperties.forEach(responseObject::put);
         try {
             HttpUtil.setContentType(response, HttpUtil.ContentType.TEXT_PLAIN, HttpUtil.Encoding.UTF8);
         } catch (IOException e) {

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/RecoveryManager.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/RecoveryManager.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/RecoveryManager.java
index 04e6313..a502de9 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/RecoveryManager.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/RecoveryManager.java
@@ -499,7 +499,7 @@ public class RecoveryManager implements IRecoveryManager, ILifeCycleComponent {
         int abortedJobId = txnContext.getJobId().getId();
         // Obtain the first/last log record LSNs written by the Job
         long firstLSN = txnContext.getFirstLSN();
-        /**
+        /*
          * The effect of any log record with LSN below minFirstLSN has already been written to disk and
          * will not be rolled back. Therefore, we will set the first LSN of the job to the maximum of
          * minFirstLSN and the job's first LSN.

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/replication/AutoFaultToleranceStrategy.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/replication/AutoFaultToleranceStrategy.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/replication/AutoFaultToleranceStrategy.java
index 80fdbd6..4ac1305 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/replication/AutoFaultToleranceStrategy.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/replication/AutoFaultToleranceStrategy.java
@@ -25,7 +25,6 @@ import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -67,7 +66,6 @@ import org.apache.asterix.metadata.MetadataManager;
 import org.apache.asterix.util.FaultToleranceUtil;
 import org.apache.hyracks.api.application.ICCServiceContext;
 import org.apache.hyracks.api.application.IClusterLifecycleListener.ClusterEventType;
-import org.apache.hyracks.api.config.IOption;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 
 public class AutoFaultToleranceStrategy implements IFaultToleranceStrategy {
@@ -163,9 +161,8 @@ public class AutoFaultToleranceStrategy implements IFaultToleranceStrategy {
                 LOGGER.info("Partitions to recover: " + lostPartitions);
             }
             //For each replica, send a request to takeover the assigned partitions
-            for (Entry<String, List<Integer>> entry : partitionRecoveryPlan.entrySet()) {
-                String replica = entry.getKey();
-                Integer[] partitionsToTakeover = entry.getValue().toArray(new Integer[entry.getValue().size()]);
+            partitionRecoveryPlan.forEach((replica, value) -> {
+                Integer[] partitionsToTakeover = value.toArray(new Integer[value.size()]);
                 long requestId = clusterRequestId++;
                 TakeoverPartitionsRequestMessage takeoverRequest = new TakeoverPartitionsRequestMessage(requestId,
                         replica, partitionsToTakeover);
@@ -180,7 +177,7 @@ public class AutoFaultToleranceStrategy implements IFaultToleranceStrategy {
                      */
                     LOGGER.log(Level.WARNING, "Failed to send takeover request: " + takeoverRequest, e);
                 }
-            }
+            });
         }
     }
 

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/replication/NodeFailbackPlan.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/replication/NodeFailbackPlan.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/replication/NodeFailbackPlan.java
index bc069b9..ab938d2 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/replication/NodeFailbackPlan.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/replication/NodeFailbackPlan.java
@@ -163,11 +163,11 @@ public class NodeFailbackPlan {
          */
         for (String participant : participants) {
             Set<Integer> partitionToPrepareForFailback = new HashSet<>();
-            for (Map.Entry<Integer, String> entry : partition2nodeMap.entrySet()) {
-                if (entry.getValue().equals(participant)) {
-                    partitionToPrepareForFailback.add(entry.getKey());
+            partition2nodeMap.forEach((key, value) -> {
+                if (value.equals(participant)) {
+                    partitionToPrepareForFailback.add(key);
                 }
-            }
+            });
             PreparePartitionsFailbackRequestMessage msg = new PreparePartitionsFailbackRequestMessage(planId,
                     requestId++, participant, partitionToPrepareForFailback);
             if (participant.equals(nodeToReleaseMetadataManager)) {

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
index d3be23c..e45df8b 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
@@ -36,7 +36,6 @@ import java.util.Iterator;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.Properties;
 import java.util.Set;
 import java.util.concurrent.ExecutorService;
@@ -1981,9 +1980,7 @@ public class QueryTranslator extends AbstractLangTranslator implements IStatemen
                     throw new AlgebricksException("Unable to read policy file" + cfps.getSourcePolicyFile(), e);
                 }
                 Map<String, String> policyProperties = new HashMap<>();
-                for (Entry<Object, Object> entry : prop.entrySet()) {
-                    policyProperties.put((String) entry.getKey(), (String) entry.getValue());
-                }
+                prop.forEach((key, value) -> policyProperties.put((String) key, (String) value));
                 newPolicy = new FeedPolicyEntity(dataverse, policy, description, policyProperties);
             }
             MetadataManager.INSTANCE.addFeedPolicy(mdTxnCtx, newPolicy);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/asterixdb/asterix-app/src/main/java/org/apache/asterix/utils/FeedOperations.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/utils/FeedOperations.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/utils/FeedOperations.java
index 2b9386e..9cce91b 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/utils/FeedOperations.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/utils/FeedOperations.java
@@ -330,8 +330,7 @@ public class FeedOperations {
 
             // copy connectors
             connectorIdMapping.clear();
-            for (Entry<ConnectorDescriptorId, IConnectorDescriptor> entry : subJob.getConnectorMap().entrySet()) {
-                IConnectorDescriptor connDesc = entry.getValue();
+            subJob.getConnectorMap().forEach((key, connDesc) -> {
                 ConnectorDescriptorId newConnId;
                 if (connDesc instanceof MToNPartitioningConnectorDescriptor) {
                     MToNPartitioningConnectorDescriptor m2nConn = (MToNPartitioningConnectorDescriptor) connDesc;
@@ -341,8 +340,8 @@ public class FeedOperations {
                 } else {
                     newConnId = jobSpec.createConnectorDescriptor(connDesc);
                 }
-                connectorIdMapping.put(entry.getKey(), newConnId);
-            }
+                connectorIdMapping.put(key, newConnId);
+            });
 
             // make connections between operators
             for (Entry<ConnectorDescriptorId, Pair<Pair<IOperatorDescriptor, Integer>,
@@ -406,12 +405,12 @@ public class FeedOperations {
             }
 
             // set count constraints
-            for (Entry<OperatorDescriptorId, Integer> entry : operatorCounts.entrySet()) {
-                IOperatorDescriptor opDesc = jobSpec.getOperatorMap().get(entry.getKey());
-                if (!operatorLocations.keySet().contains(entry.getKey())) {
-                    PartitionConstraintHelper.addPartitionCountConstraint(jobSpec, opDesc, entry.getValue());
+            operatorCounts.forEach((key, value) -> {
+                IOperatorDescriptor opDesc = jobSpec.getOperatorMap().get(key);
+                if (!operatorLocations.keySet().contains(key)) {
+                    PartitionConstraintHelper.addPartitionCountConstraint(jobSpec, opDesc, value);
                 }
-            }
+            });
             // roots
             for (OperatorDescriptorId root : subJob.getRoots()) {
                 jobSpec.addRoot(jobSpec.getOperatorMap().get(operatorIdMapping.get(root)));

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/DatasetLifecycleManager.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/DatasetLifecycleManager.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/DatasetLifecycleManager.java
index 559d57c..cdb7bb3 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/DatasetLifecycleManager.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/context/DatasetLifecycleManager.java
@@ -491,11 +491,8 @@ public class DatasetLifecycleManager implements IDatasetLifecycleManager, ILifeC
         sb.append(String.format(idxHeaderFormat, "DatasetID", "ResourceID", "Open", "Reference Count", "Index"));
         for (DatasetResource dsr : datasets.values()) {
             DatasetInfo dsInfo = dsr.getDatasetInfo();
-            for (Map.Entry<Long, IndexInfo> entry : dsInfo.getIndexes().entrySet()) {
-                IndexInfo iInfo = entry.getValue();
-                sb.append(String.format(idxFormat, dsInfo.getDatasetID(), entry.getKey(), iInfo.isOpen(),
-                        iInfo.getReferenceCount(), iInfo.getIndex()));
-            }
+            dsInfo.getIndexes().forEach((key, iInfo) -> sb.append(String.format(idxFormat, dsInfo.getDatasetID(), key,
+                    iInfo.isOpen(), iInfo.getReferenceCount(), iInfo.getIndex())));
         }
         outputStream.write(sb.toString().getBytes());
     }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/IndexingScheduler.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/IndexingScheduler.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/IndexingScheduler.java
index 870a6df..5212892 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/IndexingScheduler.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/IndexingScheduler.java
@@ -23,6 +23,7 @@ import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.List;
@@ -80,14 +81,14 @@ public class IndexingScheduler {
      */
     public String[] getLocationConstraints(InputSplit[] splits) throws HyracksException {
         if (splits == null) {
-            /** deal the case when the splits array is null */
+            /* deal the case when the splits array is null */
             return new String[] {};
         }
         int[] workloads = new int[NCs.length];
         Arrays.fill(workloads, 0);
         String[] locations = new String[splits.length];
         Map<String, IntWritable> locationToNumOfSplits = new HashMap<String, IntWritable>();
-        /**
+        /*
          * upper bound is number of splits
          */
         int upperBoundSlots = splits.length;
@@ -96,7 +97,7 @@ public class IndexingScheduler {
             Random random = new Random(System.currentTimeMillis());
             boolean scheduled[] = new boolean[splits.length];
             Arrays.fill(scheduled, false);
-            /**
+            /*
              * scan the splits and build the popularity map
              * give the machines with less local splits more scheduling priority
              */
@@ -105,7 +106,7 @@ public class IndexingScheduler {
             for (String location : locationToNumOfSplits.keySet()) {
                 locationToNumOfAssignement.put(location, 0);
             }
-            /**
+            /*
              * push data-local upper-bounds slots to each machine
              */
             scheduleLocalSlots(splits, workloads, locations, upperBoundSlots, random, scheduled, locationToNumOfSplits,
@@ -119,7 +120,7 @@ public class IndexingScheduler {
             }
             LOGGER.info("Data local rate: "
                     + (scheduled.length == 0 ? 0.0 : ((float) dataLocalCount / (float) (scheduled.length))));
-            /**
+            /*
              * push non-data-local upper-bounds slots to each machine
              */
             locationToNumOfAssignement.clear();
@@ -158,22 +159,15 @@ public class IndexingScheduler {
             boolean[] scheduled, final HashMap<String, Integer> locationToNumOfAssignement)
                     throws IOException, UnknownHostException {
 
-        PriorityQueue<String> scheduleCadndiates = new PriorityQueue<String>(NCs.length, new Comparator<String>() {
-            @Override
-            public int compare(String s1, String s2) {
-                return locationToNumOfAssignement.get(s1).compareTo(locationToNumOfAssignement.get(s2));
-            }
-
-        });
+        PriorityQueue<String> scheduleCadndiates = new PriorityQueue<String>(NCs.length,
+                Comparator.comparing(locationToNumOfAssignement::get));
 
-        for (String nc : NCs) {
-            scheduleCadndiates.add(nc);
-        }
-        /**
+        scheduleCadndiates.addAll(Arrays.asList(NCs));
+        /*
          * schedule no-local file reads
          */
         for (int i = 0; i < splits.length; i++) {
-            /** if there is no data-local NC choice, choose a random one */
+            /* if there is no data-local NC choice, choose a random one */
             if (!scheduled[i]) {
                 String selectedNcName = scheduleCadndiates.remove();
                 if (selectedNcName != null) {
@@ -209,55 +203,48 @@ public class IndexingScheduler {
     private void scheduleLocalSlots(InputSplit[] splits, int[] workloads, String[] locations, int slots, Random random,
             boolean[] scheduled, final Map<String, IntWritable> locationToNumSplits,
             final HashMap<String, Integer> locationToNumOfAssignement) throws IOException, UnknownHostException {
-        /** scheduling candidates will be ordered inversely according to their popularity */
-        PriorityQueue<String> scheduleCadndiates = new PriorityQueue<String>(3, new Comparator<String>() {
-            @Override
-            public int compare(String s1, String s2) {
-                int assignmentDifference = locationToNumOfAssignement.get(s1)
-                        .compareTo(locationToNumOfAssignement.get(s2));
-                if (assignmentDifference != 0) {
-                    return assignmentDifference;
-                }
-                return locationToNumSplits.get(s1).compareTo(locationToNumSplits.get(s2));
+        /* scheduling candidates will be ordered inversely according to their popularity */
+        PriorityQueue<String> scheduleCadndiates = new PriorityQueue<>(3, (s1, s2) -> {
+            int assignmentDifference = locationToNumOfAssignement.get(s1).compareTo(locationToNumOfAssignement.get(s2));
+            if (assignmentDifference != 0) {
+                return assignmentDifference;
             }
-
+            return locationToNumSplits.get(s1).compareTo(locationToNumSplits.get(s2));
         });
 
         for (int i = 0; i < splits.length; i++) {
             if (scheduled[i]) {
                 continue;
             }
-            /**
+            /*
              * get the location of all the splits
              */
             String[] locs = splits[i].getLocations();
             if (locs.length > 0) {
                 scheduleCadndiates.clear();
-                for (int j = 0; j < locs.length; j++) {
-                    scheduleCadndiates.add(locs[j]);
-                }
+                Collections.addAll(scheduleCadndiates, locs);
 
                 for (String candidate : scheduleCadndiates) {
-                    /**
+                    /*
                      * get all the IP addresses from the name
                      */
                     InetAddress[] allIps = InetAddress.getAllByName(candidate);
-                    /**
+                    /*
                      * iterate overa all ips
                      */
                     for (InetAddress ip : allIps) {
-                        /**
+                        /*
                          * if the node controller exists
                          */
                         if (ipToNcMapping.get(ip.getHostAddress()) != null) {
-                            /**
+                            /*
                              * set the ncs
                              */
                             List<String> dataLocations = ipToNcMapping.get(ip.getHostAddress());
                             int arrayPos = random.nextInt(dataLocations.size());
                             String nc = dataLocations.get(arrayPos);
                             int pos = ncNameToIndex.get(nc);
-                            /**
+                            /*
                              * check if the node is already full
                              */
                             if (workloads[pos] < slots) {
@@ -270,11 +257,11 @@ public class IndexingScheduler {
                             }
                         }
                     }
-                    /**
+                    /*
                      * break the loop for data-locations if the schedule has
                      * already been found
                      */
-                    if (scheduled[i] == true) {
+                    if (scheduled[i]) {
                         break;
                     }
                 }
@@ -319,23 +306,19 @@ public class IndexingScheduler {
             ncNameToIndex.clear();
             int i = 0;
 
-            /**
+            /*
              * build the IP address to NC map
              */
             for (Map.Entry<String, NodeControllerInfo> entry : ncNameToNcInfos.entrySet()) {
                 String ipAddr = InetAddress.getByAddress(entry.getValue().getNetworkAddress().lookupIpAddress())
                         .getHostAddress();
-                List<String> matchedNCs = ipToNcMapping.get(ipAddr);
-                if (matchedNCs == null) {
-                    matchedNCs = new ArrayList<String>();
-                    ipToNcMapping.put(ipAddr, matchedNCs);
-                }
+                List<String> matchedNCs = ipToNcMapping.computeIfAbsent(ipAddr, k -> new ArrayList<>());
                 matchedNCs.add(entry.getKey());
                 NCs[i] = entry.getKey();
                 i++;
             }
 
-            /**
+            /*
              * set up the NC name to index mapping
              */
             for (i = 0; i < NCs.length; i++) {

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalLibraryManager.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalLibraryManager.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalLibraryManager.java
index 968dbf6..19a519f 100755
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalLibraryManager.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalLibraryManager.java
@@ -22,7 +22,6 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 
 import org.apache.asterix.common.exceptions.ErrorCode;
 import org.apache.asterix.common.exceptions.RuntimeDataException;
@@ -49,9 +48,7 @@ public class ExternalLibraryManager implements ILibraryManager {
     public List<Pair<String, String>> getAllLibraries() {
         ArrayList<Pair<String, String>> libs = new ArrayList<>();
         synchronized (libraryClassLoaders) {
-            for (Entry<String, ClassLoader> entry : libraryClassLoaders.entrySet()) {
-                libs.add(getDataverseAndLibararyName(entry.getKey()));;
-            }
+            libraryClassLoaders.forEach((key, value) -> libs.add(getDataverseAndLibararyName(key)));
         }
         return libs;
     }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/ClassAdToADMTest.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/ClassAdToADMTest.java b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/ClassAdToADMTest.java
index 74020f3..3bbcf89 100644
--- a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/ClassAdToADMTest.java
+++ b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/classad/test/ClassAdToADMTest.java
@@ -27,7 +27,6 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 
 import org.apache.asterix.external.api.IRawRecord;
 import org.apache.asterix.external.classad.CaseInsensitiveString;
@@ -215,8 +214,7 @@ public class ClassAdToADMTest extends TestCase {
                         parser.setLexerSource(lexerSource);
                         parser.parseNext(pAd);
                         Map<CaseInsensitiveString, ExprTree> attrs = pAd.getAttrList();
-                        for (Entry<CaseInsensitiveString, ExprTree> entry : attrs.entrySet()) {
-                            ExprTree tree = entry.getValue();
+                        attrs.forEach((key, tree) -> {
                             switch (tree.getKind()) {
                                 case ATTRREF_NODE:
                                 case CLASSAD_NODE:
@@ -231,7 +229,7 @@ public class ClassAdToADMTest extends TestCase {
                                     System.out.println("Something is wrong");
                                     break;
                             }
-                        }
+                        });
                     }
                 } finally {
                     recordReader.close();

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/asterixdb/asterix-fuzzyjoin/src/main/java/org/apache/asterix/fuzzyjoin/FuzzyJoinMemory.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-fuzzyjoin/src/main/java/org/apache/asterix/fuzzyjoin/FuzzyJoinMemory.java b/asterixdb/asterix-fuzzyjoin/src/main/java/org/apache/asterix/fuzzyjoin/FuzzyJoinMemory.java
index 9107f63..e42ba51 100644
--- a/asterixdb/asterix-fuzzyjoin/src/main/java/org/apache/asterix/fuzzyjoin/FuzzyJoinMemory.java
+++ b/asterixdb/asterix-fuzzyjoin/src/main/java/org/apache/asterix/fuzzyjoin/FuzzyJoinMemory.java
@@ -27,7 +27,6 @@ import java.util.Collection;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.asterix.fuzzyjoin.invertedlist.InvertedListLengthList;
 import org.apache.asterix.fuzzyjoin.invertedlist.InvertedListsLengthList;
@@ -176,9 +175,9 @@ public class FuzzyJoinMemory {
         // verify candidates
         //
         ArrayList<ResultJoin> results = new ArrayList<>();
-        for (Map.Entry<Integer, Integer> cand : counts.entrySet()) {
-            int count = cand.getValue();
-            int indexProbe = cand.getKey();
+        counts.forEach((key, value) -> {
+            int count = value;
+            int indexProbe = key;
             if (count > 0) {
                 int tokensProbe[] = records.get(indexProbe);
                 float similarity = similarityFilters.passSimilarityFilter(tokens, prefixLength, tokensProbe,
@@ -187,7 +186,7 @@ public class FuzzyJoinMemory {
                     results.add(new ResultJoin(indexProbe, similarity));
                 }
             }
-        }
+        });
         return results;
     }
 
@@ -293,9 +292,9 @@ public class FuzzyJoinMemory {
         // verify candidates
         //
         ArrayList<ResultSelfJoin> results = new ArrayList<>();
-        for (Map.Entry<Integer, Integer> cand : counts.entrySet()) {
-            int count = cand.getValue();
-            int indexProbe = cand.getKey();
+        counts.forEach((key, value) -> {
+            int count = value;
+            int indexProbe = key;
             if (count > 0) {
                 int tokensProbe[] = records.get(indexProbe);
                 float similarity = similarityFilters.passSimilarityFilter(tokens, prefixLength, tokensProbe,
@@ -304,7 +303,7 @@ public class FuzzyJoinMemory {
                     results.add(new ResultSelfJoin(index, indexProbe, similarity));
                 }
             }
-        }
+        });
         return results;
     }
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/asterixdb/asterix-fuzzyjoin/src/main/java/org/apache/asterix/fuzzyjoin/FuzzyJoinTokenize.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-fuzzyjoin/src/main/java/org/apache/asterix/fuzzyjoin/FuzzyJoinTokenize.java b/asterixdb/asterix-fuzzyjoin/src/main/java/org/apache/asterix/fuzzyjoin/FuzzyJoinTokenize.java
index 62b34c0..64c7e52 100644
--- a/asterixdb/asterix-fuzzyjoin/src/main/java/org/apache/asterix/fuzzyjoin/FuzzyJoinTokenize.java
+++ b/asterixdb/asterix-fuzzyjoin/src/main/java/org/apache/asterix/fuzzyjoin/FuzzyJoinTokenize.java
@@ -30,7 +30,6 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.Map;
 
 import org.apache.asterix.fuzzyjoin.tokenizer.Tokenizer;
 import org.apache.asterix.fuzzyjoin.tokenizer.TokenizerFactory;
@@ -95,9 +94,7 @@ public class FuzzyJoinTokenize {
         input.close();
 
         ArrayList<TokenCount> tokenCounts = new ArrayList<TokenCount>();
-        for (Map.Entry<String, MutableInteger> entry : tokenCount.entrySet()) {
-            tokenCounts.add(new TokenCount(entry.getKey(), entry.getValue()));
-        }
+        tokenCount.forEach((key, value) -> tokenCounts.add(new TokenCount(key, value)));
         Collections.sort(tokenCounts);
 
         BufferedWriter outputTokens = new BufferedWriter(new FileWriter(tokensFileName));

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/rewrites/VariableSubstitutionEnvironment.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/rewrites/VariableSubstitutionEnvironment.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/rewrites/VariableSubstitutionEnvironment.java
index 26f528c..a8650dd 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/rewrites/VariableSubstitutionEnvironment.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/rewrites/VariableSubstitutionEnvironment.java
@@ -33,9 +33,7 @@ public class VariableSubstitutionEnvironment {
     }
 
     public VariableSubstitutionEnvironment(Map<VariableExpr, Expression> varExprMap) {
-        for (Map.Entry<VariableExpr, Expression> entry : varExprMap.entrySet()) {
-            oldVarToNewExpressionMap.put(entry.getKey().getVar().getValue(), entry.getValue());
-        }
+        varExprMap.forEach((key, value) -> oldVarToNewExpressionMap.put(key.getVar().getValue(), value));
     }
 
     public VariableSubstitutionEnvironment(VariableSubstitutionEnvironment env) {

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/asterixdb/asterix-maven-plugins/asterix-grammar-extension-maven-plugin/src/main/java/org/apache/asterix/extension/grammar/GrammarExtensionMojo.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-maven-plugins/asterix-grammar-extension-maven-plugin/src/main/java/org/apache/asterix/extension/grammar/GrammarExtensionMojo.java b/asterixdb/asterix-maven-plugins/asterix-grammar-extension-maven-plugin/src/main/java/org/apache/asterix/extension/grammar/GrammarExtensionMojo.java
index 4c750e2..17a71f2 100644
--- a/asterixdb/asterix-maven-plugins/asterix-grammar-extension-maven-plugin/src/main/java/org/apache/asterix/extension/grammar/GrammarExtensionMojo.java
+++ b/asterixdb/asterix-maven-plugins/asterix-grammar-extension-maven-plugin/src/main/java/org/apache/asterix/extension/grammar/GrammarExtensionMojo.java
@@ -216,7 +216,7 @@ public class GrammarExtensionMojo extends AbstractMojo {
             writer.newLine();
             writer.newLine();
 
-            // Extinsibles
+            // Extensibles
             for (Entry<String, Pair<String, String>> entry : extensibles.entrySet()) {
                 writer.newLine();
                 String signature = entry.getKey();

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/asterixdb/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/org/apache/asterix/lexergenerator/LexerNode.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/org/apache/asterix/lexergenerator/LexerNode.java b/asterixdb/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/org/apache/asterix/lexergenerator/LexerNode.java
index 4f24b1e..1820be6 100644
--- a/asterixdb/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/org/apache/asterix/lexergenerator/LexerNode.java
+++ b/asterixdb/asterix-maven-plugins/lexer-generator-maven-plugin/src/main/java/org/apache/asterix/lexergenerator/LexerNode.java
@@ -40,12 +40,8 @@ public class LexerNode {
     public LexerNode clone() {
         LexerNode node = new LexerNode();
         node.finalTokenName = this.finalTokenName;
-        for (Map.Entry<Rule, LexerNode> entry : this.actions.entrySet()) {
-            node.actions.put(entry.getKey().clone(), entry.getValue().clone());
-        }
-        for (String ongoing : this.ongoingParsing) {
-            node.ongoingParsing.add(ongoing);
-        }
+        this.actions.forEach((key, value) -> node.actions.put(key.clone(), value.clone()));
+        node.ongoingParsing.addAll(this.ongoingParsing);
         return node;
     }
 
@@ -59,9 +55,7 @@ public class LexerNode {
         if (actions.size() == 0) {
             add(newRule);
         } else {
-            for (Map.Entry<Rule, LexerNode> action : actions.entrySet()) {
-                action.getValue().append(newRule);
-            }
+            actions.forEach((key, value) -> value.append(newRule));
             if (actions.containsKey(new RuleEpsilon())) {
                 actions.remove(new RuleEpsilon());
                 add(newRule);
@@ -84,9 +78,7 @@ public class LexerNode {
                 throw new Exception("Rule conflict between: " + this.finalTokenName + " and " + newNode.finalTokenName);
             }
         }
-        for (String ongoing : newNode.ongoingParsing) {
-            this.ongoingParsing.add(ongoing);
-        }
+        this.ongoingParsing.addAll(newNode.ongoingParsing);
     }
 
     public void append(LexerNode node) throws Exception {
@@ -110,9 +102,7 @@ public class LexerNode {
             this.finalTokenName = name;
         } else {
             ongoingParsing.add(TOKEN_PREFIX + name);
-            for (Map.Entry<Rule, LexerNode> action : actions.entrySet()) {
-                action.getValue().appendTokenName(name);
-            }
+            actions.forEach((key, value) -> value.appendTokenName(name));
         }
     }
 
@@ -130,7 +120,7 @@ public class LexerNode {
         if (finalTokenName != null)
             result.append("! ");
         if (actions.size() == 1)
-            result.append(actions.keySet().toArray()[0].toString() + actions.values().toArray()[0].toString());
+            result.append(actions.keySet().toArray()[0].toString()).append(actions.values().toArray()[0].toString());
         if (actions.size() > 1) {
             result.append(" ( ");
             for (Map.Entry<Rule, LexerNode> action : actions.entrySet()) {
@@ -146,7 +136,7 @@ public class LexerNode {
     }
 
     public String toJava() {
-        StringBuffer result = new StringBuffer();
+        StringBuilder result = new StringBuilder();
         if (numberOfRuleChar() > 2) {
             result.append(toJavaSingleCharRules());
             result.append(toJavaComplexRules(false));
@@ -154,10 +144,10 @@ public class LexerNode {
             result.append(toJavaComplexRules(true));
         }
         if (this.finalTokenName != null) {
-            result.append("return " + TOKEN_PREFIX + finalTokenName + ";\n");
+            result.append("return ").append(TOKEN_PREFIX).append(finalTokenName).append(";\n");
         } else if (ongoingParsing != null) {
             String ongoingParsingArgs = collectionJoin(ongoingParsing, ',');
-            result.append("return parseError(" + ongoingParsingArgs + ");\n");
+            result.append("return parseError(").append(ongoingParsingArgs).append(");\n");
         }
         return result.toString();
     }
@@ -172,12 +162,12 @@ public class LexerNode {
     }
 
     private String toJavaSingleCharRules() {
-        StringBuffer result = new StringBuffer();
+        StringBuilder result = new StringBuilder();
         result.append("switch(currentChar){\n");
         for (Map.Entry<Rule, LexerNode> action : actions.entrySet()) {
             if (action.getKey() instanceof RuleChar) {
                 RuleChar rule = (RuleChar) action.getKey();
-                result.append("case '" + rule.expectedChar() + "':\n");
+                result.append("case '").append(rule.expectedChar()).append("':\n");
                 result.append(rule.javaAction()).append("\n");
                 result.append(action.getValue().toJava());
             }
@@ -187,7 +177,7 @@ public class LexerNode {
     }
 
     private String toJavaComplexRules(boolean all) {
-        StringBuffer result = new StringBuffer();
+        StringBuilder result = new StringBuilder();
         for (Map.Entry<Rule, LexerNode> action : actions.entrySet()) {
             if (!all && action.getKey() instanceof RuleChar)
                 continue;
@@ -244,7 +234,7 @@ public class LexerNode {
             ongoingParsingArgs.append(token);
             ongoingParsingArgs.append(c);
         }
-        if (ongoingParsing.size() > 0) {
+        if (!ongoingParsing.isEmpty()) {
             ongoingParsingArgs.deleteCharAt(ongoingParsingArgs.length() - 1);
         }
         return ongoingParsingArgs.toString();

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/MetadataCache.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/MetadataCache.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/MetadataCache.java
index 08ca03b..8f88ca7 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/MetadataCache.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/MetadataCache.java
@@ -376,9 +376,7 @@ public class MetadataCache {
             if (m == null) {
                 return retDatasets;
             }
-            for (Map.Entry<String, Dataset> entry : m.entrySet()) {
-                retDatasets.add(entry.getValue());
-            }
+            m.forEach((key, value) -> retDatasets.add(value));
             return retDatasets;
         }
     }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/management/ReplicationManager.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/management/ReplicationManager.java b/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/management/ReplicationManager.java
index da45e42..126114b 100644
--- a/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/management/ReplicationManager.java
+++ b/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/management/ReplicationManager.java
@@ -509,7 +509,7 @@ public class ReplicationManager implements IReplicationManager {
             i++;
         }
 
-        /**
+        /*
          * establish log replication handshake
          */
         ByteBuffer handshakeBuffer = ByteBuffer.allocate(ReplicationProtocol.REPLICATION_REQUEST_TYPE_SIZE)
@@ -563,7 +563,7 @@ public class ReplicationManager implements IReplicationManager {
             LOGGER.info("TxnLogReplicator thread was terminated.");
         }
 
-        /**
+        /*
          * End log replication handshake (by sending a dummy log with a single byte)
          */
         ByteBuffer endLogRepHandshake = ByteBuffer.allocate(Integer.SIZE + 1).putInt(1).put((byte) 0);
@@ -602,7 +602,7 @@ public class ReplicationManager implements IReplicationManager {
             }
         }
 
-        /**
+        /*
          * Close log replication sockets
          */
         ByteBuffer goodbyeBuffer = ReplicationProtocol.getGoodbyeBuffer();
@@ -914,7 +914,7 @@ public class ReplicationManager implements IReplicationManager {
         //stop replication thread afters all jobs/logs have been processed
         suspendReplication(false);
 
-        /**
+        /*
          * If this node has any remote replicas, it needs to inform them
          * that it is shutting down.
          */
@@ -923,7 +923,7 @@ public class ReplicationManager implements IReplicationManager {
             sendShutdownNotifiction();
         }
 
-        /**
+        /*
          * If this node has any remote primary replicas, then it needs to wait
          * until all of them send the shutdown notification.
          */
@@ -1051,7 +1051,7 @@ public class ReplicationManager implements IReplicationManager {
                     ReplicationProtocol.sendGoodbye(socketChannel);
                 }
 
-                /**
+                /*
                  * 4. update the LSN_MAP for indexes that were not flushed
                  * to the current append LSN to indicate no operations happened
                  * since the checkpoint start.

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/recovery/RemoteRecoveryManager.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/recovery/RemoteRecoveryManager.java b/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/recovery/RemoteRecoveryManager.java
index 7c7a050..df17987 100644
--- a/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/recovery/RemoteRecoveryManager.java
+++ b/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/recovery/RemoteRecoveryManager.java
@@ -97,10 +97,10 @@ public class RemoteRecoveryManager implements IRemoteRecoveryManager {
         Map<String, Set<String>> recoveryList = new HashMap<>();
 
         //3. find best candidate to recover from per lost replica data
-        for (Entry<String, Set<String>> entry : recoveryCandidates.entrySet()) {
+        recoveryCandidates.forEach((key, value) -> {
             int winnerScore = -1;
             String winner = "";
-            for (String node : entry.getValue()) {
+            for (String node : value) {
 
                 int nodeScore = candidatesScore.get(node);
 
@@ -111,14 +111,14 @@ public class RemoteRecoveryManager implements IRemoteRecoveryManager {
             }
 
             if (recoveryList.containsKey(winner)) {
-                recoveryList.get(winner).add(entry.getKey());
+                recoveryList.get(winner).add(key);
             } else {
                 Set<String> nodesToRecover = new HashSet<>();
-                nodesToRecover.add(entry.getKey());
+                nodesToRecover.add(key);
                 recoveryList.put(winner, nodesToRecover);
             }
 
-        }
+        });
 
         return recoveryList;
     }
@@ -146,7 +146,7 @@ public class RemoteRecoveryManager implements IRemoteRecoveryManager {
 
     @Override
     public void takeoverPartitons(Integer[] partitions) throws IOException, ACIDException {
-        /**
+        /*
          * TODO even though the takeover is always expected to succeed,
          * in case of any failure during the takeover, the CC should be
          * notified that the takeover failed.
@@ -227,7 +227,7 @@ public class RemoteRecoveryManager implements IRemoteRecoveryManager {
                 (ReplicaResourcesManager) runtimeContext.getReplicaResourcesManager();
         Map<String, ClusterPartition[]> nodePartitions = runtimeContext.getMetadataProperties().getNodePartitions();
 
-        /**
+        /*
          * for each lost partition, get the remaining files from replicas
          * to complete the failback process.
          */
@@ -251,7 +251,7 @@ public class RemoteRecoveryManager implements IRemoteRecoveryManager {
                 replicationManager.requestReplicaFiles(replicaId, partitionsToRecover, existingFiles);
             }
         } catch (IOException e) {
-            /**
+            /*
              * in case of failure during failback completion process we need to construct a new plan
              * and get all the files from the start since the remote replicas will change in the new plan.
              */

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/ClusterStateManager.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/ClusterStateManager.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/ClusterStateManager.java
index 6e55fd2..ac83b71 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/ClusterStateManager.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/utils/ClusterStateManager.java
@@ -462,11 +462,11 @@ public class ClusterStateManager implements IClusterStateManager {
     private void updateNodeConfig(String nodeId, Map<IOption, Object> configuration) {
         ConfigManager configManager = ((ConfigManagerApplicationConfig) appCtx.getServiceContext().getAppConfig())
                 .getConfigManager();
-        for (Map.Entry<IOption, Object> entry : configuration.entrySet()) {
-            if (entry.getKey().section() == Section.NC) {
-                configManager.set(nodeId, entry.getKey(), entry.getValue());
+        configuration.forEach((key, value) -> {
+            if (key.section() == Section.NC) {
+                configManager.set(nodeId, key, value);
             }
-        }
+        });
     }
 
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/asterixdb/asterix-test-framework/src/main/java/org/apache/asterix/testframework/template/TemplateHelper.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-test-framework/src/main/java/org/apache/asterix/testframework/template/TemplateHelper.java b/asterixdb/asterix-test-framework/src/main/java/org/apache/asterix/testframework/template/TemplateHelper.java
index b3f26fd..d2f52dc 100644
--- a/asterixdb/asterix-test-framework/src/main/java/org/apache/asterix/testframework/template/TemplateHelper.java
+++ b/asterixdb/asterix-test-framework/src/main/java/org/apache/asterix/testframework/template/TemplateHelper.java
@@ -41,15 +41,15 @@ public class TemplateHelper {
 
     private TemplateHelper() {
         registerReplacement(LoremIpsumReplacement.INSTANCE);
-        StringBuffer pattern = null;
-        for (Map.Entry<String, TemplateReplacement> entry : replacements.entrySet()) {
-            if (pattern == null) {
-                pattern = new StringBuffer("%(");
+        StringBuilder pattern = new StringBuilder();
+        replacements.forEach((key, value) -> {
+            if (pattern.length() == 0) {
+                pattern.append("%(");
             } else {
                 pattern.append("|");
             }
-            pattern.append(entry.getKey());
-        }
+            pattern.append(key);
+        });
         pattern.append(")[^%]*%");
         replacementPattern = Pattern.compile(pattern.toString());
     }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/resource/PersistentLocalResourceRepository.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/resource/PersistentLocalResourceRepository.java b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/resource/PersistentLocalResourceRepository.java
index 85ad6b4..5666b48 100644
--- a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/resource/PersistentLocalResourceRepository.java
+++ b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/resource/PersistentLocalResourceRepository.java
@@ -34,7 +34,6 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.Set;
 import java.util.SortedMap;
 import java.util.concurrent.ConcurrentHashMap;
@@ -128,9 +127,8 @@ public class PersistentLocalResourceRepository implements ILocalResourceReposito
                 .append(Character.LINE_SEPARATOR).append(ioManager.getClass().getSimpleName()).append(':')
                 .append(Character.LINE_SEPARATOR).append(ioManager.toString()).append(Character.LINE_SEPARATOR)
                 .append("Cached Resources:").append(Character.LINE_SEPARATOR);
-        for (Entry<String, LocalResource> pair : resourceCache.asMap().entrySet()) {
-            aString.append(pair.getKey()).append("->").append(pair.getValue()).append(Character.LINE_SEPARATOR);
-        }
+        resourceCache.asMap().forEach(
+                (key, value) -> aString.append(key).append("->").append(value).append(Character.LINE_SEPARATOR));
         return aString.toString();
     }
 

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/asterixdb/asterix-yarn/src/main/java/org/apache/asterix/aoya/AsterixApplicationMaster.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-yarn/src/main/java/org/apache/asterix/aoya/AsterixApplicationMaster.java b/asterixdb/asterix-yarn/src/main/java/org/apache/asterix/aoya/AsterixApplicationMaster.java
index 47cf3b3..4a900e1 100644
--- a/asterixdb/asterix-yarn/src/main/java/org/apache/asterix/aoya/AsterixApplicationMaster.java
+++ b/asterixdb/asterix-yarn/src/main/java/org/apache/asterix/aoya/AsterixApplicationMaster.java
@@ -230,10 +230,10 @@ public class AsterixApplicationMaster {
 
         LOG.info("Dump debug output");
         Map<String, String> envs = System.getenv();
-        for (Map.Entry<String, String> env : envs.entrySet()) {
-            LOG.info("System env: key=" + env.getKey() + ", val=" + env.getValue());
-            System.out.println("System env: key=" + env.getKey() + ", val=" + env.getValue());
-        }
+        envs.forEach((key, value) -> {
+            LOG.info("System env: key=" + key + ", val=" + value);
+            System.out.println("System env: key=" + key + ", val=" + value);
+        });
 
         String cmd = "ls -alhLR";
         Runtime run = Runtime.getRuntime();

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/8ecbff11/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/expressions/ConstantExpression.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/expressions/ConstantExpression.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/expressions/ConstantExpression.java
index 8f55632..689d51c 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/expressions/ConstantExpression.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/expressions/ConstantExpression.java
@@ -22,7 +22,6 @@ import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 
 import org.apache.commons.lang3.mutable.Mutable;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -172,10 +171,7 @@ public final class ConstantExpression extends AbstractLogicalExpression {
     @Override
     public AbstractLogicalExpression cloneExpression() {
         Map<Object, IExpressionAnnotation> m = new HashMap<>();
-        for (Entry<Object, IExpressionAnnotation> entry : annotationMap.entrySet()) {
-            IExpressionAnnotation annot2 = entry.getValue().copy();
-            m.put(entry.getKey(), annot2);
-        }
+        annotationMap.forEach((key, value1) -> m.put(key, value1.copy()));
         ConstantExpression c = new ConstantExpression(value);
         c.annotationMap = m;
         return c;


Mime
View raw message