incubator-hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edwardy...@apache.org
Subject svn commit: r768873 - in /incubator/hama/trunk: CHANGES.txt src/examples/org/apache/hama/examples/ExampleDriver.java src/examples/org/apache/hama/examples/MatrixNorm1.java src/java/org/apache/hama/AbstractMatrix.java
Date Mon, 27 Apr 2009 06:21:36 GMT
Author: edwardyoon
Date: Mon Apr 27 06:21:35 2009
New Revision: 768873

URL: http://svn.apache.org/viewvc?rev=768873&view=rev
Log:
Add example of norm

Added:
    incubator/hama/trunk/src/examples/org/apache/hama/examples/MatrixNorm1.java
Modified:
    incubator/hama/trunk/CHANGES.txt
    incubator/hama/trunk/src/examples/org/apache/hama/examples/ExampleDriver.java
    incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java

Modified: incubator/hama/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/CHANGES.txt?rev=768873&r1=768872&r2=768873&view=diff
==============================================================================
--- incubator/hama/trunk/CHANGES.txt (original)
+++ incubator/hama/trunk/CHANGES.txt Mon Apr 27 06:21:35 2009
@@ -38,6 +38,7 @@
 
   IMPROVEMENTS
 
+    HAMA-178: Add example of norm (edwardyoon)
     HAMA-158: Implementation of random sparse matrix (edwardyoon)
     HAMA-164: Example for C = Alpha*B + A (edwardyoon)
     HAMA-154: Combine multi-mapreduce jobs into a single mapreduce job 

Modified: incubator/hama/trunk/src/examples/org/apache/hama/examples/ExampleDriver.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/examples/org/apache/hama/examples/ExampleDriver.java?rev=768873&r1=768872&r2=768873&view=diff
==============================================================================
--- incubator/hama/trunk/src/examples/org/apache/hama/examples/ExampleDriver.java (original)
+++ incubator/hama/trunk/src/examples/org/apache/hama/examples/ExampleDriver.java Mon Apr
27 06:21:35 2009
@@ -30,6 +30,7 @@
       pgd.addClass("add", MatrixAddition.class, "Mat-Mat addition.");
       pgd.addClass("mult", MatrixMultiplication.class, "Mat-Mat multiplication.");
       pgd.addClass("multfiles", FileMatrixBlockMult.class, "file matrices multiplication.");
+      pgd.addClass("norm", MatrixNorm1.class, "Maximum absolute row sum of matrix");
       pgd.driver(args);
     } catch (Throwable e) {
       e.printStackTrace();

Added: incubator/hama/trunk/src/examples/org/apache/hama/examples/MatrixNorm1.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/examples/org/apache/hama/examples/MatrixNorm1.java?rev=768873&view=auto
==============================================================================
--- incubator/hama/trunk/src/examples/org/apache/hama/examples/MatrixNorm1.java (added)
+++ incubator/hama/trunk/src/examples/org/apache/hama/examples/MatrixNorm1.java Mon Apr 27
06:21:35 2009
@@ -0,0 +1,43 @@
+/**
+ * Copyright 2007 The Apache Software Foundation
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hama.examples;
+
+import java.io.IOException;
+
+import org.apache.hama.HamaAdmin;
+import org.apache.hama.HamaAdminImpl;
+import org.apache.hama.Matrix;
+import org.apache.hama.Matrix.Norm;
+
+public class MatrixNorm1 extends AbstractExample {
+  public static void main(String[] args) throws IOException {
+    if (args.length < 1) {
+      System.out.println("norm [-m maps] [-r reduces] <matrix name>");
+      System.exit(-1);
+    } else {
+      parseArgs(args);
+    }
+
+    HamaAdmin admin = new HamaAdminImpl(conf);
+    Matrix a = admin.getMatrix(ARGS.get(0));
+    System.out.println("The maximum absolute row sum of matrix '" + ARGS.get(0)
+        + "' is " + a.norm(Norm.One));
+  }
+}

Modified: incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java?rev=768873&r1=768872&r2=768873&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java Mon Apr 27 06:21:35
2009
@@ -167,7 +167,7 @@
     jobConf.setJobName("norm1 MR job : " + this.getPath());
 
     jobConf.setNumMapTasks(config.getNumMapTasks());
-    jobConf.setNumReduceTasks(config.getNumReduceTasks());
+    jobConf.setNumReduceTasks(1);
     
     final FileSystem fs = FileSystem.get(jobConf);
     final Path outDir = new Path(new Path(getType() + "_TMP_norm1_dir"), "out");
@@ -191,7 +191,7 @@
       reader.close();
     }
 
-    fs.delete(outDir, true);
+    fs.delete(outDir.getParent(), true);
     return max.get();
   }
   



Mime
View raw message