incubator-hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edwardy...@apache.org
Subject svn commit: r683869 - in /incubator/hama/trunk/src/java/org/apache/hama: AbstractBase.java AbstractMatrix.java Vector.java
Date Fri, 08 Aug 2008 06:25:07 GMT
Author: edwardyoon
Date: Thu Aug  7 23:25:07 2008
New Revision: 683869

URL: http://svn.apache.org/viewvc?rev=683869&view=rev
Log:
Implement get(int index)

Modified:
    incubator/hama/trunk/src/java/org/apache/hama/AbstractBase.java
    incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java
    incubator/hama/trunk/src/java/org/apache/hama/Vector.java

Modified: incubator/hama/trunk/src/java/org/apache/hama/AbstractBase.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/AbstractBase.java?rev=683869&r1=683868&r2=683869&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/AbstractBase.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/AbstractBase.java Thu Aug  7 23:25:07 2008
@@ -1,12 +1,25 @@
 package org.apache.hama;
 
+import org.apache.hadoop.hbase.util.Bytes;
+
 public abstract class AbstractBase {
-  /**
-   * Return the integer column index
-   * 
-   * @param b key
-   * @return integer
-   */
+
+  public int bytesToInt(byte[] b) {
+    return Integer.parseInt(Bytes.toString(b));
+  }
+  
+  public byte[] intToBytes(int d) {
+    return Bytes.toBytes(String.valueOf(d));
+  }
+  
+  public double bytesToDouble(byte[] b) {
+    return Double.parseDouble(Bytes.toString(b));
+  }
+
+  public byte[] doubleToBytes(Double d) {
+    return Bytes.toBytes(d.toString());
+  }
+
   public int getColumnIndex(byte[] b) {
     String cKey = new String(b);
     return Integer.parseInt(cKey

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=683869&r1=683868&r2=683869&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/AbstractMatrix.java Thu Aug  7 23:25:07
2008
@@ -127,14 +127,6 @@
     return result;
   }
 
-  public double bytesToDouble(byte[] b) {
-    return Double.parseDouble(Bytes.toString(b));
-  }
-
-  public byte[] doubleToBytes(Double d) {
-    return Bytes.toBytes(d.toString());
-  }
-
   /** {@inheritDoc} */
   public RowResult getRowResult(byte[] row) {
     try {

Modified: incubator/hama/trunk/src/java/org/apache/hama/Vector.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/Vector.java?rev=683869&r1=683868&r2=683869&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/Vector.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/Vector.java Thu Aug  7 23:25:07 2008
@@ -81,8 +81,7 @@
   }
 
   public double get(int index) {
-    // TODO Auto-generated method stub
-    return 0;
+    return bytesToInt(this.cells.get(intToBytes(index)).getValue());
   }
 
   public double norm(Norm type) {



Mime
View raw message