HADOOP-2198 HTable should have method to return table metadata
git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk/src/contrib/hbase@599534 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7102265285
commit
6f14e60b7f
|
@ -62,6 +62,8 @@ Trunk (unreleased changes)
|
|||
HADOOP-2262 Retry n times instead of n**2 times.
|
||||
HADOOP-1608 Relational Algrebra Operators
|
||||
(Edward Yoon via Stack)
|
||||
HADOOP-2198 HTable should have method to return table metadata
|
||||
|
||||
|
||||
Release 0.15.1
|
||||
Branch 0.15
|
||||
|
|
|
@ -163,6 +163,22 @@ public class HTable implements HConstants {
|
|||
return this.tableName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return table metadata
|
||||
* @throws IOException
|
||||
*/
|
||||
public HTableDescriptor getMetadata() throws IOException {
|
||||
HTableDescriptor [] metas = this.connection.listTables();
|
||||
HTableDescriptor result = null;
|
||||
for (int i = 0; i < metas.length; i++) {
|
||||
if (metas[i].getName().equals(this.tableName)) {
|
||||
result = metas[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the starting row key for every region in the currently open table
|
||||
* @return Array of region starting row keys
|
||||
|
|
|
@ -71,6 +71,11 @@ public class TestHTable extends HBaseClusterTestCase implements HConstants {
|
|||
// put some data into table A
|
||||
|
||||
HTable a = new HTable(conf, tableAname);
|
||||
|
||||
// Assert the metadata is good.
|
||||
HTableDescriptor meta = a.getMetadata();
|
||||
assertTrue(meta.equals(tableAdesc));
|
||||
|
||||
long lockid = a.startUpdate(row);
|
||||
a.put(lockid, COLUMN_FAMILY, value);
|
||||
a.commit(lockid);
|
||||
|
|
Loading…
Reference in New Issue