Return-Path: X-Original-To: apmail-mahout-commits-archive@www.apache.org Delivered-To: apmail-mahout-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7602BD0E9 for ; Thu, 11 Oct 2012 19:31:31 +0000 (UTC) Received: (qmail 40538 invoked by uid 500); 11 Oct 2012 19:31:31 -0000 Delivered-To: apmail-mahout-commits-archive@mahout.apache.org Received: (qmail 40415 invoked by uid 500); 11 Oct 2012 19:31:30 -0000 Mailing-List: contact commits-help@mahout.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@mahout.apache.org Delivered-To: mailing list commits@mahout.apache.org Received: (qmail 40405 invoked by uid 99); 11 Oct 2012 19:31:30 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Oct 2012 19:31:30 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Oct 2012 19:31:27 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 3F71523889BB; Thu, 11 Oct 2012 19:30:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@mahout.apache.org From: dlyubimov@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121011193043.3F71523889BB@eris.apache.org> 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; }