You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2014/09/24 06:27:25 UTC

git commit: Amend HBASE-12023 HRegion.applyFamilyMapToMemstore creates too many iterator objects; More cases (Vladimir Rodionov)

Repository: hbase
Updated Branches:
  refs/heads/0.94 6bf164109 -> a6dbb0459


Amend HBASE-12023 HRegion.applyFamilyMapToMemstore creates too many iterator objects; More cases (Vladimir Rodionov)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/a6dbb045
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/a6dbb045
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/a6dbb045

Branch: refs/heads/0.94
Commit: a6dbb04593cbafa672910f66ad218d6928f92265
Parents: 6bf1641
Author: Andrew Purtell <ap...@apache.org>
Authored: Tue Sep 23 13:12:05 2014 -0700
Committer: Andrew Purtell <ap...@apache.org>
Committed: Tue Sep 23 21:25:30 2014 -0700

----------------------------------------------------------------------
 .../hadoop/hbase/regionserver/HRegion.java      | 26 +++++++++++++++-----
 1 file changed, 20 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/a6dbb045/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java b/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
index bf3a193..5da00dc 100644
--- a/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
+++ b/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
@@ -2068,9 +2068,11 @@ public class HRegion implements HeapSize { // , Writable{
 
       byte[] family = e.getKey();
       List<KeyValue> kvs = e.getValue();
+      assert kvs instanceof RandomAccess;
       Map<byte[], Integer> kvCount = new TreeMap<byte[], Integer>(Bytes.BYTES_COMPARATOR);
-
-      for (KeyValue kv: kvs) {
+      int listSize = kvs.size();
+      for (int i=0; i < listSize; i++) {
+        KeyValue kv = kvs.get(i);
         //  Check if time is LATEST, change to time of most recent addition if so
         //  This is expensive.
         if (kv.isLatestTimestamp() && kv.isDeleteType()) {
@@ -2920,7 +2922,10 @@ public class HRegion implements HeapSize { // , Writable{
       final Iterable<List<KeyValue>> keyLists, final byte[] now) {
     for (List<KeyValue> keys: keyLists) {
       if (keys == null) continue;
-      for (KeyValue key : keys) {
+      assert keys instanceof RandomAccess;
+      int listSize = keys.size();
+      for (int i=0; i < listSize; i++) {
+        KeyValue key = keys.get(i);
         key.updateLatestStamp(now);
       }
     }
@@ -3181,7 +3186,10 @@ public class HRegion implements HeapSize { // , Writable{
     }
     long maxTs = now + timestampSlop;
     for (List<KeyValue> kvs : familyMap.values()) {
-      for (KeyValue kv : kvs) {
+      assert kvs instanceof RandomAccess;
+      int listSize = kvs.size();
+      for (int i=0; i < listSize; i++) {
+        KeyValue kv = kvs.get(i);
         // see if the user-side TS is out of range. latest = server-side
         if (!kv.isLatestTimestamp() && kv.getTimestamp() > maxTs) {
           throw new DoNotRetryIOException("Timestamp for KV out of range "
@@ -3200,7 +3208,10 @@ public class HRegion implements HeapSize { // , Writable{
   private void addFamilyMapToWALEdit(Map<byte[], List<KeyValue>> familyMap,
       WALEdit walEdit) {
     for (List<KeyValue> edits : familyMap.values()) {
-      for (KeyValue kv : edits) {
+      assert edits instanceof RandomAccess;
+      int listSize = edits.size();
+      for (int i=0; i < listSize; i++) {
+        KeyValue kv = edits.get(i);
         walEdit.add(kv);
       }
     }
@@ -6069,7 +6080,10 @@ public class HRegion implements HeapSize { // , Writable{
 
     long putSize = 0;
     for (List<KeyValue> edits : familyMap.values()) {
-      for (KeyValue kv : edits) {
+      assert edits instanceof RandomAccess;
+      int listSize = edits.size();
+      for (int i=0; i < listSize; i++) {
+        KeyValue kv = edits.get(i);
         putSize += kv.getKeyLength() + kv.getValueLength();
       }
     }