You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by sy...@apache.org on 2016/02/13 21:10:22 UTC

[11/22] hbase git commit: HBASE-15204 Try to estimate the cell count for adding into WALEdit (Ram)

HBASE-15204 Try to estimate the cell count for adding into WALEdit (Ram)


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

Branch: refs/heads/hbase-12439
Commit: fec97338931f2617ddb99bf7faad67d0a0ee2ddf
Parents: 1942a99
Author: ramkrishna <ra...@gmail.com>
Authored: Thu Feb 11 09:09:25 2016 +0530
Committer: ramkrishna <ra...@gmail.com>
Committed: Thu Feb 11 09:09:25 2016 +0530

----------------------------------------------------------------------
 .../hadoop/hbase/regionserver/HRegion.java      | 20 ++++++++++++++++----
 .../hadoop/hbase/regionserver/wal/WALEdit.java  | 11 ++++++++++-
 2 files changed, 26 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/fec97338/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 ac846b6..3e6c092 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
@@ -2951,7 +2951,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
     Set<byte[]> deletesCfSet = null;
     long currentNonceGroup = HConstants.NO_NONCE;
     long currentNonce = HConstants.NO_NONCE;
-    WALEdit walEdit = new WALEdit(replay);
+    WALEdit walEdit = null;
     boolean locked = false;
     // reference family maps directly so coprocessors can mutate them if desired
     Map<byte[], List<Cell>>[] familyMaps = new Map[batchOp.operations.length];
@@ -2962,6 +2962,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
     int noOfPuts = 0;
     int noOfDeletes = 0;
     WriteEntry writeEntry = null;
+    int cellCount = 0;
     /** Keep track of the locks we hold so we can release them in finally clause */
     List<RowLock> acquiredRowLocks = Lists.newArrayListWithCapacity(batchOp.operations.length);
     try {
@@ -2990,7 +2991,11 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
 
         lastIndexExclusive++;
         numReadyToWrite++;
-
+        if (replay) {
+          for (List<Cell> cells : mutation.getFamilyCellMap().values()) {
+            cellCount += cells.size();
+          }
+        }
         if (mutation instanceof Put) {
           // If Column Families stay consistent through out all of the
           // individual puts then metrics can be reported as a multiput across
@@ -3041,8 +3046,15 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
           noOfDeletes++;
         }
         rewriteCellTags(familyMaps[i], mutation);
+        WALEdit fromCP = batchOp.walEditsFromCoprocessors[i];
+        if (fromCP != null) {
+          cellCount += fromCP.size();
+        }
+        for (List<Cell> cells : familyMaps[i].values()) {
+          cellCount += cells.size();
+        }
       }
-
+      walEdit = new WALEdit(cellCount, replay);
       lock(this.updatesLock.readLock(), numReadyToWrite);
       locked = true;
 
@@ -3082,7 +3094,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
         if (nonceGroup != currentNonceGroup || nonce != currentNonce) {
           // Write what we have so far for nonces out to WAL
           appendCurrentNonces(m, replay, walEdit, now, currentNonceGroup, currentNonce);
-          walEdit = new WALEdit(replay);
+          walEdit = new WALEdit(cellCount, replay);
           currentNonceGroup = nonceGroup;
           currentNonce = nonce;
         }

http://git-wip-us.apache.org/repos/asf/hbase/blob/fec97338/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALEdit.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALEdit.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALEdit.java
index cea2ee7..346a8ed 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALEdit.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALEdit.java
@@ -99,7 +99,7 @@ public class WALEdit implements Writable, HeapSize {
   private final int VERSION_2 = -1;
   private final boolean isReplay;
 
-  private ArrayList<Cell> cells = new ArrayList<Cell>(1);
+  private ArrayList<Cell> cells = null;
 
   public static final WALEdit EMPTY_WALEDIT = new WALEdit();
 
@@ -117,7 +117,16 @@ public class WALEdit implements Writable, HeapSize {
   }
 
   public WALEdit(boolean isReplay) {
+    this(1, isReplay);
+  }
+
+  public WALEdit(int cellCount) {
+    this(cellCount, false);
+  }
+
+  public WALEdit(int cellCount, boolean isReplay) {
     this.isReplay = isReplay;
+    cells = new ArrayList<Cell>(cellCount);
   }
 
   /**