hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r599879 - in /lucene/hadoop/trunk/src/contrib/hbase: ./ src/java/org/apache/hadoop/hbase/
Date Fri, 30 Nov 2007 17:18:05 GMT
Author: stack
Date: Fri Nov 30 09:18:01 2007
New Revision: 599879

URL: http://svn.apache.org/viewvc?rev=599879&view=rev
Log:
HADOOP-2224 Add HTable.getRow(ROW, ts)

Modified:
    lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegion.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegionInterface.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegionServer.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HTable.java

Modified: lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt?rev=599879&r1=599878&r2=599879&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt Fri Nov 30 09:18:01 2007
@@ -71,6 +71,8 @@
    HADOOP-2296 hbase shell: phantom columns show up from select command
    HADOOP-2297 System.exit() Handling in hbase shell jar command
                (Edward Yoon via Stack)
+   HADOOP-2224 Add HTable.getRow(ROW, ts)
+               (Bryan Duxbury via Stack)
 
 
 Release 0.15.1

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegion.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegion.java?rev=599879&r1=599878&r2=599879&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegion.java (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegion.java Fri
Nov 30 09:18:01 2007
@@ -1017,7 +1017,25 @@
    * @throws IOException
    */
   public Map<Text, byte []> getFull(Text row) throws IOException {
-    HStoreKey key = new HStoreKey(row, System.currentTimeMillis());
+    return getFull(row, HConstants.LATEST_TIMESTAMP);
+  }
+
+  /**
+   * Fetch all the columns for the indicated row at a specified timestamp.
+   * Returns a TreeMap that maps column names to values.
+   *
+   * We should eventually use Bloom filters here, to reduce running time.  If 
+   * the database has many column families and is very sparse, then we could be 
+   * checking many files needlessly.  A small Bloom for each row would help us 
+   * determine which column groups are useful for that row.  That would let us 
+   * avoid a bunch of disk activity.
+   *
+   * @param row
+   * @return Map<columnName, byte[]> values
+   * @throws IOException
+   */
+  public Map<Text, byte []> getFull(Text row, long ts) throws IOException {
+    HStoreKey key = new HStoreKey(row, ts);
     obtainRowLock(row);
     try {
       TreeMap<Text, byte []> result = new TreeMap<Text, byte[]>();

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegionInterface.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegionInterface.java?rev=599879&r1=599878&r2=599879&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegionInterface.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegionInterface.java
Fri Nov 30 09:18:01 2007
@@ -100,6 +100,18 @@
   throws IOException;
 
   /**
+   * Get all the data for the specified row at a given timestamp
+   * 
+   * @param regionName region name
+   * @param row row key
+   * @return map of values
+   * @throws IOException
+   */
+  public MapWritable getRow(final Text regionName, final Text row, final long ts)
+  throws IOException;
+
+
+  /**
    * Applies a batch of updates via one RPC
    * 
    * @param regionName name of the region to update

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegionServer.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegionServer.java?rev=599879&r1=599878&r2=599879&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegionServer.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HRegionServer.java
Fri Nov 30 09:18:01 2007
@@ -1291,6 +1291,29 @@
   }
 
   /** {@inheritDoc} */
+  public MapWritable getRow(final Text regionName, final Text row, final long ts)
+    throws IOException {
+
+    checkOpen();
+    requestCount.incrementAndGet();
+    try {
+      HRegion region = getRegion(regionName);
+      MapWritable result = new MapWritable();
+      Map<Text, byte[]> map = region.getFull(row);
+      for (Map.Entry<Text, byte []> es: map.entrySet()) {
+        result.put(new HStoreKey(row, es.getKey()),
+            new ImmutableBytesWritable(es.getValue()));
+      }
+      return result;
+      
+    } catch (IOException e) {
+      checkFileSystem();
+      throw e;
+    }
+  }
+
+
+  /** {@inheritDoc} */
   public MapWritable next(final long scannerId) throws IOException {
 
     checkOpen();

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HTable.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HTable.java?rev=599879&r1=599878&r2=599879&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HTable.java (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/HTable.java Fri
Nov 30 09:18:01 2007
@@ -347,13 +347,24 @@
   }
     
   /** 
-   * Get all the data for the specified row
+   * Get all the data for the specified row at the latest timestamp
    * 
    * @param row row key
    * @return map of colums to values
    * @throws IOException
    */
   public SortedMap<Text, byte[]> getRow(Text row) throws IOException {
+    return getRow(row, HConstants.LATEST_TIMESTAMP);
+  }
+
+  /** 
+   * Get all the data for the specified row at a specified timestamp
+   * 
+   * @param row row key
+   * @return map of colums to values
+   * @throws IOException
+   */
+  public SortedMap<Text, byte[]> getRow(Text row, long ts) throws IOException {
     checkClosed();
     MapWritable value = null;
     for (int tries = 0; tries < numRetries; tries++) {
@@ -362,7 +373,7 @@
         connection.getHRegionConnection(r.getServerAddress());
       
       try {
-        value = server.getRow(r.getRegionInfo().getRegionName(), row);
+        value = server.getRow(r.getRegionInfo().getRegionName(), row, ts);
         break;
         
       } catch (IOException e) {
@@ -395,6 +406,7 @@
     }
     return results;
   }
+
 
   /** 
    * Get a scanner on the current table starting at the specified row.



Mime
View raw message