hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r769290 - in /hadoop/hbase/branches/0.19: CHANGES.txt src/java/org/apache/hadoop/hbase/client/HTable.java
Date Tue, 28 Apr 2009 08:29:55 GMT
Author: stack
Date: Tue Apr 28 08:29:55 2009
New Revision: 769290

URL: http://svn.apache.org/viewvc?rev=769290&view=rev
Log:
HBASE-1350 New method in HTable.java to return start and end keys for regions in a table 

Modified:
    hadoop/hbase/branches/0.19/CHANGES.txt
    hadoop/hbase/branches/0.19/src/java/org/apache/hadoop/hbase/client/HTable.java

Modified: hadoop/hbase/branches/0.19/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.19/CHANGES.txt?rev=769290&r1=769289&r2=769290&view=diff
==============================================================================
--- hadoop/hbase/branches/0.19/CHANGES.txt (original)
+++ hadoop/hbase/branches/0.19/CHANGES.txt Tue Apr 28 08:29:55 2009
@@ -12,6 +12,8 @@
                not exist (Rong-en Fan via Stack)
    HBASE-1287  Partitioner class not used in TableMapReduceUtil.initTableReduceJob()
                (Lars George and Billy Pearson via Stack)
+   HBASE-1350  New method in HTable.java to return start and end keys for
+               regions in a table (Vimal Mathew via Stack)
 
 Release 0.19.1 - 03/19/2009
   BUG FIXES

Modified: hadoop/hbase/branches/0.19/src/java/org/apache/hadoop/hbase/client/HTable.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.19/src/java/org/apache/hadoop/hbase/client/HTable.java?rev=769290&r1=769289&r2=769290&view=diff
==============================================================================
--- hadoop/hbase/branches/0.19/src/java/org/apache/hadoop/hbase/client/HTable.java (original)
+++ hadoop/hbase/branches/0.19/src/java/org/apache/hadoop/hbase/client/HTable.java Tue Apr
28 08:29:55 2009
@@ -47,6 +47,7 @@
 import org.apache.hadoop.hbase.io.RowResult;
 import org.apache.hadoop.hbase.io.HbaseMapWritable;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.Pair;
 import org.apache.hadoop.hbase.util.Writables;
 
 /**
@@ -227,7 +228,29 @@
    * @throws IOException
    */
   public byte[][] getStartKeys() throws IOException {
-    final List<byte[]> keyList = new ArrayList<byte[]>();
+    return getStartEndKeys().getFirst();
+  }
+
+  /**
+   * Gets the ending row key for every region in the currently open table
+   * 
+   * @return Array of region ending row keys
+   * @throws IOException
+   */
+  public byte[][] getEndKeys() throws IOException {
+    return getStartEndKeys().getSecond();
+  }
+
+  /**
+   * Gets the starting and ending row keys for every region in the currently open table
+   * 
+   * @return Pair of arrays of region starting and ending row keys
+   * @throws IOException
+   */
+  @SuppressWarnings("unchecked")
+  public Pair<byte[][],byte[][]> getStartEndKeys() throws IOException {
+    final List<byte[]> startKeyList = new ArrayList<byte[]>();
+    final List<byte[]> endKeyList = new ArrayList<byte[]>();
 
     MetaScannerVisitor visitor = new MetaScannerVisitor() {
       public boolean processRow(RowResult rowResult) throws IOException {
@@ -235,7 +258,8 @@
             rowResult.get(HConstants.COL_REGIONINFO));
         if (Bytes.equals(info.getTableDesc().getName(), getTableName())) {
           if (!(info.isOffline() || info.isSplit())) {
-            keyList.add(info.getStartKey());
+            startKeyList.add(info.getStartKey());
+            endKeyList.add(info.getEndKey());
           }
         }
         return true;
@@ -243,7 +267,8 @@
 
     };
     MetaScanner.metaScan(configuration, visitor, this.tableName);
-    return keyList.toArray(new byte[keyList.size()][]);
+    return new Pair(startKeyList.toArray(new byte[startKeyList.size()][]),
+                endKeyList.toArray(new byte[endKeyList.size()][]));
   }
 
   /**



Mime
View raw message