hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From na...@apache.org
Subject svn commit: r1550883 - /hive/trunk/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java
Date Sat, 14 Dec 2013 06:48:49 GMT
Author: navis
Date: Sat Dec 14 06:48:48 2013
New Revision: 1550883

URL: http://svn.apache.org/r1550883
Log:
HIVE-5985 : Make qfile_regex to accept multiple patterns (Navis reviewed by Ashutosh Chauhan)

Modified:
    hive/trunk/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java

Modified: hive/trunk/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java
URL: http://svn.apache.org/viewvc/hive/trunk/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java?rev=1550883&r1=1550882&r2=1550883&view=diff
==============================================================================
--- hive/trunk/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java (original)
+++ hive/trunk/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java Sat Dec 14 06:48:48 2013
@@ -314,7 +314,7 @@ public class QTestGenTask extends Task {
       includeOnly = new HashSet<String>(Arrays.asList(includeQueryFile.split(",")));
     }
 
-    List<File> qFiles = new ArrayList<File>();
+    List<File> qFiles;
     HashMap<String, String> qFilesMap = new HashMap<String, String>();
     File hiveRootDir = null;
     File queryDir = null;
@@ -323,38 +323,41 @@ public class QTestGenTask extends Task {
     File logDir = null;
     
     try {
-      if (queryDirectory != null) {
-        queryDir = new File(queryDirectory);
-      }
+      // queryDirectory should not be null
+      queryDir = new File(queryDirectory);
 
+      // dedup file list
+      Set<File> testFiles = new HashSet<File>();
       if (queryFile != null && !queryFile.equals("")) {
-        // The user may have passed a list of files - comma seperated
+        // The user may have passed a list of files - comma separated
         for (String qFile : queryFile.split(",")) {
           if (includeOnly != null && !includeOnly.contains(qFile)) {
             continue;
           }
           if (null != queryDir) {
-            qFiles.add(new File(queryDir, qFile));
+            testFiles.add(new File(queryDir, qFile));
           } else {
-            qFiles.add(new File(qFile));
+            testFiles.add(new File(qFile));
           }
         }
       } else if (queryFileRegex != null && !queryFileRegex.equals("")) {
-        qFiles.addAll(Arrays.asList(queryDir.listFiles(
-            new QFileRegexFilter(queryFileRegex, includeOnly))));
+        for (String regex : queryFileRegex.split(",")) {
+          testFiles.addAll(Arrays.asList(queryDir.listFiles(
+              new QFileRegexFilter(regex, includeOnly))));
+        }
       } else if (runDisabled != null && runDisabled.equals("true")) {
-        qFiles.addAll(Arrays.asList(queryDir.listFiles(new DisabledQFileFilter(includeOnly))));
+        testFiles.addAll(Arrays.asList(queryDir.listFiles(new DisabledQFileFilter(includeOnly))));
       } else {
-        qFiles.addAll(Arrays.asList(queryDir.listFiles(new QFileFilter(includeOnly))));
+        testFiles.addAll(Arrays.asList(queryDir.listFiles(new QFileFilter(includeOnly))));
       }
 
       if (excludeQueryFile != null && !excludeQueryFile.equals("")) {
         // Exclude specified query files, comma separated
         for (String qFile : excludeQueryFile.split(",")) {
           if (null != queryDir) {
-            qFiles.remove(new File(queryDir, qFile));
+            testFiles.remove(new File(queryDir, qFile));
           } else {
-            qFiles.remove(new File(qFile));
+            testFiles.remove(new File(qFile));
           }
         }
       }
@@ -364,7 +367,8 @@ public class QTestGenTask extends Task {
         throw new BuildException("Hive Root Directory "
             + hiveRootDir.getCanonicalPath() + " does not exist");
       }
-      
+
+      qFiles = new ArrayList<File>(testFiles);
       Collections.sort(qFiles);
       for (File qFile : qFiles) {
         qFilesMap.put(qFile.getName(), relativePath(hiveRootDir, qFile));
@@ -409,7 +413,7 @@ public class QTestGenTask extends Task {
       Template t = ve.getTemplate(template);
 
       if (clusterMode == null) {
-        clusterMode = new String("");
+        clusterMode = "";
       }
       if (hadoopVersion == null) {
         hadoopVersion = "";



Mime
View raw message