You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by mb...@apache.org on 2016/05/24 05:57:58 UTC

incubator-asterixdb git commit: SONAR: Collection, misc fixes

Repository: incubator-asterixdb
Updated Branches:
  refs/heads/master 8afce8f68 -> af2199414


SONAR: Collection, misc fixes

Fixes for issue Inappropriate "Collection" calls should not be made, as well
as some other misc SonarLint suggestions while in these files.

Change-Id: Ie68a269bab4d1b2bdc628a5f09b9afff3882e09e
Reviewed-on: https://asterix-gerrit.ics.uci.edu/881
Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <ti...@apache.org>
Reviewed-by: Yingyi Bu <bu...@gmail.com>


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

Branch: refs/heads/master
Commit: af2199414b3aa7c445bf8d244542754b1dd37d8c
Parents: 8afce8f
Author: Michael Blow <mb...@apache.org>
Authored: Mon May 23 23:45:45 2016 -0400
Committer: Michael Blow <mi...@couchbase.com>
Committed: Mon May 23 22:57:43 2016 -0700

----------------------------------------------------------------------
 .../rules/PushAggregateIntoGroupbyRule.java     |  16 ++-
 .../asterix/event/util/PatternCreator.java      | 117 ++++++++-----------
 .../visitor/SqlppGroupBySugarVisitor.java       |   2 +-
 .../rules/ExtractCommonOperatorsRule.java       |  36 +++---
 .../hyracks/api/client/impl/PlanUtils.java      |   4 +-
 5 files changed, 85 insertions(+), 90 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/af219941/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushAggregateIntoGroupbyRule.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushAggregateIntoGroupbyRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushAggregateIntoGroupbyRule.java
index 2346b03..ed489e5 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushAggregateIntoGroupbyRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushAggregateIntoGroupbyRule.java
@@ -24,10 +24,13 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
 
 import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
 import org.apache.commons.lang3.mutable.Mutable;
 import org.apache.commons.lang3.mutable.MutableObject;
+import org.apache.hadoop.yarn.webapp.hamlet.HamletSpec;
 import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
 import org.apache.hyracks.algebricks.common.utils.Pair;
 import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
