.../apache/hadoop/hbase/regionserver/HRegion.java | 21 ++++++++++++++++----- .../hadoop/hbase/regionserver/wal/WALEdit.java | 11 ++++++++++- 2 files changed, 26 insertions(+), 6 deletions(-) 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 f03c205..a82cdee 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 @@ -2989,7 +2989,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi Set deletesCfSet = null; long currentNonceGroup = HConstants.NO_NONCE, currentNonce = HConstants.NO_NONCE; - WALEdit walEdit = new WALEdit(isInReplay); + WALEdit walEdit = null; MultiVersionConcurrencyControl.WriteEntry writeEntry = null; long txid = 0; boolean doRollBackMemstore = false; @@ -3006,6 +3006,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi int noOfPuts = 0, noOfDeletes = 0; WALKey walKey = null; long mvccNum = 0; + int cellCount = 0; try { // ------------------------------------ // STEP 1. Try to acquire as many locks as we can, and ensure @@ -3020,7 +3021,6 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi Map> familyMap = mutation.getFamilyCellMap(); // store the family map reference to allow for mutations familyMaps[lastIndexExclusive] = familyMap; - // skip anything that "ran" already if (batchOp.retCodeDetails[lastIndexExclusive].getOperationStatusCode() != OperationStatusCode.NOT_RUN) { @@ -3079,7 +3079,11 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi lastIndexExclusive++; numReadyToWrite++; - + if (isInReplay) { + for (List cells : mutation.getFamilyCellMap().values()) { + cellCount += cells.size(); + } + } if (isPutMutation) { // If Column Families stay consistent through out all of the // individual puts then metrics can be reported as a mutliput across @@ -3127,8 +3131,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 cells : familyMaps[i].values()) { + cellCount += cells.size(); + } } - + walEdit = new WALEdit(cellCount); lock(this.updatesLock.readLock(), numReadyToWrite); locked = true; @@ -3177,7 +3188,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi currentNonceGroup, currentNonce, mvcc); txid = this.wal.append(this.htableDescriptor, this.getRegionInfo(), walKey, walEdit, true); - walEdit = new WALEdit(isInReplay); + walEdit = new WALEdit(cellCount, isInReplay); walKey = null; } currentNonceGroup = nonceGroup; 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 cells = new ArrayList(1); + private ArrayList 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(cellCount); } /**