HBASE-19245 MultiTableInputFormatBase#getSplits creates a Connection per Table

We make one Connection only instead of a Connection per table (Change is
just moving one line it involves right-shifting body of the function)
This commit is contained in:
Michael Stack 2017-11-13 11:42:10 -08:00
parent 7139113fde
commit 3ad300a2b0
No known key found for this signature in database
GPG Key ID: 9816C7FC8ACC93D2
1 changed files with 50 additions and 48 deletions

View File

@ -178,13 +178,13 @@ public abstract class MultiTableInputFormatBase extends
List<InputSplit> splits = new ArrayList<>();
Iterator iter = tableMaps.entrySet().iterator();
// Make a single Connection to the Cluster and use it across all tables.
try (Connection conn = ConnectionFactory.createConnection(context.getConfiguration())) {
while (iter.hasNext()) {
Map.Entry<TableName, List<Scan>> entry = (Map.Entry<TableName, List<Scan>>) iter.next();
TableName tableName = entry.getKey();
List<Scan> scanList = entry.getValue();
try (Connection conn = ConnectionFactory.createConnection(context.getConfiguration());
Table table = conn.getTable(tableName);
try (Table table = conn.getTable(tableName);
RegionLocator regionLocator = conn.getRegionLocator(tableName)) {
RegionSizeCalculator sizeCalculator = new RegionSizeCalculator(
regionLocator, conn.getAdmin());
@ -230,13 +230,15 @@ public abstract class MultiTableInputFormatBase extends
splits.add(split);
if (LOG.isDebugEnabled())
if (LOG.isDebugEnabled()) {
LOG.debug("getSplits: split -> " + (count++) + " -> " + split);
}
}
}
}
}
}
}
return splits;
}