asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Blow (Code Review)" <do-not-re...@asterixdb.incubator.apache.org>
Subject Change in asterixdb[master]: SONAR: Collection, misc fixes
Date Tue, 24 May 2016 00:47:19 GMT
Michael Blow has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/881

Change subject: SONAR: Collection, misc fixes
......................................................................

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
---
M asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/PushAggregateIntoGroupbyRule.java
M asterixdb/asterix-events/src/main/java/org/apache/asterix/event/util/PatternCreator.java
M asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/SqlppGroupBySugarVisitor.java
M hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/ExtractCommonOperatorsRule.java
M hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/client/impl/PlanUtils.java
5 files changed, 78 insertions(+), 90 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/81/881/1

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..892c6cc 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
@@ -80,8 +80,9 @@
     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);
+        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,10 +91,10 @@
                 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));
+                        gbyOp.getNestedPlans().remove((int)gbyAggVarToPlanIndex.get(aggVar));
                     }
                 }
             }
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 @@
 
 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 @@
             }
         }
         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 @@
             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 @@
             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 @@
         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 @@
         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 @@
         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 @@
         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 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 @@
                 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 @@
                         break;
 
                     case LOCAL:
-                        if (removedBackupDirsLocal.contains(backups)) {
+                        if (removedBackupDirsLocal.contains(backupDir)) {
                             continue;
                         }
                         patternList.addAll(createRemoveLocalBackupPattern(instance, backupDir).getPattern());
@@ -315,15 +310,14 @@
         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 @@
             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 @@
         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 @@
             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 @@
                 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 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 @@
     }
 
     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 @@
             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 @@
             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 @@
                 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 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 @@
             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 @@
             p = new Pattern(null, 1, null, event);
             patternList.add(p);
         }
-        Patterns patterns = new Patterns(patternList);
-        return patterns;
+        return new Patterns(patternList);
     }
 }
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 @@
         }
         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;
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 @@
 
 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 @@
                 && 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 @@
             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 @@
     }
 
     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);
         }
     }
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 @@
 
 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 @@
 
     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());

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/881
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie68a269bab4d1b2bdc628a5f09b9afff3882e09e
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: Michael Blow <michael.blow@couchbase.com>

Mime
View raw message