incubator-hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edwardy...@apache.org
Subject svn commit: r713663 - in /incubator/hama/trunk/src: java/org/apache/hama/ java/org/apache/hama/io/ java/org/apache/hama/mapred/ test/org/apache/hama/util/
Date Thu, 13 Nov 2008 06:52:01 GMT
Author: edwardyoon
Date: Wed Nov 12 22:52:00 2008
New Revision: 713663

URL: http://svn.apache.org/viewvc?rev=713663&view=rev
Log:
Add license

Modified:
    incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java
    incubator/hama/trunk/src/java/org/apache/hama/DenseMatrix.java
    incubator/hama/trunk/src/java/org/apache/hama/DenseVector.java
    incubator/hama/trunk/src/java/org/apache/hama/io/BlockEntry.java
    incubator/hama/trunk/src/java/org/apache/hama/io/DoubleEntry.java
    incubator/hama/trunk/src/java/org/apache/hama/io/VectorMapWritable.java
    incubator/hama/trunk/src/java/org/apache/hama/io/VectorUpdate.java
    incubator/hama/trunk/src/java/org/apache/hama/io/VectorWritable.java
    incubator/hama/trunk/src/java/org/apache/hama/mapred/VectorInputFormatBase.java
    incubator/hama/trunk/src/test/org/apache/hama/util/TestNumeric.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=713663&r1=713662&r2=713663&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java Wed Nov 12 22:52:00
2008
@@ -30,7 +30,7 @@
 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.hama.util.BytesUtil;
 import org.apache.log4j.Logger;
 
 /**
@@ -95,9 +95,9 @@
   /** {@inheritDoc} */
   public double get(int i, int j) throws IOException {
     double result = -1;
-    Cell c = table.get(Numeric.intToBytes(i), Numeric.getColumnIndex(j));
+    Cell c = table.get(BytesUtil.intToBytes(i), BytesUtil.getColumnIndex(j));
     if (c != null) {
-      result = Numeric.bytesToDouble(c.getValue());
+      result = BytesUtil.bytesToDouble(c.getValue());
     }
     return result;
   }
@@ -106,13 +106,13 @@
   public int getRows() throws IOException {
     Cell rows = null;
     rows = table.get(Constants.METADATA, Constants.METADATA_ROWS);
-    return Numeric.bytesToInt(rows.getValue());
+    return BytesUtil.bytesToInt(rows.getValue());
   }
 
   /** {@inheritDoc} */
   public int getColumns() throws IOException {
     Cell columns = table.get(Constants.METADATA, Constants.METADATA_COLUMNS);
-    return Numeric.bytesToInt(columns.getValue());
+    return BytesUtil.bytesToInt(columns.getValue());
   }
 
   /** {@inheritDoc} */
