mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From isa...@apache.org
Subject svn commit: r1488627 [2/2] - in /mahout/trunk: ./ core/src/test/java/org/apache/mahout/cf/taste/hadoop/item/ core/src/test/java/org/apache/mahout/cf/taste/hadoop/similarity/item/ core/src/test/java/org/apache/mahout/classifier/naivebayes/ core/src/test...
Date Sat, 01 Jun 2013 22:24:04 GMT
Modified: mahout/trunk/integration/src/test/java/org/apache/mahout/utils/SplitInputTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/integration/src/test/java/org/apache/mahout/utils/SplitInputTest.java?rev=1488627&r1=1488626&r2=1488627&view=diff
==============================================================================
--- mahout/trunk/integration/src/test/java/org/apache/mahout/utils/SplitInputTest.java (original)
+++ mahout/trunk/integration/src/test/java/org/apache/mahout/utils/SplitInputTest.java Sat
Jun  1 22:24:03 2013
@@ -33,6 +33,7 @@ import org.apache.hadoop.io.IntWritable;
 import org.apache.hadoop.io.SequenceFile;
 import org.apache.hadoop.io.Text;
 import org.apache.hadoop.io.Writable;
+import org.apache.hadoop.util.ToolRunner;
 import org.apache.mahout.classifier.ClassifierData;
 import org.apache.mahout.common.Pair;
 import org.apache.mahout.common.iterator.sequencefile.SequenceFileIterable;
@@ -60,7 +61,7 @@ public final class SplitInputTest extend
   @Override
   @Before
   public void setUp() throws Exception {
-    Configuration conf = new Configuration();
+    Configuration conf = getConfiguration();
     fs = FileSystem.get(conf);
 
     super.setUp();
@@ -190,7 +191,7 @@ public final class SplitInputTest extend
   private void writeVectorSequenceFile(Path path, int testPoints)
       throws IOException {
     Path tempSequenceFile = new Path(path, "part-00000");
-    Configuration conf = new Configuration();
+    Configuration conf = getConfiguration();
     IntWritable key = new IntWritable();
     VectorWritable value = new VectorWritable();
     SequenceFile.Writer writer = null;
@@ -219,7 +220,7 @@ public final class SplitInputTest extend
   private void writeTextSequenceFile(Path path, int testPoints)
       throws IOException {
     Path tempSequenceFile = new Path(path, "part-00000");
-    Configuration conf = new Configuration();
+    Configuration conf = getConfiguration();
     Text key = new Text();
     Text value = new Text();
     SequenceFile.Writer writer = null;
@@ -241,8 +242,8 @@ public final class SplitInputTest extend
    * Display contents of a SequenceFile
    * @param sequenceFilePath path to SequenceFile
    */
-  private static void displaySequenceFile(Path sequenceFilePath) {
-    for (Pair<?,?> record : new SequenceFileIterable<Writable,Writable>(sequenceFilePath,
true, new Configuration())) {
+  private void displaySequenceFile(Path sequenceFilePath) throws IOException {
+    for (Pair<?,?> record : new SequenceFileIterable<Writable,Writable>(sequenceFilePath,
true, getConfiguration())) {
       System.out.println(record.getFirst() + "\t" + record.getSecond());
     }
   }
@@ -252,9 +253,9 @@ public final class SplitInputTest extend
    * @param sequenceFilePath path to SequenceFile
    * @return number of records
    */
-  private static int getNumberRecords(Path sequenceFilePath) {
+  private int getNumberRecords(Path sequenceFilePath) throws IOException {
     int numberRecords = 0;
-    for (Object value : new SequenceFileValueIterable<Writable>(sequenceFilePath, true,
new Configuration())) {
+    for (Object value : new SequenceFileValueIterable<Writable>(sequenceFilePath, true,
getConfiguration())) {
       numberRecords++;
     }
     return numberRecords;
@@ -311,7 +312,7 @@ public final class SplitInputTest extend
             "--mapRedOutputDir", tempMapRedOutputDirectory.toString(),
             "--randomSelectionPct", Integer.toString(randomSelectionPct),
             "--keepPct", Integer.toString(keepPct), "-ow" };
-    SplitInput.main(args);
+    ToolRunner.run(getConfiguration(), new SplitInput(), args);
     validateSplitInputMapReduce(numPoints, randomSelectionPct, keepPct);
   }
 
@@ -325,7 +326,7 @@ public final class SplitInputTest extend
     si.setKeepPct(keepPct);
     si.setMapRedOutputDirectory(tempMapRedOutputDirectory);
     si.setUseMapRed(true);
-    si.splitDirectory(tempSequenceDirectory);
+    si.splitDirectory(getConfiguration(), tempSequenceDirectory);
 
     validateSplitInputMapReduce(numPoints, randomSelectionPct, keepPct);
   }
@@ -334,7 +335,7 @@ public final class SplitInputTest extend
    * Validate that number of test records and number of training records
    * are consistant with keepPct and randomSelectionPct
    */
-  private void validateSplitInputMapReduce(int numPoints, int randomSelectionPct, int keepPct)
{
+  private void validateSplitInputMapReduce(int numPoints, int randomSelectionPct, int keepPct)
throws IOException {
     Path testPath = new Path(tempMapRedOutputDirectory, "test-r-00000");
     Path trainingPath = new Path(tempMapRedOutputDirectory, "training-r-00000");
     int numberTestRecords = getNumberRecords(testPath);

Modified: mahout/trunk/math/src/test/java/org/apache/mahout/math/MahoutTestCase.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/test/java/org/apache/mahout/math/MahoutTestCase.java?rev=1488627&r1=1488626&r2=1488627&view=diff
==============================================================================
--- mahout/trunk/math/src/test/java/org/apache/mahout/math/MahoutTestCase.java (original)
+++ mahout/trunk/math/src/test/java/org/apache/mahout/math/MahoutTestCase.java Sat Jun  1
22:24:03 2013
@@ -51,10 +51,13 @@ public abstract class MahoutTestCase ext
 
   protected final File getTestTempDir() throws IOException {
     if (testTempDir == null) {
-      String systemTmpDir = System.getProperty("java.io.tmpdir");
+      String systemTmpDir = System.getProperty("mahout.test.directory");
+      if (systemTmpDir == null)
+    	systemTmpDir = "target/";
+      systemTmpDir += "test-data";
       long simpleRandomLong = (long) (Long.MAX_VALUE * Math.random());
       testTempDir = new File(systemTmpDir, "mahout-" + getClass().getSimpleName() + '-' +
simpleRandomLong);
-      if (!testTempDir.mkdir()) {
+      if (!testTempDir.mkdirs()) {
         throw new IOException("Could not create " + testTempDir);
       }
       testTempDir.deleteOnExit();

Modified: mahout/trunk/pom.xml
URL: http://svn.apache.org/viewvc/mahout/trunk/pom.xml?rev=1488627&r1=1488626&r2=1488627&view=diff
==============================================================================
--- mahout/trunk/pom.xml (original)
+++ mahout/trunk/pom.xml Sat Jun  1 22:24:03 2013
@@ -677,6 +677,9 @@
           <argLine>-Xms256m -Xmx1800m</argLine>
           <testFailureIgnore>false</testFailureIgnore>
           <redirectTestOutputToFile>true</redirectTestOutputToFile>
+          <systemPropertyVariables>
+            <mahout.test.directory>${project.build.directory}</mahout.test.directory>
+          </systemPropertyVariables>
         </configuration>
       </plugin>
       <plugin>



Mime
View raw message