mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlyubi...@apache.org
Subject svn commit: r1397251 - /mahout/trunk/core/src/main/java/org/apache/mahout/math/hadoop/stochasticsvd/SSVDCli.java
Date Thu, 11 Oct 2012 19:30:43 GMT
Author: dlyubimov
Date: Thu Oct 11 19:30:42 2012
New Revision: 1397251

URL: http://svn.apache.org/viewvc?rev=1397251&view=rev
Log:
MAHOUT-1097: 1) some results are not moved to output folder. 2) -ow flag was not working as
intended, fixed.

Modified:
    mahout/trunk/core/src/main/java/org/apache/mahout/math/hadoop/stochasticsvd/SSVDCli.java

Modified: mahout/trunk/core/src/main/java/org/apache/mahout/math/hadoop/stochasticsvd/SSVDCli.java
URL: http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/math/hadoop/stochasticsvd/SSVDCli.java?rev=1397251&r1=1397250&r2=1397251&view=diff
==============================================================================
--- mahout/trunk/core/src/main/java/org/apache/mahout/math/hadoop/stochasticsvd/SSVDCli.java
(original)
+++ mahout/trunk/core/src/main/java/org/apache/mahout/math/hadoop/stochasticsvd/SSVDCli.java
Thu Oct 11 19:30:42 2012
@@ -21,7 +21,6 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.util.ToolRunner;
@@ -59,10 +58,7 @@ public class SSVDCli extends AbstractJob
               "uhs",
               "Compute U * Sigma^0.5",
               String.valueOf(false));
-    addOption("uSigma",
-              "us",
-              "Compute U * Sigma",
-              String.valueOf(false));
+    addOption("uSigma", "us", "Compute U * Sigma", String.valueOf(false));
     addOption("computeV", "V", "compute V (true/false)", String.valueOf(true));
     addOption("vHalfSigma",
               "vhs",
@@ -149,26 +145,32 @@ public class SSVDCli extends AbstractJob
     // housekeeping
     FileSystem fs = FileSystem.get(getOutputPath().toUri(), conf);
 
+    if (overwrite) {
+      fs.delete(getOutputPath(), true);
+    }
+
     fs.mkdirs(getOutputPath());
 
     Vector svalues = solver.getSingularValues().viewPart(0, k);
     SSVDHelper.saveVector(svalues, getOutputPath("sigma"), conf);
 
-    if (computeU) {
-      FileStatus[] uFiles = fs.globStatus(new Path(solver.getUPath()));
-      if (uFiles != null) {
-        for (FileStatus uf : uFiles) {
-          fs.rename(uf.getPath(), getOutputPath());
-        }
-      }
-    }
-    if (computeV) {
-      FileStatus[] vFiles = fs.globStatus(new Path(solver.getVPath()));
-      if (vFiles != null) {
-        for (FileStatus vf : vFiles) {
-          fs.rename(vf.getPath(), getOutputPath());
-        }
-      }
+    if (computeU && !fs.rename(new Path(solver.getUPath()), getOutputPath())) {
+      throw new IOException("Unable to move U results to the output path.");
+    }
+    if (cUHalfSigma
+        && !fs.rename(new Path(solver.getuHalfSigmaPath()), getOutputPath())) {
+      throw new IOException("Unable to move U*Sigma^0.5 results to the output path.");
+    }
+    if (cUSigma
+        && !fs.rename(new Path(solver.getuSigmaPath()), getOutputPath())) {
+      throw new IOException("Unable to move U*Sigma results to the output path.");
+    }
+    if (computeV && !fs.rename(new Path(solver.getVPath()), getOutputPath())) {
+      throw new IOException("Unable to move V results to the output path.");
+    }
+    if (cVHalfSigma
+        && !fs.rename(new Path(solver.getvHalfSigmaPath()), getOutputPath())) {
+      throw new IOException("Unable to move V*Sigma^0.5 results to the output path.");
     }
     return 0;
   }



Mime
View raw message