hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From na...@apache.org
Subject svn commit: r1438894 - in /hive/trunk: ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java build-common.xml ql/build.xml
Date Sat, 26 Jan 2013 13:56:34 GMT
Author: namit
Date: Sat Jan 26 13:56:34 2013
New Revision: 1438894

URL: http://svn.apache.org/viewvc?rev=1438894&view=rev
Log:
HIVE-3944 Make accept qfile argument for miniMR tests
(Navis via namit)


Modified:
    hive/trunk/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java
    hive/trunk/build-common.xml
    hive/trunk/ql/build.xml

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=1438894&r1=1438893&r2=1438894&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 Jan 26 13:56:34 2013
@@ -23,7 +23,8 @@ import java.io.File;
 import java.io.FileFilter;
 import java.io.FileWriter;
 import java.io.IOException;
-import java.util.StringTokenizer;
+import java.util.HashSet;
+import java.util.Set;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
@@ -32,10 +33,8 @@ import java.util.regex.Pattern;
 import java.util.HashMap;
 
 import org.apache.commons.lang.StringUtils;
-import org.apache.tools.ant.AntClassLoader;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Task;
-import org.apache.tools.ant.Project;
 
 import org.apache.velocity.app.VelocityEngine;
 import org.apache.velocity.Template;
@@ -47,9 +46,28 @@ import org.apache.velocity.runtime.Runti
 
 public class QTestGenTask extends Task {
 
-  public class QFileFilter implements FileFilter {
-  
+  public class IncludeFilter implements FileFilter {
+
+    Set<String> includeOnly;
+    public IncludeFilter(Set<String> includeOnly) {
+      this.includeOnly = includeOnly;
+    }
+
     public boolean accept(File fpath) {
+      return includeOnly == null || includeOnly.contains(fpath.getName());
+    }
+  }
+
+  public class QFileFilter extends IncludeFilter {
+
+    public QFileFilter(Set<String> includeOnly) {
+      super(includeOnly);
+    }
+
+    public boolean accept(File fpath) {
+      if (!super.accept(fpath)) {
+        return false;
+      }
       if (fpath.isDirectory() ||
           !fpath.getName().endsWith(".q")) {
         return false;
@@ -59,8 +77,15 @@ public class QTestGenTask extends Task {
     
   }
   
-  public class DisabledQFileFilter implements FileFilter { 
+  public class DisabledQFileFilter extends IncludeFilter {
+    public DisabledQFileFilter(Set<String> includeOnly) {
+      super(includeOnly);
+    }
+
     public boolean accept(File fpath) {
+      if (!super.accept(fpath)) {
+        return false;
+      }
       return !fpath.isDirectory() && fpath.getName().endsWith(".q.disabled");
     }  
   }
@@ -68,7 +93,8 @@ public class QTestGenTask extends Task {
   public class QFileRegexFilter extends QFileFilter {
     Pattern filterPattern;
     
-    public QFileRegexFilter(String filter) {
+    public QFileRegexFilter(String filter, Set<String> includeOnly) {
+      super(includeOnly);
       filterPattern = Pattern.compile(filter);
     }
     
@@ -89,6 +115,8 @@ public class QTestGenTask extends Task {
  
   private String queryFile;
 
+  private String includeQueryFile;
+
   private String excludeQueryFile;
   
   private String queryFileRegex;
@@ -213,6 +241,14 @@ public class QTestGenTask extends Task {
     return queryFile;
   }
 
+  public String getIncludeQueryFile() {
+    return includeQueryFile;
+  }
+
+  public void setIncludeQueryFile(String includeQueryFile) {
+    this.includeQueryFile = includeQueryFile;
+  }
+
   public void setExcludeQueryFile(String excludeQueryFile) {
     this.excludeQueryFile = excludeQueryFile;
   }
@@ -259,6 +295,11 @@ public class QTestGenTask extends Task {
       throw new BuildException("No className specified");
     }
 
+    Set<String> includeOnly = null;
+    if (includeQueryFile != null && !includeQueryFile.isEmpty()) {
+      includeOnly = new HashSet<String>(Arrays.asList(includeQueryFile.split(",")));
+    }
+
     List<File> qFiles = new ArrayList<File>();
     HashMap<String, String> qFilesMap = new HashMap<String, String>();
     File outDir = null;
@@ -274,6 +315,9 @@ public class QTestGenTask extends Task {
       if (queryFile != null && !queryFile.equals("")) {
         // The user may have passed a list of files - comma seperated
         for (String qFile : queryFile.split(",")) {
+          if (includeOnly != null && !includeOnly.contains(qFile)) {
+            continue;
+          }
           if (null != inpDir) {
             qFiles.add(new File(inpDir, qFile));
           } else {
@@ -281,11 +325,12 @@ public class QTestGenTask extends Task {
           }
         }
       } else if (queryFileRegex != null && !queryFileRegex.equals("")) {
-        qFiles.addAll(Arrays.asList(inpDir.listFiles(new QFileRegexFilter(queryFileRegex))));
+        qFiles.addAll(Arrays.asList(inpDir.listFiles(
+            new QFileRegexFilter(queryFileRegex, includeOnly))));
       } else if (runDisabled != null && runDisabled.equals("true")) {
-        qFiles.addAll(Arrays.asList(inpDir.listFiles(new DisabledQFileFilter())));
+        qFiles.addAll(Arrays.asList(inpDir.listFiles(new DisabledQFileFilter(includeOnly))));
       } else {
-        qFiles.addAll(Arrays.asList(inpDir.listFiles(new QFileFilter())));
+        qFiles.addAll(Arrays.asList(inpDir.listFiles(new QFileFilter(includeOnly))));
       }
 
       if (excludeQueryFile != null && !excludeQueryFile.equals("")) {

Modified: hive/trunk/build-common.xml
URL: http://svn.apache.org/viewvc/hive/trunk/build-common.xml?rev=1438894&r1=1438893&r2=1438894&view=diff
==============================================================================
--- hive/trunk/build-common.xml (original)
+++ hive/trunk/build-common.xml Sat Jan 26 13:56:34 2013
@@ -334,6 +334,12 @@
       </not>
     </condition>
 
+    <condition property="qfile_negative_regex" value="">
+      <not>
+        <isset property="qfile_negative_regex"/>
+      </not>
+    </condition>
+
     <condition property="overwrite" value="false">
       <not>
         <isset property="overwrite"/>

Modified: hive/trunk/ql/build.xml
URL: http://svn.apache.org/viewvc/hive/trunk/ql/build.xml?rev=1438894&r1=1438893&r2=1438894&view=diff
==============================================================================
--- hive/trunk/ql/build.xml (original)
+++ hive/trunk/ql/build.xml Sat Jan 26 13:56:34 2013
@@ -90,7 +90,8 @@
         <qtestgen outputDirectory="${test.build.src}/org/apache/hadoop/hive/cli" 
                   templatePath="${ql.test.template.dir}" template="TestCliDriver.vm" 
                   queryDirectory="${ql.test.query.clientpositive.dir}" 
-                  queryFile="${minimr.query.files}"
+                  queryFile="${qfile}"
+                  includeQueryFile="${minimr.query.files}"
                   queryFileRegex="${qfile_regex}"
                   clusterMode="miniMR"
                   runDisabled="${run_disabled}"
@@ -102,8 +103,9 @@
 
         <qtestgen outputDirectory="${test.build.src}/org/apache/hadoop/hive/cli" 
                   templatePath="${ql.test.template.dir}" template="TestNegativeCliDriver.vm"

-                  queryDirectory="${ql.test.query.dir}/clientnegative" 
-                  queryFile="${minimr.query.negative.files}"
+                  queryDirectory="${ql.test.query.dir}/clientnegative"
+                  queryFile="${qfile}"
+                  includeQueryFile="${minimr.query.negative.files}"
                   queryFileRegex="${qfile_negative_regex}"
                   clusterMode="miniMR"
                   runDisabled="${run_disabled}"



Mime
View raw message