Author: edwardyoon
Date: Thu Oct 30 18:48:00 2008
New Revision: 709324
URL: http://svn.apache.org/viewvc?rev=709324&view=rev
Log:
Commit HAMA-5_v02.patch
Modified:
incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java
incubator/hama/trunk/src/java/org/apache/hama/algebra/Mult1DLayoutMap.java
incubator/hama/trunk/src/java/org/apache/hama/algebra/Mult1DLayoutReduce.java
incubator/hama/trunk/src/java/org/apache/hama/io/VectorMapWritable.java
incubator/hama/trunk/src/java/org/apache/hama/mapred/MatrixInputFormatBase.java
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=709324&r1=709323&r2=709324&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java Thu Oct
30 18:48:00 2008
@@ -1,230 +1,231 @@
-/**
- * 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.io.IOException;
-
-import org.apache.hadoop.hbase.HColumnDescriptor;
-import org.apache.hadoop.hbase.HTableDescriptor;
-import org.apache.hadoop.hbase.MasterNotRunningException;
-import org.apache.hadoop.hbase.client.HBaseAdmin;
-import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.io.BatchUpdate;
-import org.apache.hadoop.hbase.io.Cell;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.hama.io.VectorUpdate;
-import org.apache.hama.util.Numeric;
-import org.apache.log4j.Logger;
-
-/**
- * Methods of the matrix classes
- */
-public abstract class AbstractMatrix implements Matrix {
- static final Logger LOG = Logger.getLogger(AbstractMatrix.class);
-
- protected HamaConfiguration config;
- protected HBaseAdmin admin;
- // a matrix just need a table path to point to the table which stores matrix.
- // let HamaAdmin manage Matrix Name space.
- protected String matrixPath;
- protected HTable table;
- protected HTableDescriptor tableDesc;
- protected HamaAdmin hamaAdmin;
-
- protected boolean closed = true;
- /**
- * Sets the job configuration
- *
- * @param conf configuration object
- */
- public void setConfiguration(HamaConfiguration conf) {
- this.config = conf;
- try {
- this.admin = new HBaseAdmin(config);
- } catch (MasterNotRunningException e) {
- LOG.error(e, e);
- }
-
- hamaAdmin = new HamaAdminImpl(conf, admin);
- }
-
- /**
- * Create matrix space
- */
- protected void create() throws IOException {
- // It should run only when table doesn't exist.
- if (!admin.tableExists(matrixPath)) {
- this.tableDesc.addFamily(new HColumnDescriptor(Constants.COLUMN));
- this.tableDesc.addFamily(new HColumnDescriptor(Constants.ATTRIBUTE));
- this.tableDesc.addFamily(new HColumnDescriptor(Constants.ALIASEFAMILY));
-
- LOG.info("Initializing the matrix storage.");
- this.admin.createTable(this.tableDesc);
- LOG.info("Create Matrix " + matrixPath);
-
- // connect to the table.
- table = new HTable(config, matrixPath);
- // Record the matrix type in METADATA_TYPE
- BatchUpdate update = new BatchUpdate(Constants.METADATA);
- update.put(Constants.METADATA_TYPE,
Bytes.toBytes(this.getClass().getSimpleName()));
-
- table.commit(update);
-
- // the new matrix's reference is 1.
- setReference(1);
- }
- }
-
- /** [EMAIL PROTECTED] */
- public double get(int i, int j) throws IOException {
- double result = -1;
- Cell c = table.get(Numeric.intToBytes(i), Numeric.getColumnIndex(j));
- if (c != null) {
- result = Numeric.bytesToDouble(c.getValue());
- }
- return result;
- }
-
- /** [EMAIL PROTECTED] */
- public int getRows() throws IOException {
- Cell rows = null;
- rows = table.get(Constants.METADATA, Constants.METADATA_ROWS);
- return Numeric.bytesToInt(rows.getValue());
- }
-
- /** [EMAIL PROTECTED] */
- public int getColumns() throws IOException {
- Cell columns = table.get(Constants.METADATA, Constants.METADATA_COLUMNS);
- return Numeric.bytesToInt(columns.getValue());
- }
-
- /** [EMAIL PROTECTED] */
- public void set(int i, int j, double value) throws IOException {
- VectorUpdate update = new VectorUpdate(i);
- update.put(j, value);
- table.commit(update.getBatchUpdate());
- }
-
- /** [EMAIL PROTECTED] */
- public void add(int i, int j, double value) throws IOException {
- // TODO Auto-generated method stub
- }
-
- /** [EMAIL PROTECTED] */
- public void setDimension(int rows, int columns) throws IOException {
- VectorUpdate update = new VectorUpdate(Constants.METADATA);
- update.put(Constants.METADATA_ROWS, rows);
- update.put(Constants.METADATA_COLUMNS, columns);
-
- table.commit(update.getBatchUpdate());
- }
-
- public String getRowAttribute(int row) throws IOException {
- Cell rows = null;
- rows = table.get(Numeric.intToBytes(row), Bytes.toBytes(Constants.ATTRIBUTE
- + "string"));
-
- return (rows != null) ? Bytes.toString(rows.getValue()) : null;
- }
-
- public void setRowAttribute(int row, String name) throws IOException {
- VectorUpdate update = new VectorUpdate(row);
- update.put(Constants.ATTRIBUTE + "string", name);
- table.commit(update.getBatchUpdate());
- }
-
- public String getColumnAttribute(int column) throws IOException {
- Cell rows = null;
- rows = table.get(Constants.CINDEX, (Constants.ATTRIBUTE + column));
- return (rows != null) ? Bytes.toString(rows.getValue()) : null;
- }
-
- public void setColumnAttribute(int column, String name) throws IOException {
- VectorUpdate update = new VectorUpdate(Constants.CINDEX);
- update.put(column, name);
- table.commit(update.getBatchUpdate());
- }
-
- /** [EMAIL PROTECTED] */
- public String getPath() {
- return matrixPath;
- }
-
- protected void setReference(int reference) throws IOException {
- BatchUpdate update = new BatchUpdate(Constants.METADATA);
- update.put(Constants.METADATA_REFERENCE, Bytes.toBytes(reference));
- table.commit(update);
- }
-
- protected int incrementAndGetRef() throws IOException {
- int reference = 1;
- Cell rows = null;
- rows = table.get(Constants.METADATA, Constants.METADATA_REFERENCE);
- if(rows != null) {
- reference = Bytes.toInt(rows.getValue());
- reference++;
- }
- setReference(reference);
- return reference;
- }
-
- protected int decrementAndGetRef() throws IOException {
- int reference = 0;
- Cell rows = null;
- rows = table.get(Constants.METADATA, Constants.METADATA_REFERENCE);
- if(rows != null) {
- reference = Bytes.toInt(rows.getValue());
- if(reference>0) // reference==0, we need not to decrement it.
- reference--;
- }
- setReference(reference);
- return reference;
- }
-
- protected boolean hasAliaseName() throws IOException {
- Cell rows = null;
- rows = table.get(Constants.METADATA, Constants.ALIASENAME);
- return (rows != null) ? true : false;
- }
-
- public void close() throws IOException {
- if(closed) // have been closed
- return;
- int reference = decrementAndGetRef();
- if(reference<=0) { // no reference again.
- if(! hasAliaseName()) { // the table has not been aliased, we delete the
table.
- if (admin.isTableEnabled(matrixPath)) {
- admin.disableTable(matrixPath);
- admin.deleteTable(matrixPath);
- }
- }
- }
- closed = true;
- }
-
- public boolean save(String aliasename) throws IOException {
- // mark & update the aliase name in "alise:name" meta column.
- // ! one matrix has only one aliasename now.
- BatchUpdate update = new BatchUpdate(Constants.METADATA);
- update.put(Constants.ALIASENAME, Bytes.toBytes(aliasename));
- table.commit(update);
- return hamaAdmin.save(this, aliasename);
- }
-}
+/**
+ * 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.io.IOException;
+
+import org.apache.hadoop.hbase.HColumnDescriptor;
+import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.MasterNotRunningException;
+import org.apache.hadoop.hbase.client.HBaseAdmin;
+import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.io.BatchUpdate;
+import org.apache.hadoop.hbase.io.Cell;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hama.io.VectorUpdate;
+import org.apache.hama.util.Numeric;
+import org.apache.log4j.Logger;
+
+/**
+ * Methods of the matrix classes
+ */
+public abstract class AbstractMatrix implements Matrix {
+ static final Logger LOG = Logger.getLogger(AbstractMatrix.class);
+
+ protected HamaConfiguration config;
+ protected HBaseAdmin admin;
+ // a matrix just need a table path to point to the table which stores matrix.
+ // let HamaAdmin manage Matrix Name space.
+ protected String matrixPath;
+ protected HTable table;
+ protected HTableDescriptor tableDesc;
+ protected HamaAdmin hamaAdmin;
+
+ protected boolean closed = true;
+
+ /**
+ * Sets the job configuration
+ *
+ * @param conf configuration object
+ * @throws MasterNotRunningException
+ */
+ public void setConfiguration(HamaConfiguration conf)
+ throws MasterNotRunningException {
+ this.config = conf;
+ this.admin = new HBaseAdmin(config);
+
+ hamaAdmin = new HamaAdminImpl(conf, admin);
+ }
+
+ /**
+ * Create matrix space
+ */
+ protected void create() throws IOException {
+ // It should run only when table doesn't exist.
+ if (!admin.tableExists(matrixPath)) {
+ this.tableDesc.addFamily(new HColumnDescriptor(Constants.COLUMN));
+ this.tableDesc.addFamily(new HColumnDescriptor(Constants.ATTRIBUTE));
+ this.tableDesc.addFamily(new HColumnDescriptor(Constants.ALIASEFAMILY));
+
+ LOG.info("Initializing the matrix storage.");
+ this.admin.createTable(this.tableDesc);
+ LOG.info("Create Matrix " + matrixPath);
+
+ // connect to the table.
+ table = new HTable(config, matrixPath);
+ // Record the matrix type in METADATA_TYPE
+ BatchUpdate update = new BatchUpdate(Constants.METADATA);
+ update.put(Constants.METADATA_TYPE, Bytes.toBytes(this.getClass()
+ .getSimpleName()));
+
+ table.commit(update);
+
+ // the new matrix's reference is 1.
+ setReference(1);
+ }
+ }
+
+ /** [EMAIL PROTECTED] */
+ public double get(int i, int j) throws IOException {
+ double result = -1;
+ Cell c = table.get(Numeric.intToBytes(i), Numeric.getColumnIndex(j));
+ if (c != null) {
+ result = Numeric.bytesToDouble(c.getValue());
+ }
+ return result;
+ }
+
+ /** [EMAIL PROTECTED] */
+ public int getRows() throws IOException {
+ Cell rows = null;
+ rows = table.get(Constants.METADATA, Constants.METADATA_ROWS);
+ return Numeric.bytesToInt(rows.getValue());
+ }
+
+ /** [EMAIL PROTECTED] */
+ public int getColumns() throws IOException {
+ Cell columns = table.get(Constants.METADATA, Constants.METADATA_COLUMNS);
+ return Numeric.bytesToInt(columns.getValue());
+ }
+
+ /** [EMAIL PROTECTED] */
+ public void set(int i, int j, double value) throws IOException {
+ VectorUpdate update = new VectorUpdate(i);
+ update.put(j, value);
+ table.commit(update.getBatchUpdate());
+ }
+
+ /** [EMAIL PROTECTED] */
+ public void add(int i, int j, double value) throws IOException {
+ // TODO Auto-generated method stub
+ }
+
+ /** [EMAIL PROTECTED] */
+ public void setDimension(int rows, int columns) throws IOException {
+ VectorUpdate update = new VectorUpdate(Constants.METADATA);
+ update.put(Constants.METADATA_ROWS, rows);
+ update.put(Constants.METADATA_COLUMNS, columns);
+
+ table.commit(update.getBatchUpdate());
+ }
+
+ public String getRowAttribute(int row) throws IOException {
+ Cell rows = null;
+ rows = table.get(Numeric.intToBytes(row), Bytes.toBytes(Constants.ATTRIBUTE
+ + "string"));
+
+ return (rows != null) ? Bytes.toString(rows.getValue()) : null;
+ }
+
+ public void setRowAttribute(int row, String name) throws IOException {
+ VectorUpdate update = new VectorUpdate(row);
+ update.put(Constants.ATTRIBUTE + "string", name);
+ table.commit(update.getBatchUpdate());
+ }
+
+ public String getColumnAttribute(int column) throws IOException {
+ Cell rows = null;
+ rows = table.get(Constants.CINDEX, (Constants.ATTRIBUTE + column));
+ return (rows != null) ? Bytes.toString(rows.getValue()) : null;
+ }
+
+ public void setColumnAttribute(int column, String name) throws IOException {
+ VectorUpdate update = new VectorUpdate(Constants.CINDEX);
+ update.put(column, name);
+ table.commit(update.getBatchUpdate());
+ }
+
+ /** [EMAIL PROTECTED] */
+ public String getPath() {
+ return matrixPath;
+ }
+
+ protected void setReference(int reference) throws IOException {
+ BatchUpdate update = new BatchUpdate(Constants.METADATA);
+ update.put(Constants.METADATA_REFERENCE, Bytes.toBytes(reference));
+ table.commit(update);
+ }
+
+ protected int incrementAndGetRef() throws IOException {
+ int reference = 1;
+ Cell rows = null;
+ rows = table.get(Constants.METADATA, Constants.METADATA_REFERENCE);
+ if (rows != null) {
+ reference = Bytes.toInt(rows.getValue());
+ reference++;
+ }
+ setReference(reference);
+ return reference;
+ }
+
+ protected int decrementAndGetRef() throws IOException {
+ int reference = 0;
+ Cell rows = null;
+ rows = table.get(Constants.METADATA, Constants.METADATA_REFERENCE);
+ if (rows != null) {
+ reference = Bytes.toInt(rows.getValue());
+ if (reference > 0) // reference==0, we need not to decrement it.
+ reference--;
+ }
+ setReference(reference);
+ return reference;
+ }
+
+ protected boolean hasAliaseName() throws IOException {
+ Cell rows = null;
+ rows = table.get(Constants.METADATA, Constants.ALIASENAME);
+ return (rows != null) ? true : false;
+ }
+
+ public void close() throws IOException {
+ if (closed) // have been closed
+ return;
+ int reference = decrementAndGetRef();
+ if (reference <= 0) { // no reference again.
+ if (!hasAliaseName()) { // the table has not been aliased, we delete the
+ // table.
+ if (admin.isTableEnabled(matrixPath)) {
+ admin.disableTable(matrixPath);
+ admin.deleteTable(matrixPath);
+ }
+ }
+ }
+ closed = true;
+ }
+
+ public boolean save(String aliasename) throws IOException {
+ // mark & update the aliase name in "alise:name" meta column.
+ // ! one matrix has only one aliasename now.
+ BatchUpdate update = new BatchUpdate(Constants.METADATA);
+ update.put(Constants.ALIASENAME, Bytes.toBytes(aliasename));
+ table.commit(update);
+ return hamaAdmin.save(this, aliasename);
+ }
+}
Modified:
incubator/hama/trunk/src/java/org/apache/hama/algebra/Mult1DLayoutMap.java
URL:
http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/algebra/Mult1DLayoutMap.java?rev=709324&r1=709323&r2=709324&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/algebra/Mult1DLayoutMap.java
(original)
+++ incubator/hama/trunk/src/java/org/apache/hama/algebra/Mult1DLayoutMap.java
Thu Oct 30 18:48:00 2008
@@ -1,82 +1,78 @@
-/**
- * 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.algebra;
-
-import java.io.IOException;
-import java.util.Iterator;
-
-import org.apache.hadoop.io.IntWritable;
-import org.apache.hadoop.mapred.JobConf;
-import org.apache.hadoop.mapred.OutputCollector;
-import org.apache.hadoop.mapred.Reporter;
-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;
-import org.apache.hama.io.VectorEntry;
-import org.apache.hama.io.VectorWritable;
-import org.apache.hama.mapred.DenseMap;
-import org.apache.log4j.Logger;
-
-/**
- * 1D Block Layout version
- */
-public class Mult1DLayoutMap extends DenseMap<IntWritable, VectorWritable> {
- static final Logger LOG = Logger.getLogger(Mult1DLayoutMap.class);
- protected Matrix matrix_b;
- public static final String MATRIX_B = "hama.multiplication.matrix.b";
-
- public void configure(JobConf job) {
- try {
- matrix_b = new DenseMatrix(new HamaConfiguration(), job.get(MATRIX_B,
""));
- } catch (IOException e) {
- LOG.warn("Load matrix_b failed : " + e.getMessage());
- }
- }
-
- public static void initJob(String matrix_a, String matrix_b,
- Class<Mult1DLayoutMap> map, Class<IntWritable> outputKeyClass,
- Class<VectorWritable> outputValueClass, JobConf jobConf) {
-
- jobConf.setMapOutputValueClass(outputValueClass);
- jobConf.setMapOutputKeyClass(outputKeyClass);
- jobConf.setMapperClass(map);
- jobConf.set(MATRIX_B, matrix_b);
-
- initJob(matrix_a, map, jobConf);
- }
-
- @Override
- public void map(IntWritable key, VectorWritable value,
- OutputCollector<IntWritable, VectorWritable> output, Reporter reporter)
- throws IOException {
-
- Iterator<VectorEntry> it = value.getDenseVector().iterator();
- int i = 0;
- while (it.hasNext()) {
- Vector v = matrix_b.getRow(i);
-
- output.collect(key, new VectorWritable(key.get(), (DenseVector) v
- .scale(it.next().getValue())));
- i++;
- }
- }
-}
+/**
+ * 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.algebra;
+
+import java.io.IOException;
+
+import org.apache.hadoop.io.IntWritable;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.hadoop.mapred.OutputCollector;
+import org.apache.hadoop.mapred.Reporter;
+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;
+import org.apache.hama.io.VectorWritable;
+import org.apache.hama.mapred.DenseMap;
+import org.apache.log4j.Logger;
+
+/**
+ * 1D Block Layout version
+ */
+public class Mult1DLayoutMap extends DenseMap<IntWritable, VectorWritable> {
+ static final Logger LOG = Logger.getLogger(Mult1DLayoutMap.class);
+ protected Matrix matrix_b;
+ public static final String MATRIX_B = "hama.multiplication.matrix.b";
+
+ public void configure(JobConf job) {
+ try {
+ matrix_b = new DenseMatrix(new HamaConfiguration(), job.get(MATRIX_B,
""));
+ } catch (IOException e) {
+ LOG.warn("Load matrix_b failed : " + e.getMessage());
+ }
+ }
+
+ public static void initJob(String matrix_a, String matrix_b,
+ Class<Mult1DLayoutMap> map, Class<IntWritable> outputKeyClass,
+ Class<VectorWritable> outputValueClass, JobConf jobConf) {
+
+ jobConf.setMapOutputValueClass(outputValueClass);
+ jobConf.setMapOutputKeyClass(outputKeyClass);
+ jobConf.setMapperClass(map);
+ jobConf.set(MATRIX_B, matrix_b);
+
+ initJob(matrix_a, map, jobConf);
+ }
+
+ @Override
+ public void map(IntWritable key, VectorWritable value,
+ OutputCollector<IntWritable, VectorWritable> output, Reporter reporter)
+ throws IOException {
+
+ DenseVector v1 = value.getDenseVector();
+
+ for(int i = 0; i < v1.size(); i++) {
+ Vector v2 = matrix_b.getRow(i);
+ DenseVector sum = (DenseVector) v2.scale(v1.get(i));
+ output.collect(key, new VectorWritable(key.get(), sum));
+ }
+ }
+}
Modified:
incubator/hama/trunk/src/java/org/apache/hama/algebra/Mult1DLayoutReduce.java
URL:
http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/algebra/Mult1DLayoutReduce.java?rev=709324&r1=709323&r2=709324&view=diff
==============================================================================
---
incubator/hama/trunk/src/java/org/apache/hama/algebra/Mult1DLayoutReduce.java
(original)
+++
incubator/hama/trunk/src/java/org/apache/hama/algebra/Mult1DLayoutReduce.java
Thu Oct 30 18:48:00 2008
@@ -35,17 +35,16 @@
public class Mult1DLayoutReduce extends
MatrixReduce<IntWritable, VectorWritable> {
static final Logger LOG = Logger.getLogger(Mult1DLayoutReduce.class);
-
+ public static final Map<Integer, Double> buffer = new HashMap<Integer,
Double>();
+
@Override
public void reduce(IntWritable key, Iterator<VectorWritable> values,
OutputCollector<IntWritable, VectorUpdate> output, Reporter reporter)
throws IOException {
VectorUpdate update = new VectorUpdate(key.get());
-
VectorWritable sum;
- Map<Integer, Double> buffer = new HashMap<Integer, Double>();
-
+
// Summation
while (values.hasNext()) {
sum = values.next();
@@ -57,7 +56,9 @@
}
}
}
+
update.putAll(buffer);
+ buffer.clear();
output.collect(key, update);
}
Modified:
incubator/hama/trunk/src/java/org/apache/hama/io/VectorMapWritable.java
URL:
http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/io/VectorMapWritable.java?rev=709324&r1=709323&r2=709324&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/io/VectorMapWritable.java
(original)
+++ incubator/hama/trunk/src/java/org/apache/hama/io/VectorMapWritable.java Thu
Oct 30 18:48:00 2008
@@ -43,7 +43,7 @@
Configurable {
private AtomicReference<Configuration> conf = new
AtomicReference<Configuration>();
- // Static maps of code to class and vice versa. Includes types used in hbase
+ // Static maps of code to class and vice versa. Includes types used in hama
// only.
static final Map<Byte, Class<?>> CODE_TO_CLASS = new HashMap<Byte,
Class<?>>();
static final Map<Class<?>, Byte> CLASS_TO_CODE = new HashMap<Class<?>,
Byte>();
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=709324&r1=709323&r2=709324&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
Thu Oct 30 18:48:00 2008
@@ -131,7 +131,7 @@
}
/**
- * @return ImmutableBytesWritable
+ * @return IntWritable
*
* @see org.apache.hadoop.mapred.RecordReader#createKey()
*/