You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hama.apache.org by ed...@apache.org on 2008/08/26 04:08:01 UTC
svn commit: r688938 - in /incubator/hama/trunk/src: java/org/apache/hama/
java/org/apache/hama/algebra/ java/org/apache/hama/io/
java/org/apache/hama/mapred/ test/org/apache/hama/
Author: edwardyoon
Date: Mon Aug 25 19:08:00 2008
New Revision: 688938
URL: http://svn.apache.org/viewvc?rev=688938&view=rev
Log:
Remove findbugs warnings.
Modified:
incubator/hama/trunk/src/java/org/apache/hama/DenseVector.java
incubator/hama/trunk/src/java/org/apache/hama/algebra/AdditionMap.java
incubator/hama/trunk/src/java/org/apache/hama/io/VectorWritable.java
incubator/hama/trunk/src/java/org/apache/hama/mapred/DenseMap.java
incubator/hama/trunk/src/java/org/apache/hama/mapred/MatrixInputFormatBase.java
incubator/hama/trunk/src/test/org/apache/hama/TestVector.java
Modified: incubator/hama/trunk/src/java/org/apache/hama/DenseVector.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/DenseVector.java?rev=688938&r1=688937&r2=688938&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/DenseVector.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/DenseVector.java Mon Aug 25 19:08:00 2008
@@ -1,3 +1,22 @@
+/**
+ * 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;
import java.util.Iterator;
@@ -7,7 +26,6 @@
import org.apache.hadoop.hbase.io.Cell;
import org.apache.hadoop.hbase.io.HbaseMapWritable;
import org.apache.hadoop.hbase.io.RowResult;
-import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hama.io.VectorWritable;
import org.apache.hama.util.Numeric;
import org.apache.log4j.Logger;
@@ -19,7 +37,7 @@
this(null, new HbaseMapWritable<byte[], Cell>());
}
- public DenseVector(final byte[] rowKey, final HbaseMapWritable<byte[], Cell> m) {
+ public DenseVector(final byte[] row, final HbaseMapWritable<byte[], Cell> m) {
this.row = row;
this.cells = m;
}
@@ -58,7 +76,7 @@
for (int i = 0; i < this.size(); i++) {
double value = (this.get(i) + v2.get(i));
Cell cValue = new Cell(String.valueOf(value), System.currentTimeMillis());
- trunk.put(Bytes.toBytes("column:" + i), cValue);
+ trunk.put(Numeric.getColumnIndex(i), cValue);
}
return new DenseVector(row, trunk);
@@ -112,7 +130,8 @@
}
public DenseVector set(Vector v) {
- return new DenseVector(((DenseVector) v).getRow(), ((DenseVector) v).getCells());
+ return new DenseVector(((DenseVector) v).getRow(), ((DenseVector) v)
+ .getCells());
}
public double getNorm1() {
@@ -151,4 +170,4 @@
// TODO Auto-generated method stub
return 0;
}
-}
\ No newline at end of file
+}
Modified: incubator/hama/trunk/src/java/org/apache/hama/algebra/AdditionMap.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/algebra/AdditionMap.java?rev=688938&r1=688937&r2=688938&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/algebra/AdditionMap.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/algebra/AdditionMap.java Mon Aug 25 19:08:00 2008
@@ -32,7 +32,7 @@
public class AdditionMap extends DenseMap<ImmutableBytesWritable, DenseVector> {
@Override
- public void map(ImmutableBytesWritable key, Vector value,
+ public void map(ImmutableBytesWritable key, DenseVector value,
OutputCollector<ImmutableBytesWritable, DenseVector> output,
Reporter reporter) throws IOException {
@@ -40,4 +40,5 @@
output.collect(key, (DenseVector) v1.add(value));
}
+
}
Modified: incubator/hama/trunk/src/java/org/apache/hama/io/VectorWritable.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/io/VectorWritable.java?rev=688938&r1=688937&r2=688938&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/io/VectorWritable.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/io/VectorWritable.java Mon Aug 25 19:08:00 2008
@@ -173,7 +173,7 @@
* The inner class for an entry of row.
*
*/
- public class Entries implements Map.Entry<byte[], Cell> {
+ public static class Entries implements Map.Entry<byte[], Cell> {
private final byte[] column;
private final Cell cell;
Modified: incubator/hama/trunk/src/java/org/apache/hama/mapred/DenseMap.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/mapred/DenseMap.java?rev=688938&r1=688937&r2=688938&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/mapred/DenseMap.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/mapred/DenseMap.java Mon Aug 25 19:08:00 2008
@@ -1,3 +1,22 @@
+/**
+ * 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.mapred;
import java.io.IOException;
@@ -13,14 +32,14 @@
import org.apache.hadoop.mapred.Reporter;
import org.apache.hama.Constants;
import org.apache.hama.DenseMatrix;
+import org.apache.hama.DenseVector;
import org.apache.hama.HamaConfiguration;
import org.apache.hama.Matrix;
-import org.apache.hama.Vector;
@SuppressWarnings("unchecked")
public abstract class DenseMap<K extends WritableComparable, V extends Writable>
extends MapReduceBase implements
- Mapper<ImmutableBytesWritable, Vector, K, V> {
+ Mapper<ImmutableBytesWritable, DenseVector, K, V> {
public static Matrix MATRIX_B;
public static void initJob(String matrixA, String matrixB,
@@ -38,6 +57,6 @@
job.set(MatrixInputFormat.COLUMN_LIST, Constants.COLUMN);
}
- public abstract void map(ImmutableBytesWritable key, Vector value,
+ public abstract void map(ImmutableBytesWritable key, DenseVector value,
OutputCollector<K, V> output, Reporter reporter) throws IOException;
}
Modified: incubator/hama/trunk/src/java/org/apache/hama/mapred/MatrixInputFormatBase.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/mapred/MatrixInputFormatBase.java?rev=688938&r1=688937&r2=688938&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/mapred/MatrixInputFormatBase.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/mapred/MatrixInputFormatBase.java Mon Aug 25 19:08:00 2008
@@ -54,7 +54,7 @@
/**
* Iterate over an HBase table data, return (Text, DenseVector) pairs
*/
- protected class TableRecordReader implements
+ protected static class TableRecordReader implements
RecordReader<ImmutableBytesWritable, DenseVector> {
private byte[] startRow;
private byte[] endRow;
Modified: incubator/hama/trunk/src/test/org/apache/hama/TestVector.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/test/org/apache/hama/TestVector.java?rev=688938&r1=688937&r2=688938&view=diff
==============================================================================
--- incubator/hama/trunk/src/test/org/apache/hama/TestVector.java (original)
+++ incubator/hama/trunk/src/test/org/apache/hama/TestVector.java Mon Aug 25 19:08:00 2008
@@ -58,6 +58,12 @@
assertEquals(cos, cosine);
}
+ /**
+ * Test Norm one
+ *
+ * @param v1
+ * @param v2
+ */
private void norm1Test(Vector v1, Vector v2) {
assertEquals(norm1, ((DenseVector) v1).getNorm1());
}