You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2014/10/14 23:11:19 UTC
git commit: HBASE-12247 Replace setHTable() with initializeTable() in
TableInputFormat. (Solomon Duskis)
Repository: hbase
Updated Branches:
refs/heads/master dc8600152 -> 3544f4e98
HBASE-12247 Replace setHTable() with initializeTable() in TableInputFormat. (Solomon Duskis)
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/3544f4e9
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/3544f4e9
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/3544f4e9
Branch: refs/heads/master
Commit: 3544f4e98b4aa6e0082c67883a37aa6bffc02003
Parents: dc86001
Author: stack <st...@apache.org>
Authored: Tue Oct 14 14:11:21 2014 -0700
Committer: stack <st...@apache.org>
Committed: Tue Oct 14 14:11:21 2014 -0700
----------------------------------------------------------------------
.../hadoop/hbase/mapreduce/TableInputFormat.java | 7 ++-----
.../hadoop/hbase/mapreduce/TableInputFormatBase.java | 14 +++++++++-----
2 files changed, 11 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/3544f4e9/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableInputFormat.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableInputFormat.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableInputFormat.java
index 8dac05a..56ae349 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableInputFormat.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableInputFormat.java
@@ -30,7 +30,6 @@ import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.classification.InterfaceStability;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;
-import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.RegionLocator;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.util.Bytes;
@@ -109,9 +108,8 @@ implements Configurable {
this.conf = configuration;
TableName tableName = TableName.valueOf(conf.get(INPUT_TABLE));
try {
- // TODO: Replace setHTable() with initializeTable() once we have
- // a clean method of closing a connection.
- setHTable(new HTable(new Configuration(conf), tableName));
+ // NOTE: This connection doesn't currently get closed explicit1ly.
+ initializeTable(ConnectionFactory.createConnection(new Configuration(conf)), tableName);
} catch (Exception e) {
LOG.error(StringUtils.stringifyException(e));
}
@@ -183,7 +181,6 @@ implements Configurable {
*
* @param scan The Scan to update.
* @param familyAndQualifier family and qualifier
- * @return A reference to this instance.
* @throws IllegalArgumentException When familyAndQualifier is invalid.
*/
private static void addColumn(Scan scan, byte[] familyAndQualifier) {
http://git-wip-us.apache.org/repos/asf/hbase/blob/3544f4e9/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableInputFormatBase.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableInputFormatBase.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableInputFormatBase.java
index ff41314..6560b41 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableInputFormatBase.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableInputFormatBase.java
@@ -96,6 +96,8 @@ extends InputFormat<ImmutableBytesWritable, Result> {
*
* @see Scan */
private Scan scan = null;
+ /** The {@link Admin}. */
+ private Admin admin;
/** The {@link Table} to scan. */
private Table table;
/** The {@link RegionLocator} of the table. */
@@ -163,8 +165,8 @@ extends InputFormat<ImmutableBytesWritable, Result> {
throw new IOException("No table was provided.");
}
- RegionSizeCalculator sizeCalculator = new RegionSizeCalculator((HTable) table);
-
+ RegionSizeCalculator sizeCalculator = new RegionSizeCalculator(regionLocator, admin);
+
Pair<byte[][], byte[][]> keys = getStartEndKeys();
if (keys == null || keys.getFirst() == null ||
keys.getFirst().length == 0) {
@@ -287,25 +289,27 @@ extends InputFormat<ImmutableBytesWritable, Result> {
* Allows subclasses to set the {@link HTable}.
*
* @param table The table to get the data from.
- * @throws IOExceptfion
+ * @throws IOException
* @deprecated Use {@link #initializeTable(Connection, TableName)} instead.
*/
@Deprecated
protected void setHTable(HTable table) throws IOException {
this.table = table;
this.regionLocator = table;
+ this.admin = table.getConnection().getAdmin();
}
/**
- * Allows subclasses to initalize the table information.
+ * Allows subclasses to initialize the table information.
*
* @param connection The {@link Connection} to the HBase cluster.
* @param tableName The {@link TableName} of the table to process.
- * @throws IOExceptfion
+ * @throws IOException
*/
protected void initializeTable(Connection connection, TableName tableName) throws IOException {
this.table = connection.getTable(tableName);
this.regionLocator = connection.getRegionLocator(tableName);
+ this.admin = connection.getAdmin();
}
/**