@@ -138,7 +138,7 @@
 
   public String getRowAttribute(int row) throws IOException {
     Cell rows = null;
-    rows = table.get(Numeric.intToBytes(row), Bytes.toBytes(Constants.ATTRIBUTE
+    rows = table.get(BytesUtil.intToBytes(row), Bytes.toBytes(Constants.ATTRIBUTE
         + "string"));
 
     return (rows != null) ? Bytes.toString(rows.getValue()) : null;

Modified: incubator/hama/trunk/src/java/org/apache/hama/DenseMatrix.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/DenseMatrix.java?rev=713663&r1=713662&r2=713663&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/DenseMatrix.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/DenseMatrix.java Wed Nov 12 22:52:00 2008
@@ -40,7 +40,7 @@
 import org.apache.hama.io.VectorWritable;
 import org.apache.hama.mapred.RowCyclicReduce;
 import org.apache.hama.util.JobManager;
-import org.apache.hama.util.Numeric;
+import org.apache.hama.util.BytesUtil;
 import org.apache.hama.util.RandomVariable;
 
 public class DenseMatrix extends AbstractMatrix implements Matrix {
@@ -268,18 +268,18 @@
   }
 
   public DenseVector getRow(int row) throws IOException {
-    return new DenseVector(table.getRow(Numeric.intToBytes(row)));
+    return new DenseVector(table.getRow(BytesUtil.intToBytes(row)));
   }
 
   public Vector getColumn(int column) throws IOException {
-    byte[] columnKey = Numeric.getColumnIndex(column);
+    byte[] columnKey = BytesUtil.getColumnIndex(column);
     byte[][] c = { columnKey };
     Scanner scan = table.getScanner(c, HConstants.EMPTY_START_ROW);
 
     VectorMapWritable<Integer, DoubleEntry> trunk = new VectorMapWritable<Integer,
DoubleEntry>();
 
     for (RowResult row : scan) {
-      trunk.put(Numeric.bytesToInt(row.getRow()), 
+      trunk.put(BytesUtil.bytesToInt(row.getRow()), 
           new DoubleEntry(row.get(columnKey)));
     }
 
@@ -341,15 +341,15 @@
     SubMatrix result = new SubMatrix((i1-i0) + 1, columnSize);
     byte[][] c = new byte[columnSize][];
     for (int i = 0; i < columnSize; i++) {
-      c[i] = Numeric.getColumnIndex(j0 + i);
+      c[i] = BytesUtil.getColumnIndex(j0 + i);
     }
 
-    Scanner scan = table.getScanner(c, Numeric.intToBytes(i0), Numeric.intToBytes(i1 + 1));
+    Scanner scan = table.getScanner(c, BytesUtil.intToBytes(i0), BytesUtil.intToBytes(i1
+ 1));
 
     int rKey = 0, cKey = 0;
     for (RowResult row : scan) {
       for (Map.Entry<byte[], Cell> e : row.entrySet()) {
-        result.set(rKey, cKey, Numeric.bytesToDouble(e.getValue().getValue()));
+        result.set(rKey, cKey, BytesUtil.bytesToDouble(e.getValue().getValue()));
         cKey++;
       }
       rKey++;

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=713663&r1=713662&r2=713663&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/DenseVector.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/DenseVector.java Wed Nov 12 22:52:00 2008
@@ -27,7 +27,7 @@
 import org.apache.hadoop.hbase.io.RowResult;
 import org.apache.hama.io.DoubleEntry;
 import org.apache.hama.io.VectorMapWritable;
-import org.apache.hama.util.Numeric;
+import org.apache.hama.util.BytesUtil;
 import org.apache.log4j.Logger;
 
 public class DenseVector extends AbstractVector implements Vector {
@@ -44,7 +44,7 @@
   public DenseVector(RowResult row) {
     this.entries = new VectorMapWritable<Integer, DoubleEntry>();
     for (Map.Entry<byte[], Cell> f : row.entrySet()) {
-      this.entries.put(Numeric.getColumnIndex(f.getKey()), 
+      this.entries.put(BytesUtil.getColumnIndex(f.getKey()), 
           new DoubleEntry(f.getValue()));
     }
   }

Modified: incubator/hama/trunk/src/java/org/apache/hama/io/BlockEntry.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/io/BlockEntry.java?rev=713663&r1=713662&r2=713663&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/io/BlockEntry.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/io/BlockEntry.java Wed Nov 12 22:52: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.io;
 
 import java.io.DataInput;
@@ -9,7 +28,7 @@
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.io.Writable;
 import org.apache.hama.SubMatrix;
-import org.apache.hama.util.Numeric;
+import org.apache.hama.util.BytesUtil;
 import org.apache.log4j.Logger;
 
 public class BlockEntry implements Writable, Iterable<BlockEntry> {
@@ -35,7 +54,7 @@
 
   public BlockEntry(SubMatrix value) throws IOException {
     this.values = new byte[1][];
-    this.values[0] = Numeric.subMatrixToBytes(value);
+    this.values[0] = BytesUtil.subMatrixToBytes(value);
     this.timestamps = new long[1];
     this.timestamps[0] = System.currentTimeMillis();
   }
@@ -46,7 +65,7 @@
    * @throws ClassNotFoundException
    */
   public SubMatrix getValue() throws IOException, ClassNotFoundException {
-    return Numeric.bytesToSubMatrix(this.values[0]);
+    return BytesUtil.bytesToSubMatrix(this.values[0]);
   }
 
   /** @return the current VectorEntry's timestamp */

Modified: incubator/hama/trunk/src/java/org/apache/hama/io/DoubleEntry.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/io/DoubleEntry.java?rev=713663&r1=713662&r2=713663&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/io/DoubleEntry.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/io/DoubleEntry.java Wed Nov 12 22:52:00
2008
@@ -27,7 +27,7 @@
 import org.apache.hadoop.hbase.io.Cell;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.io.Writable;
-import org.apache.hama.util.Numeric;
+import org.apache.hama.util.BytesUtil;
 import org.apache.log4j.Logger;
 
 public class DoubleEntry implements Writable, Iterable<DoubleEntry> {
@@ -53,14 +53,14 @@
 
   public DoubleEntry(double value) {
     this.values = new byte[1][];
-    this.values[0] = Numeric.doubleToBytes(value);
+    this.values[0] = BytesUtil.doubleToBytes(value);
     this.timestamps = new long[1];
     this.timestamps[0] = System.currentTimeMillis();
   }
   
   /** @return the current VectorEntry's value */
   public double getValue() {
-    return Numeric.bytesToDouble(this.values[0]);
+    return BytesUtil.bytesToDouble(this.values[0]);
   }
 
   /** @return the current VectorEntry's timestamp */

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=713663&r1=713662&r2=713663&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 Wed Nov 12 22:52:00
2008
@@ -37,7 +37,7 @@
 import org.apache.hadoop.io.Text;
 import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.util.ReflectionUtils;
-import org.apache.hama.util.Numeric;
+import org.apache.hama.util.BytesUtil;
 
 public class VectorMapWritable<K, V> implements Map<Integer, V>, Writable,
     Configurable {
@@ -148,7 +148,7 @@
 
     // Then write out each key/value pair
     for (Map.Entry<Integer, V> e : instance.entrySet()) {
-      Bytes.writeByteArray(out, Numeric.getColumnIndex(e.getKey()));
+      Bytes.writeByteArray(out, BytesUtil.getColumnIndex(e.getKey()));
       out.writeByte(getId(e.getValue().getClass()));
       ((Writable) e.getValue()).write(out);
     }
@@ -171,7 +171,7 @@
           .readByte()), getConf());
       value.readFields(in);
       V v = (V) value;
-      this.instance.put(Numeric.getColumnIndex(key), v);
+      this.instance.put(BytesUtil.getColumnIndex(key), v);
     }
   }
 

Modified: incubator/hama/trunk/src/java/org/apache/hama/io/VectorUpdate.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/io/VectorUpdate.java?rev=713663&r1=713662&r2=713663&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/io/VectorUpdate.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/io/VectorUpdate.java Wed Nov 12 22:52:00
2008
@@ -26,13 +26,13 @@
 import org.apache.hadoop.hbase.io.BatchUpdate;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hama.Constants;
-import org.apache.hama.util.Numeric;
+import org.apache.hama.util.BytesUtil;
 
 public class VectorUpdate {
   private BatchUpdate batchUpdate;
 
   public VectorUpdate(int i) {
-    this.batchUpdate = new BatchUpdate(Numeric.intToBytes(i));
+    this.batchUpdate = new BatchUpdate(BytesUtil.intToBytes(i));
   }
 
   public VectorUpdate(String row) {
@@ -44,7 +44,7 @@
   }
 
   public void put(int j, double value) {
-    this.batchUpdate.put(Numeric.getColumnIndex(j), Numeric
+    this.batchUpdate.put(BytesUtil.getColumnIndex(j), BytesUtil
         .doubleToBytes(value));
   }
 
@@ -58,7 +58,7 @@
   }
 
   public void put(String row, int val) {
-    this.batchUpdate.put(row, Numeric.intToBytes(val));
+    this.batchUpdate.put(row, BytesUtil.intToBytes(val));
   }
 
   public BatchUpdate getBatchUpdate() {

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=713663&r1=713662&r2=713663&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 Wed Nov 12 22:52:00
2008
@@ -33,7 +33,7 @@
 import org.apache.hadoop.io.Writable;
 import org.apache.hama.DenseVector;
 import org.apache.hama.Vector;
-import org.apache.hama.util.Numeric;
+import org.apache.hama.util.BytesUtil;
 
 public class VectorWritable implements Writable, Map<Integer, DoubleEntry> {
 
@@ -114,12 +114,12 @@
   }
 
   public void readFields(final DataInput in) throws IOException {
-    this.row = Numeric.bytesToInt(Bytes.readByteArray(in));
+    this.row = BytesUtil.bytesToInt(Bytes.readByteArray(in));
     this.entries.readFields(in);
   }
 
   public void write(final DataOutput out) throws IOException {
-    Bytes.writeByteArray(out, Numeric.intToBytes(this.row));
+    Bytes.writeByteArray(out, BytesUtil.intToBytes(this.row));
     this.entries.write(out);
   }
 

Modified: incubator/hama/trunk/src/java/org/apache/hama/mapred/VectorInputFormatBase.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/mapred/VectorInputFormatBase.java?rev=713663&r1=713662&r2=713663&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/mapred/VectorInputFormatBase.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/mapred/VectorInputFormatBase.java Wed Nov
12 22:52:00 2008
@@ -41,7 +41,7 @@
 import org.apache.hadoop.mapred.Reporter;
 import org.apache.hama.Constants;
 import org.apache.hama.io.VectorWritable;
-import org.apache.hama.util.Numeric;
+import org.apache.hama.util.BytesUtil;
 
 public abstract class VectorInputFormatBase implements
     InputFormat<IntWritable, VectorWritable> {
@@ -174,7 +174,7 @@
       RowResult result = this.scanner.next();
       boolean hasMore = result != null && result.size() > 0;
       if (hasMore) {
-        key.set(Numeric.bytesToInt(result.getRow()));
+        key.set(BytesUtil.bytesToInt(result.getRow()));
         Writables.copyWritable(result, value);
       }
       return hasMore;
@@ -208,12 +208,12 @@
   public InputSplit[] getSplits(JobConf job, int numSplits) throws IOException {
     Cell meta = this.table.get(Constants.METADATA, Constants.METADATA_ROWS);
 
-    if (Numeric.bytesToInt(meta.getValue()) < numSplits) {
-      numSplits = Numeric.bytesToInt(meta.getValue());
+    if (BytesUtil.bytesToInt(meta.getValue()) < numSplits) {
+      numSplits = BytesUtil.bytesToInt(meta.getValue());
     }
 
     int[] startKeys = new int[numSplits];
-    int interval = Numeric.bytesToInt(meta.getValue()) / numSplits;
+    int interval = BytesUtil.bytesToInt(meta.getValue()) / numSplits;
 
     for (int i = 0; i < numSplits; i++) {
       startKeys[i] = (i * interval);
@@ -222,8 +222,8 @@
     InputSplit[] splits = new InputSplit[startKeys.length];
     for (int i = 0; i < startKeys.length; i++) {
       splits[i] = new TableSplit(this.table.getTableName(), 
-          Numeric.intToBytes(startKeys[i]), ((i + 1) < startKeys.length) ? 
-              Numeric.intToBytes(startKeys[i + 1]) : HConstants.EMPTY_START_ROW);
+          BytesUtil.intToBytes(startKeys[i]), ((i + 1) < startKeys.length) ? 
+              BytesUtil.intToBytes(startKeys[i + 1]) : HConstants.EMPTY_START_ROW);
     }
     return splits;
   }

Modified: incubator/hama/trunk/src/test/org/apache/hama/util/TestNumeric.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/test/org/apache/hama/util/TestNumeric.java?rev=713663&r1=713662&r2=713663&view=diff
==============================================================================
--- incubator/hama/trunk/src/test/org/apache/hama/util/TestNumeric.java (original)
+++ incubator/hama/trunk/src/test/org/apache/hama/util/TestNumeric.java Wed Nov 12 22:52:00
2008
@@ -32,14 +32,14 @@
    * Integer conversion test
    */
   public void testInteger() {
-    assertEquals(Numeric.bytesToInt(Numeric.intToBytes(TEST_INT)), TEST_INT);
+    assertEquals(BytesUtil.bytesToInt(BytesUtil.intToBytes(TEST_INT)), TEST_INT);
   }
 
   /**
    * Double conversion test
    */
   public void testDouble() {
-    assertEquals(Numeric.bytesToDouble(Numeric.doubleToBytes(TEST_DOUBLE)),
+    assertEquals(BytesUtil.bytesToDouble(BytesUtil.doubleToBytes(TEST_DOUBLE)),
         TEST_DOUBLE);
   }
 
@@ -47,8 +47,8 @@
    * Get the column index from hbase.
    */
   public void testGetColumnIndex() {
-    byte[] result = Numeric.getColumnIndex(3);
+    byte[] result = BytesUtil.getColumnIndex(3);
     assertEquals(Bytes.toString(result), Constants.COLUMN
-        + Numeric.getColumnIndex(result));
+        + BytesUtil.getColumnIndex(result));
   }
 }



Mime
View raw message