Author: stack
Date: Thu Apr 14 18:35:19 2011
New Revision: 1092431
URL: http://svn.apache.org/viewvc?rev=1092431&view=rev
Log:
HBASE-3701 revisit ArrayList creation
Modified:
hbase/trunk/CHANGES.txt
hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
Modified: hbase/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1092431&r1=1092430&r2=1092431&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Thu Apr 14 18:35:19 2011
@@ -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
Modified:
hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
URL:
http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java?rev=1092431&r1=1092430&r2=1092431&view=diff
==============================================================================
---
hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
(original)
+++
hbase/trunk/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
Thu Apr 14 18:35:19 2011
@@ -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) {