@@ -80,8 +83,10 @@ public class PushAggregateIntoGroupbyRule implements IAlgebraicRewriteRule {
     private void removeRedundantListifies(Mutable<ILogicalOperator> opRef, IOptimizationContext context,
             Map<LogicalVariable, Integer> gbyAggVars, Map<LogicalVariable, GroupByOperator> gbyWithAgg,
             Map<LogicalVariable, Integer> gbyAggVarToPlanIndex) throws AlgebricksException {
-        for (LogicalVariable aggVar : gbyAggVars.keySet()) {
-            int occurs = gbyAggVars.get(aggVar);
+        List<Pair<GroupByOperator, Integer>> removeList = new ArrayList<>();
+        for (Map.Entry<LogicalVariable, Integer> aggVarEntry : gbyAggVars.entrySet()) {
+            LogicalVariable aggVar = aggVarEntry.getKey();
+            int occurs = aggVarEntry.getValue();
             if (occurs == 0) {
                 GroupByOperator gbyOp = gbyWithAgg.get(aggVar);
                 AggregateOperator aggOp = (AggregateOperator) gbyOp.getNestedPlans()
@@ -90,14 +95,17 @@ public class PushAggregateIntoGroupbyRule implements IAlgebraicRewriteRule {
                 if (pos >= 0) {
                     aggOp.getVariables().remove(pos);
                     aggOp.getExpressions().remove(pos);
-                    List<LogicalVariable> producedVarsAtAgg = new ArrayList<LogicalVariable>();
+                    List<LogicalVariable> producedVarsAtAgg = new ArrayList<>();
                     VariableUtilities.getProducedVariablesInDescendantsAndSelf(aggOp, producedVarsAtAgg);
                     if (producedVarsAtAgg.isEmpty()) {
-                        gbyOp.getNestedPlans().remove(gbyAggVarToPlanIndex.get(aggVar));
+                        removeList.add(new Pair<>(gbyOp, gbyAggVarToPlanIndex.get(aggVar)));
                     }
                 }
             }
         }
+        for (Pair<GroupByOperator, Integer> remove : removeList) {
+            remove.first.getNestedPlans().remove((int)remove.second);
+        }
     }
 
     private boolean collectVarsBottomUp(Mutable<ILogicalOperator> opRef, IOptimizationContext context,

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/af219941/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/util/PatternCreator.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/util/PatternCreator.java b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/util/PatternCreator.java
index ce84cc8..b19a722 100644
--- a/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/util/PatternCreator.java
+++ b/asterixdb/asterix-events/src/main/java/org/apache/asterix/event/util/PatternCreator.java
@@ -48,23 +48,22 @@ import org.apache.asterix.installer.schema.conf.Backup;
 
 public class PatternCreator {
 
-    public static PatternCreator INSTANCE = new PatternCreator();
+    public static final PatternCreator INSTANCE = new PatternCreator();
 
     private PatternCreator() {
-
     }
 
     private ILookupService lookupService = ServiceProvider.INSTANCE.getLookupService();
 
     private void addInitialDelay(Pattern p, int delay, String unit) {
-        Delay d = new Delay(new Value(null, "" + delay), unit);
+        Delay d = new Delay(new Value(null, Integer.toString(delay)), unit);
         p.setDelay(d);
     }
 
     public Patterns getAsterixBinaryTransferPattern(String asterixInstanceName, Cluster cluster) throws Exception {
         String ccLocationIp = cluster.getMasterNode().getClusterIp();
         String destDir = cluster.getWorkingDir().getDir() + File.separator + "asterix";
-        List<Pattern> ps = new ArrayList<Pattern>();
+        List<Pattern> ps = new ArrayList<>();
 
         Pattern copyHyracks = createCopyHyracksPattern(asterixInstanceName, cluster, ccLocationIp, destDir);
         ps.add(copyHyracks);
@@ -79,14 +78,13 @@ public class PatternCreator {
             }
         }
         ps.addAll(createHadoopLibraryTransferPattern(cluster).getPattern());
-        Patterns patterns = new Patterns(ps);
-        return patterns;
+        return new Patterns(ps);
     }
 
     public Patterns getStartAsterixPattern(String asterixInstanceName, Cluster cluster, boolean createCommand)
             throws Exception {
         String ccLocationId = cluster.getMasterNode().getId();
-        List<Pattern> ps = new ArrayList<Pattern>();
+        List<Pattern> ps = new ArrayList<>();
 
         Pattern createCC = createCCStartPattern(ccLocationId);
         addInitialDelay(createCC, 3, "sec");
@@ -100,12 +98,11 @@ public class PatternCreator {
             ps.add(createNC);
         }
 
-        Patterns patterns = new Patterns(ps);
-        return patterns;
+        return new Patterns(ps);
     }
 
     public Patterns getStopCommandPattern(String asterixInstanceName) throws Exception {
-        List<Pattern> ps = new ArrayList<Pattern>();
+        List<Pattern> ps = new ArrayList<>();
         AsterixInstance asterixInstance = lookupService.getAsterixInstance(asterixInstanceName);
         Cluster cluster = asterixInstance.getCluster();
 
@@ -121,8 +118,7 @@ public class PatternCreator {
             nodeControllerIndex++;
         }
 
-        Patterns patterns = new Patterns(ps);
-        return patterns;
+        return new Patterns(ps);
     }
 
     public Patterns getBackUpAsterixPattern(AsterixInstance instance, Backup backupConf) throws Exception {
@@ -160,12 +156,12 @@ public class PatternCreator {
         String hdfsBackupDir = backupConf.getBackupDir();
         VerificationUtil.verifyBackupRestoreConfiguration(hdfsUrl, hadoopVersion, hdfsBackupDir);
         String workingDir = cluster.getWorkingDir().getDir();
-        String backupId = "" + instance.getBackupInfo().size();
+        String backupId = Integer.toString(instance.getBackupInfo().size());
         String store;
         String pargs;
         String iodevices;
         store = cluster.getStore();
-        List<Pattern> patternList = new ArrayList<Pattern>();
+        List<Pattern> patternList = new ArrayList<>();
         for (Node node : cluster.getNode()) {
             Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
             iodevices = node.getIodevices() == null ? instance.getCluster().getIodevices() : node.getIodevices();
@@ -183,13 +179,13 @@ public class PatternCreator {
         Cluster cluster = instance.getCluster();
         String backupDir = backupConf.getBackupDir();
         String workingDir = cluster.getWorkingDir().getDir();
-        String backupId = "" + instance.getBackupInfo().size();
+        String backupId = Integer.toString(instance.getBackupInfo().size());
         String iodevices;
         String txnLogDir;
         String store;
         String pargs;
         store = cluster.getStore();
-        List<Pattern> patternList = new ArrayList<Pattern>();
+        List<Pattern> patternList = new ArrayList<>();
         for (Node node : cluster.getNode()) {
             Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
             iodevices = node.getIodevices() == null ? instance.getCluster().getIodevices() : node.getIodevices();
@@ -213,7 +209,7 @@ public class PatternCreator {
         String workingDir = cluster.getWorkingDir().getDir();
         int backupId = backupInfo.getId();
         String pargs;
-        List<Pattern> patternList = new ArrayList<Pattern>();
+        List<Pattern> patternList = new ArrayList<>();
         for (Node node : cluster.getNode()) {
             Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
             String iodevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
@@ -234,7 +230,7 @@ public class PatternCreator {
         String workingDir = cluster.getWorkingDir().getDir();
         int backupId = backupInfo.getId();
         String pargs;
-        List<Pattern> patternList = new ArrayList<Pattern>();
+        List<Pattern> patternList = new ArrayList<>();
         for (Node node : cluster.getNode()) {
             Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
             String iodevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
@@ -248,7 +244,7 @@ public class PatternCreator {
     }
 
     public Patterns createHadoopLibraryTransferPattern(Cluster cluster) throws Exception {
-        List<Pattern> patternList = new ArrayList<Pattern>();
+        List<Pattern> patternList = new ArrayList<>();
         String workingDir = cluster.getWorkingDir().getDir();
         String hadoopVersion = AsterixEventService.getConfiguration().getBackup().getHdfs().getVersion();
         File hadoopDir = new File(AsterixEventService.getEventHome() + File.separator + "hadoop-" + hadoopVersion);
@@ -277,24 +273,23 @@ public class PatternCreator {
                 patternList.add(p);
             }
         }
-        Patterns patterns = new Patterns(patternList);
-        return patterns;
+        return new Patterns(patternList);
     }
 
     public Patterns createDeleteInstancePattern(AsterixInstance instance) throws Exception {
-        List<Pattern> patternList = new ArrayList<Pattern>();
+        List<Pattern> patternList = new ArrayList<>();
         patternList.addAll(createRemoveAsterixStoragePattern(instance).getPattern());
-        if (instance.getBackupInfo() != null && instance.getBackupInfo().size() > 0) {
+        if (instance.getBackupInfo() != null && !instance.getBackupInfo().isEmpty()) {
             List<BackupInfo> backups = instance.getBackupInfo();
-            Set<String> removedBackupDirsHDFS = new HashSet<String>();
-            Set<String> removedBackupDirsLocal = new HashSet<String>();
+            Set<String> removedBackupDirsHDFS = new HashSet<>();
+            Set<String> removedBackupDirsLocal = new HashSet<>();
 
             String backupDir;
             for (BackupInfo binfo : backups) {
                 backupDir = binfo.getBackupConf().getBackupDir();
                 switch (binfo.getBackupType()) {
                     case HDFS:
-                        if (removedBackupDirsHDFS.contains(backups)) {
+                        if (removedBackupDirsHDFS.contains(backupDir)) {
                             continue;
                         }
                         patternList.addAll(createRemoveHDFSBackupPattern(instance, backupDir).getPattern());
@@ -302,7 +297,7 @@ public class PatternCreator {
                         break;
 
                     case LOCAL:
-                        if (removedBackupDirsLocal.contains(backups)) {
+                        if (removedBackupDirsLocal.contains(backupDir)) {
                             continue;
                         }
                         patternList.addAll(createRemoveLocalBackupPattern(instance, backupDir).getPattern());
@@ -315,15 +310,14 @@ public class PatternCreator {
         patternList.addAll(createRemoveAsterixLogDirPattern(instance).getPattern());
         patternList.addAll(createRemoveAsterixRootMetadata(instance).getPattern());
         patternList.addAll(createRemoveAsterixTxnLogs(instance).getPattern());
-        Patterns patterns = new Patterns(patternList);
-        return patterns;
+        return new Patterns(patternList);
     }
 
     private Patterns createRemoveAsterixTxnLogs(AsterixInstance instance) throws Exception {
-        List<Pattern> patternList = new ArrayList<Pattern>();
+        List<Pattern> patternList = new ArrayList<>();
         Cluster cluster = instance.getCluster();
-        Nodeid nodeid = null;
-        Event event = null;
+        Nodeid nodeid;
+        Event event;
         for (Node node : cluster.getNode()) {
             String txnLogDir = node.getTxnLogDir() == null ? cluster.getTxnLogDir() : node.getTxnLogDir();
             nodeid = new Nodeid(new Value(null, node.getId()));
@@ -331,12 +325,11 @@ public class PatternCreator {
             patternList.add(new Pattern(null, 1, null, event));
         }
 
-        Patterns patterns = new Patterns(patternList);
-        return patterns;
+        return new Patterns(patternList);
     }
 
     private Patterns createRemoveHDFSBackupPattern(AsterixInstance instance, String hdfsBackupDir) throws Exception {
-        List<Pattern> patternList = new ArrayList<Pattern>();
+        List<Pattern> patternList = new ArrayList<>();
         Cluster cluster = instance.getCluster();
         String hdfsUrl = AsterixEventService.getConfiguration().getBackup().getHdfs().getUrl();
         String hadoopVersion = AsterixEventService.getConfiguration().getBackup().getHdfs().getVersion();
@@ -347,17 +340,16 @@ public class PatternCreator {
         String pargs = workingDir + " " + hadoopVersion + " " + hdfsUrl + " " + pathToDelete;
         Event event = new Event("hdfs_delete", nodeid, pargs);
         patternList.add(new Pattern(null, 1, null, event));
-        Patterns patterns = new Patterns(patternList);
-        return patterns;
+        return new Patterns(patternList);
     }
 
     private Patterns createRemoveLocalBackupPattern(AsterixInstance instance, String localBackupDir) throws Exception {
-        List<Pattern> patternList = new ArrayList<Pattern>();
+        List<Pattern> patternList = new ArrayList<>();
         Cluster cluster = instance.getCluster();
 
         String pathToDelete = localBackupDir + File.separator + instance.getName();
         String pargs = pathToDelete;
-        List<String> removedBackupDirs = new ArrayList<String>();
+        List<String> removedBackupDirs = new ArrayList<>();
         for (Node node : cluster.getNode()) {
             if (removedBackupDirs.contains(node.getClusterIp())) {
                 continue;
@@ -368,12 +360,11 @@ public class PatternCreator {
             removedBackupDirs.add(node.getClusterIp());
         }
 
-        Patterns patterns = new Patterns(patternList);
-        return patterns;
+        return new Patterns(patternList);
     }
 
     public Patterns createRemoveAsterixWorkingDirPattern(AsterixInstance instance) throws Exception {
-        List<Pattern> patternList = new ArrayList<Pattern>();
+        List<Pattern> patternList = new ArrayList<>();
         Cluster cluster = instance.getCluster();
         String workingDir = cluster.getWorkingDir().getDir();
         String pargs = workingDir;
@@ -388,13 +379,12 @@ public class PatternCreator {
                 patternList.add(new Pattern(null, 1, null, event));
             }
         }
-        Patterns patterns = new Patterns(patternList);
-        return patterns;
+        return new Patterns(patternList);
     }
 
     public Patterns getLibraryInstallPattern(AsterixInstance instance, String dataverse, String libraryName,
             String libraryPath) throws Exception {
-        List<Pattern> patternList = new ArrayList<Pattern>();
+        List<Pattern> patternList = new ArrayList<>();
         Cluster cluster = instance.getCluster();
         Nodeid nodeid = new Nodeid(new Value(null, EventDriver.CLIENT_NODE.getId()));
         String username = cluster.getUsername() != null ? cluster.getUsername() : System.getProperty("user.name");
@@ -431,7 +421,7 @@ public class PatternCreator {
 
     public Patterns getLibraryUninstallPattern(AsterixInstance instance, String dataverse, String libraryName)
             throws Exception {
-        List<Pattern> patternList = new ArrayList<Pattern>();
+        List<Pattern> patternList = new ArrayList<>();
         Cluster cluster = instance.getCluster();
         String workingDir = cluster.getWorkingDir().getDir();
         String destFile = dataverse + "." + libraryName;
@@ -472,11 +462,11 @@ public class PatternCreator {
     }
 
     private Patterns createRemoveAsterixRootMetadata(AsterixInstance instance) throws Exception {
-        List<Pattern> patternList = new ArrayList<Pattern>();
+        List<Pattern> patternList = new ArrayList<>();
         Cluster cluster = instance.getCluster();
-        Nodeid nodeid = null;
-        String pargs = null;
-        Event event = null;
+        Nodeid nodeid;
+        String pargs;
+        Event event;
         for (Node node : cluster.getNode()) {
             String iodevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
             String primaryIODevice = iodevices.split(",")[0].trim();
@@ -486,12 +476,11 @@ public class PatternCreator {
             patternList.add(new Pattern(null, 1, null, event));
         }
 
-        Patterns patterns = new Patterns(patternList);
-        return patterns;
+        return new Patterns(patternList);
     }
 
     private Patterns createRemoveAsterixLogDirPattern(AsterixInstance instance) throws Exception {
-        List<Pattern> patternList = new ArrayList<Pattern>();
+        List<Pattern> patternList = new ArrayList<>();
         Cluster cluster = instance.getCluster();
         String pargs = instance.getCluster().getLogDir();
         Nodeid nodeid = new Nodeid(new Value(null, cluster.getMasterNode().getId()));
@@ -507,14 +496,13 @@ public class PatternCreator {
             patternList.add(new Pattern(null, 1, null, event));
         }
 
-        Patterns patterns = new Patterns(patternList);
-        return patterns;
+        return new Patterns(patternList);
     }
 
     private Patterns createRemoveAsterixStoragePattern(AsterixInstance instance) throws Exception {
-        List<Pattern> patternList = new ArrayList<Pattern>();
+        List<Pattern> patternList = new ArrayList<>();
         Cluster cluster = instance.getCluster();
-        String pargs = null;
+        String pargs;
 
         for (Node node : cluster.getNode()) {
             Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
@@ -528,8 +516,7 @@ public class PatternCreator {
                 patternList.add(new Pattern(null, 1, null, event));
             }
         }
-        Patterns patterns = new Patterns(patternList);
-        return patterns;
+        return new Patterns(patternList);
     }
 
     private Pattern createCopyHyracksPattern(String instanceName, Cluster cluster, String destinationIp,
@@ -576,7 +563,7 @@ public class PatternCreator {
     }
 
     public Patterns createPrepareNodePattern(String instanceName, Cluster cluster, Node nodeToBeAdded) {
-        List<Pattern> ps = new ArrayList<Pattern>();
+        List<Pattern> ps = new ArrayList<>();
         boolean workingDirOnNFS = cluster.getWorkingDir().isNFS();
         if (!workingDirOnNFS) {
             String ccLocationIp = cluster.getMasterNode().getClusterIp();
@@ -609,13 +596,12 @@ public class PatternCreator {
             ps.add(p);
         }
 
-        Patterns patterns = new Patterns(ps);
-        return patterns;
+        return new Patterns(ps);
     }
 
     public Patterns getGenerateLogPattern(String asterixInstanceName, Cluster cluster, String outputDir) {
-        List<Pattern> patternList = new ArrayList<Pattern>();
-        Map<String, String> nodeLogs = new HashMap<String, String>();
+        List<Pattern> patternList = new ArrayList<>();
+        Map<String, String> nodeLogs = new HashMap<>();
 
         String username = cluster.getUsername() == null ? System.getProperty("user.name") : cluster.getUsername();
         String srcHost = cluster.getMasterNode().getClientIp();
@@ -640,7 +626,6 @@ public class PatternCreator {
             p = new Pattern(null, 1, null, event);
             patternList.add(p);
         }
-        Patterns patterns = new Patterns(patternList);
-        return patterns;
+        return new Patterns(patternList);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/af219941/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppGroupBySugarVisitor.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppGroupBySugarVisitor.java b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppGroupBySugarVisitor.java
index 6db1ea3..6c88a6a 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppGroupBySugarVisitor.java
+++ b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppGroupBySugarVisitor.java
@@ -118,7 +118,7 @@ public class SqlppGroupBySugarVisitor extends AbstractSqlppExpressionScopingVisi
         }
         Set<VariableExpr> definedVars = scopeChecker.getCurrentScope().getLiveVariables();
         Set<VariableExpr> vars = new HashSet<>(targetVars);
-        vars.remove(definedVars); // Exclude re-defined local variables.
+        vars.removeAll(definedVars); // Exclude re-defined local variables.
         Set<VariableExpr> freeVars = SqlppRewriteUtil.getFreeVariable(expr);
         if (!vars.containsAll(freeVars)) {
             return expr;

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/af219941/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/ExtractCommonOperatorsRule.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/ExtractCommonOperatorsRule.java b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/ExtractCommonOperatorsRule.java
index 3b31f6d..40fce90 100644
--- a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/ExtractCommonOperatorsRule.java
+++ b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/ExtractCommonOperatorsRule.java
@@ -52,12 +52,13 @@ import org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule;
 
 public class ExtractCommonOperatorsRule implements IAlgebraicRewriteRule {
 
-    private final HashMap<Mutable<ILogicalOperator>, List<Mutable<ILogicalOperator>>> childrenToParents = new HashMap<Mutable<ILogicalOperator>, List<Mutable<ILogicalOperator>>>();
-    private final List<Mutable<ILogicalOperator>> roots = new ArrayList<Mutable<ILogicalOperator>>();
-    private final List<List<Mutable<ILogicalOperator>>> equivalenceClasses = new ArrayList<List<Mutable<ILogicalOperator>>>();
-    private final HashMap<Mutable<ILogicalOperator>, BitSet> opToCandidateInputs = new HashMap<Mutable<ILogicalOperator>, BitSet>();
-    private final HashMap<Mutable<ILogicalOperator>, MutableInt> clusterMap = new HashMap<Mutable<ILogicalOperator>, MutableInt>();
-    private final HashMap<Integer, BitSet> clusterWaitForMap = new HashMap<Integer, BitSet>();
+    private final HashMap<Mutable<ILogicalOperator>, List<Mutable<ILogicalOperator>>> childrenToParents
+            = new HashMap<>();
+    private final List<Mutable<ILogicalOperator>> roots = new ArrayList<>();
+    private final List<List<Mutable<ILogicalOperator>>> equivalenceClasses = new ArrayList<>();
+    private final HashMap<Mutable<ILogicalOperator>, BitSet> opToCandidateInputs = new HashMap<>();
+    private final HashMap<Mutable<ILogicalOperator>, MutableInt> clusterMap = new HashMap<>();
+    private final HashMap<Integer, BitSet> clusterWaitForMap = new HashMap<>();
     private int lastUsedClusterId = 0;
 
     @Override
@@ -68,8 +69,9 @@ public class ExtractCommonOperatorsRule implements IAlgebraicRewriteRule {
                 && op.getOperatorTag() != LogicalOperatorTag.DISTRIBUTE_RESULT) {
             return false;
         }
-        if (!roots.contains(op)) {
-            roots.add(new MutableObject<ILogicalOperator>(op));
+        MutableObject<ILogicalOperator> mutableOp = new MutableObject<>(op);
+        if (!roots.contains(mutableOp)) {
+            roots.add(mutableOp);
         }
         return false;
     }
@@ -83,15 +85,15 @@ public class ExtractCommonOperatorsRule implements IAlgebraicRewriteRule {
             return false;
         }
         boolean rewritten = false;
-        boolean changed = false;
-        if (roots.size() > 0) {
+        boolean changed;
+        if (!roots.isEmpty()) {
             do {
                 changed = false;
                 // applying the rewriting until fixpoint
                 topDownMaterialization(roots);
                 genCandidates(context);
                 removeTrivialShare();
-                if (equivalenceClasses.size() > 0) {
+                if (!equivalenceClasses.isEmpty()) {
                     changed = rewrite(context);
                 }
                 if (!rewritten) {
@@ -296,28 +298,28 @@ public class ExtractCommonOperatorsRule implements IAlgebraicRewriteRule {
     }
 
     private void topDownMaterialization(List<Mutable<ILogicalOperator>> tops) {
-        List<Mutable<ILogicalOperator>> candidates = new ArrayList<Mutable<ILogicalOperator>>();
-        List<Mutable<ILogicalOperator>> nextLevel = new ArrayList<Mutable<ILogicalOperator>>();
+        List<Mutable<ILogicalOperator>> candidates = new ArrayList<>();
+        List<Mutable<ILogicalOperator>> nextLevel = new ArrayList<>();
         for (Mutable<ILogicalOperator> op : tops) {
             for (Mutable<ILogicalOperator> opRef : op.getValue().getInputs()) {
                 List<Mutable<ILogicalOperator>> opRefList = childrenToParents.get(opRef);
                 if (opRefList == null) {
-                    opRefList = new ArrayList<Mutable<ILogicalOperator>>();
+                    opRefList = new ArrayList<>();
                     childrenToParents.put(opRef, opRefList);
                     nextLevel.add(opRef);
                 }
                 opRefList.add(op);
             }
-            if (op.getValue().getInputs().size() == 0) {
+            if (op.getValue().getInputs().isEmpty()) {
                 candidates.add(op);
             }
         }
-        if (equivalenceClasses.size() > 0) {
+        if (!equivalenceClasses.isEmpty()) {
             equivalenceClasses.get(0).addAll(candidates);
         } else {
             equivalenceClasses.add(candidates);
         }
-        if (nextLevel.size() > 0) {
+        if (!nextLevel.isEmpty()) {
             topDownMaterialization(nextLevel);
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/af219941/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/client/impl/PlanUtils.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/client/impl/PlanUtils.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/client/impl/PlanUtils.java
index 401708a..6dc29c0 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/client/impl/PlanUtils.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/client/impl/PlanUtils.java
@@ -29,7 +29,7 @@ import org.apache.hyracks.api.job.JobSpecification;
 
 public class PlanUtils {
     public static void visit(JobSpecification spec, IOperatorDescriptorVisitor visitor) throws HyracksException {
-        Set<OperatorDescriptorId> seen = new HashSet<OperatorDescriptorId>();
+        Set<OperatorDescriptorId> seen = new HashSet<>();
         for (IOperatorDescriptor op : spec.getOperatorMap().values()) {
             visitOperator(visitor, seen, op);
         }
@@ -37,7 +37,7 @@ public class PlanUtils {
 
     private static void visitOperator(IOperatorDescriptorVisitor visitor, Set<OperatorDescriptorId> seen,
             IOperatorDescriptor op) throws HyracksException {
-        if (!seen.contains(op)) {
+        if (!seen.contains(op.getOperatorId())) {
             visitor.visit(op);
         }
         seen.add(op.getOperatorId());