HBASE-3701 revisit ArrayList creation

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1092431 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2011-04-14 18:35:19 +00:00
parent 7f90ea5860
commit 84c44732f9
2 changed files with 11 additions and 4 deletions

View File

@ -159,6 +159,7 @@ Release 0.91.0 - Unreleased
book metrics section (Doug Meil)
HBASE-3759 Eliminate use of ThreadLocals for CoprocessorEnvironment
bypass() and complete()
HBASE-3701 revisit ArrayList creation (Ted Yu via Stack)
TASKS
HBASE-3559 Move report of split to master OFF the heartbeat channel

View File

@ -1202,6 +1202,8 @@ public class HConnectionManager {
HServerAddress [] lastServers = new HServerAddress[results.length];
List<Row> workingList = new ArrayList<Row>(list);
boolean retry = true;
// count that helps presize actions array
int actionCount = 0;
Throwable singleRowCause = null;
for (int tries = 0; tries < numRetries && retry; ++tries) {
@ -1292,6 +1294,7 @@ public class HConnectionManager {
// order), so they can be retried.
retry = false;
workingList.clear();
actionCount = 0;
for (int i = 0; i < results.length; i++) {
// if null (fail) or instanceof Throwable && not instanceof DNRIOE
// then retry that row. else dont.
@ -1300,11 +1303,14 @@ public class HConnectionManager {
!(results[i] instanceof DoNotRetryIOException))) {
retry = true;
actionCount++;
Row row = list.get(i);
workingList.add(row);
deleteCachedLocation(tableName, row.getRow());
} else {
if (results[i] != null && results[i] instanceof Throwable) {
actionCount++;
}
// add null to workingList, so the order remains consistent with the original list argument.
workingList.add(null);
}
@ -1319,9 +1325,9 @@ public class HConnectionManager {
}
List<Throwable> exceptions = new ArrayList<Throwable>();
List<Row> actions = new ArrayList<Row>();
List<HServerAddress> addresses = new ArrayList<HServerAddress>();
List<Throwable> exceptions = new ArrayList<Throwable>(actionCount);
List<Row> actions = new ArrayList<Row>(actionCount);
List<HServerAddress> addresses = new ArrayList<HServerAddress>(actionCount);
for (int i = 0 ; i < results.length; i++) {
if (results[i] == null || results[i] instanceof Throwable) {