Return-Path: Delivered-To: apmail-hadoop-hbase-commits-archive@minotaur.apache.org Received: (qmail 44021 invoked from network); 28 Apr 2009 08:30:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 28 Apr 2009 08:30:19 -0000 Received: (qmail 30527 invoked by uid 500); 28 Apr 2009 08:30:19 -0000 Delivered-To: apmail-hadoop-hbase-commits-archive@hadoop.apache.org Received: (qmail 30482 invoked by uid 500); 28 Apr 2009 08:30:19 -0000 Mailing-List: contact hbase-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hbase-dev@hadoop.apache.org Delivered-To: mailing list hbase-commits@hadoop.apache.org Received: (qmail 30473 invoked by uid 99); 28 Apr 2009 08:30:19 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Apr 2009 08:30:19 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Apr 2009 08:30:17 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 1612323888EB; Tue, 28 Apr 2009 08:29:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: hbase-commits@hadoop.apache.org From: stack@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090428082956.1612323888EB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 keyList = new ArrayList(); + 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 getStartEndKeys() throws IOException { + final List startKeyList = new ArrayList(); + final List endKeyList = new ArrayList(); 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()][])); } /**