hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r674724 - in /hadoop/hbase/trunk: CHANGES.txt src/java/org/apache/hadoop/hbase/client/HTable.java src/java/org/apache/hadoop/hbase/regionserver/HRegion.java src/test/org/apache/hadoop/hbase/client/TestHTable.java
Date Tue, 08 Jul 2008 05:24:37 GMT
Author: stack
Date: Mon Jul  7 22:24:36 2008
New Revision: 674724

URL: http://svn.apache.org/viewvc?rev=674724&view=rev
Log:
HBASE-631 HTable.getRow() for only a column family

Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HTable.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java
    hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/client/TestHTable.java

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=674724&r1=674723&r2=674724&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Mon Jul  7 22:24:36 2008
@@ -261,6 +261,8 @@
    HBASE-536   Remove MiniDFS startup from MiniHBaseCluster
    HBASE-521   Improve client scanner interface
    HBASE-562   Move Exceptions to subpackages (Jean-Daniel Cryans via Stack)
+   HBASE-631   HTable.getRow() for only a column family
+               (Jean-Daniel Cryans via Stack)
 
   NEW FEATURES
    HBASE-47    Option to set TTL for columns in hbase

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HTable.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HTable.java?rev=674724&r1=674723&r2=674724&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HTable.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HTable.java Mon Jul  7 22:24:36
2008
@@ -544,7 +544,7 @@
    * Get selected columns for the specified row at the latest timestamp
    * 
    * @param row row key
-   * @param columns Array of column names you want to retrieve.
+   * @param columns Array of column names and families you want to retrieve.
    * @return RowResult is empty if row does not exist.
    * @throws IOException
    */
@@ -557,7 +557,7 @@
    * Get selected columns for the specified row at the latest timestamp
    * 
    * @param row row key
-   * @param columns Array of column names you want to retrieve.
+   * @param columns Array of column names and families you want to retrieve.
    * @return RowResult is empty if row does not exist.
    * @throws IOException
    */
@@ -570,7 +570,7 @@
    * Get selected columns for the specified row at the latest timestamp
    * 
    * @param row row key
-   * @param columns Array of column names you want to retrieve.
+   * @param columns Array of column names and families you want to retrieve.
    * @return RowResult is empty if row does not exist.
    * @throws IOException
    */
@@ -583,7 +583,7 @@
    * Get selected columns for the specified row at a specified timestamp
    * 
    * @param row row key
-   * @param columns Array of column names you want to retrieve.   
+   * @param columns Array of column names and families you want to retrieve.
    * @param ts timestamp
    * @return RowResult is empty if row does not exist.
    * @throws IOException
@@ -598,7 +598,7 @@
    * Get selected columns for the specified row at a specified timestamp
    * 
    * @param row row key
-   * @param columns Array of column names you want to retrieve.   
+   * @param columns Array of column names and families you want to retrieve.
    * @param ts timestamp
    * @return RowResult is empty if row does not exist.
    * @throws IOException
@@ -613,7 +613,7 @@
    * Get selected columns for the specified row at a specified timestamp
    * 
    * @param row row key
-   * @param columns Array of column names you want to retrieve.   
+   * @param columns Array of column names and families you want to retrieve.
    * @param ts timestamp
    * @return RowResult is empty if row does not exist.
    * @throws IOException

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=674724&r1=674723&r2=674724&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java Mon Jul
 7 22:24:36 2008
@@ -1160,6 +1160,17 @@
       for (HStore targetStore: stores.values()) {
         targetStore.getFull(key, columns, result);
       }
+      // Previous step won't fetch whole families: HBASE-631.
+      // For each column name that is just a column family, open the store
+      // related to it and fetch everything for that row. 
+      if (columns != null) {
+        for (byte[] bs : columns) {
+          if (HStoreKey.getFamilyDelimiterIndex(bs) == (bs.length - 1)) {
+            HStore store = stores.get(Bytes.mapKey(HStoreKey.getFamily(bs)));
+            store.getFull(key, null, result);
+          }
+        }
+      }
       return result;
     } finally {
       releaseRowLock(lid);

Modified: hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/client/TestHTable.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/client/TestHTable.java?rev=674724&r1=674723&r2=674724&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/client/TestHTable.java (original)
+++ hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/client/TestHTable.java Mon Jul  7
22:24:36 2008
@@ -21,7 +21,6 @@
 
 import java.io.IOException;
 import java.util.Map;
-
 import org.apache.hadoop.hbase.HBaseClusterTestCase;
 import org.apache.hadoop.hbase.HColumnDescriptor;
 import org.apache.hadoop.hbase.HConstants;
@@ -148,8 +147,6 @@
     */
   public void testTableNotFoundExceptionWithATable() {
     try {
-      HColumnDescriptor column =
-        new HColumnDescriptor(COLUMN_FAMILY);
       HBaseAdmin admin = new HBaseAdmin(conf);
       HTableDescriptor testTableADesc =
         new HTableDescriptor("table");
@@ -169,4 +166,50 @@
     }
   }
   
+  public void testGetRow() {
+    HTable table = null;
+    try {
+      HColumnDescriptor column2 =
+        new HColumnDescriptor(Bytes.toBytes("info2:"));
+      HBaseAdmin admin = new HBaseAdmin(conf);
+      HTableDescriptor testTableADesc =
+        new HTableDescriptor(tableAname);
+      testTableADesc.addFamily(column);
+      testTableADesc.addFamily(column2);
+      admin.createTable(testTableADesc);
+      
+      table = new HTable(conf, tableAname);
+      BatchUpdate batchUpdate = new BatchUpdate(row);
+      
+      for(int i = 0; i < 5; i++)
+        batchUpdate.put(COLUMN_FAMILY_STR+i, Bytes.toBytes(i));
+      
+      table.commit(batchUpdate);
+      
+      RowResult result = null;
+      result = table.getRow(row,  new byte[][] {COLUMN_FAMILY});
+      for(int i = 0; i < 5; i++)
+        assertTrue(result.containsKey(Bytes.toBytes(COLUMN_FAMILY_STR+i)));
+      
+      result = table.getRow(row);
+      for(int i = 0; i < 5; i++)
+        assertTrue(result.containsKey(Bytes.toBytes(COLUMN_FAMILY_STR+i)));
+
+      batchUpdate = new BatchUpdate(row);
+      batchUpdate.put("info2:a", Bytes.toBytes("a"));
+      table.commit(batchUpdate);
+      
+      result = table.getRow(row, new byte[][] { COLUMN_FAMILY,
+          Bytes.toBytes("info2:a") });
+      for(int i = 0; i < 5; i++)
+        assertTrue(result.containsKey(Bytes.toBytes(COLUMN_FAMILY_STR+i)));
+      assertTrue(result.containsKey(Bytes.toBytes("info2:a")));
+   
+    } catch (IOException e) {
+      e.printStackTrace();
+      fail("Should not have any exception " +
+        e.getClass());
+    }
+  }
+  
 }



Mime
View raw message