hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject [3/3] git commit: Amend HBASE-12023 HRegion.applyFamilyMapToMemstore creates too many iterator objects; More cases (Vladimir Rodionov)
Date Tue, 23 Sep 2014 21:06:06 GMT
Amend HBASE-12023 HRegion.applyFamilyMapToMemstore creates too many iterator objects; More
cases (Vladimir Rodionov)

Conflicts:
	hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java


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

Branch: refs/heads/0.98
Commit: 3897a02a1bd30f4376c31a025f85332f6124388a
Parents: 0033b9a
Author: Andrew Purtell <apurtell@apache.org>
Authored: Tue Sep 23 13:12:05 2014 -0700
Committer: Andrew Purtell <apurtell@apache.org>
Committed: Tue Sep 23 13:53:59 2014 -0700

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/KeyValueUtil.java   |  2 +-
 .../hadoop/hbase/regionserver/HRegion.java      | 31 +++++++++++++++-----
 2 files changed, 24 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/3897a02a/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java
----------------------------------------------------------------------
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java
index 607a253..12fea64 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java
@@ -46,7 +46,7 @@ public class KeyValueUtil {
         cell.getTagsLengthUnsigned()));
   }
 
-  protected static int keyLength(final Cell cell) {
+  public static int keyLength(final Cell cell) {
     return (int)KeyValue.getKeyDataStructureSize(cell.getRowLength(), cell.getFamilyLength(),
       cell.getQualifierLength());
   }

http://git-wip-us.apache.org/repos/asf/hbase/blob/3897a02a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
index 8be1962..d2cb9f5 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
@@ -2024,9 +2024,12 @@ public class HRegion implements HeapSize { // , Writable{
 
       byte[] family = e.getKey();
       List<Cell> cells = e.getValue();
-      Map<byte[], Integer> kvCount = new TreeMap<byte[], Integer>(Bytes.BYTES_COMPARATOR);
+      assert cells instanceof RandomAccess;
 
-      for (Cell cell: cells) {
+      Map<byte[], Integer> kvCount = new TreeMap<byte[], Integer>(Bytes.BYTES_COMPARATOR);
+      int listSize = cells.size();
+      for (int i=0; i < listSize; i++) {
+        Cell cell = cells.get(i);
         KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
         //  Check if time is LATEST, change to time of most recent addition if so
         //  This is expensive.
@@ -2824,7 +2827,10 @@ public class HRegion implements HeapSize { // , Writable{
   void updateKVTimestamps(final Iterable<List<Cell>> keyLists, final byte[] now)
{
     for (List<Cell> cells: keyLists) {
       if (cells == null) continue;
-      for (Cell cell : cells) {
+      assert cells instanceof RandomAccess;
+      int listSize = cells.size();
+      for (int i=0; i < listSize; i++) {
+        Cell cell = cells.get(i);
         KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
         kv.updateLatestStamp(now);
       }
@@ -3005,7 +3011,10 @@ public class HRegion implements HeapSize { // , Writable{
     }
     long maxTs = now + timestampSlop;
     for (List<Cell> kvs : familyMap.values()) {
-      for (Cell cell : kvs) {
+      assert kvs instanceof RandomAccess;
+      int listSize  = kvs.size();
+      for (int i=0; i < listSize; i++) {
+        Cell cell = kvs.get(i);
         // see if the user-side TS is out of range. latest = server-side
         KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
         if (!kv.isLatestTimestamp() && kv.getTimestamp() > maxTs) {
@@ -3025,7 +3034,10 @@ public class HRegion implements HeapSize { // , Writable{
   private void addFamilyMapToWALEdit(Map<byte[], List<Cell>> familyMap,
       WALEdit walEdit) {
     for (List<Cell> edits : familyMap.values()) {
-      for (Cell cell : edits) {
+      assert edits instanceof RandomAccess;
+      int listSize = edits.size();
+      for (int i=0; i < listSize; i++) {
+        Cell cell = edits.get(i);
         walEdit.add(KeyValueUtil.ensureKeyValue(cell));
       }
     }
@@ -5885,9 +5897,12 @@ public class HRegion implements HeapSize { // , Writable{
 
     long mutationSize = 0;
     for (List<Cell> cells: familyMap.values()) {
-      for (Cell cell : cells) {
-        KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
-        mutationSize += kv.getKeyLength() + kv.getValueLength();
+      assert cells instanceof RandomAccess;
+      int listSize = cells.size();
+      for (int i=0; i < listSize; i++) {
+        Cell cell = cells.get(i);
+        // TODO we need include tags length also here.
+        mutationSize += KeyValueUtil.keyLength(cell) + cell.getValueLength();
       }
     }
 


Mime
View raw message