hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject svn commit: r786693 - in /hadoop/hbase/trunk: CHANGES.txt src/java/org/apache/hadoop/hbase/regionserver/HRegion.java src/java/org/apache/hadoop/hbase/regionserver/Store.java
Date Fri, 19 Jun 2009 22:15:41 GMT
Author: apurtell
Date: Fri Jun 19 22:15:40 2009
New Revision: 786693

URL: http://svn.apache.org/viewvc?rev=786693&view=rev
Log:
HBASE-1547 atomicIncrement doesnt increase hregion.memcacheSize

Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/Store.java

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=786693&r1=786692&r2=786693&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Fri Jun 19 22:15:40 2009
@@ -209,6 +209,7 @@
    HBASE-1387  Before release verify all object sizes using Ryans' instrumented
                JVM trick (Erik Holstad via Stack)
    HBASE-1545  atomicIncrements creating new values with Long.MAX_VALUE
+   HBASE-1547  atomicIncrement doesnt increase hregion.memcacheSize
 
   IMPROVEMENTS
    HBASE-1089  Add count of regions on filesystem to master UI; add percentage

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=786693&r1=786692&r2=786693&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegion.java Fri Jun
19 22:15:40 2009
@@ -2275,16 +2275,29 @@
       byte [] qualifier, long amount)
   throws IOException {
     checkRow(row);
-    
+
+    boolean flush = false;
     // Lock row
     Integer lid = obtainRowLock(row);
     long result = 0L;
     try {
       Store store = stores.get(family);
-      result = store.incrementColumnValue(row, family, qualifier, amount);
+
+      Store.ValueAndSize vas =
+          store.incrementColumnValue(row, family, qualifier, amount);
+
+      result = vas.value;
+      long size = this.memcacheSize.addAndGet(vas.sizeAdded);
+      flush = isFlushSize(size);
     } finally {
       releaseRowLock(lid);
     }
+
+    if (flush) {
+      // Request a cache flush.  Do it outside update lock.
+      requestFlush();
+    }
+
     return result;
   }
     

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/Store.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/Store.java?rev=786693&r1=786692&r2=786693&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/Store.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/Store.java Fri Jun 19
22:15:40 2009
@@ -1494,6 +1494,15 @@
     // Run a GET scan and put results into the specified list 
     scanner.get(result);
   }
+
+  public static class ValueAndSize {
+    public long value;
+    public long sizeAdded;
+    public ValueAndSize(long value, long sizeAdded) {
+      this.value = value;
+      this.sizeAdded = sizeAdded;
+    }
+  }
   
   /**
    * Increments the value for the given row/family/qualifier
@@ -1504,7 +1513,7 @@
    * @return The new value.
    * @throws IOException
    */
-  public long incrementColumnValue(byte [] row, byte [] family,
+  public ValueAndSize incrementColumnValue(byte [] row, byte [] family,
       byte [] qualifier, long amount) throws IOException {
     long value = 0;
     List<KeyValue> result = new ArrayList<KeyValue>();
@@ -1527,9 +1536,8 @@
       value = Bytes.toLong(buffer, valueOffset, Bytes.SIZEOF_LONG) + amount;
       Bytes.putBytes(buffer, valueOffset, Bytes.toBytes(value), 0, 
           Bytes.SIZEOF_LONG);
-      return value;
+      return new ValueAndSize(value, 0);
     }
-    
     // Check if we even have storefiles
     if(this.storefiles.isEmpty()) {
       return addNewKeyValue(row, family, qualifier, value, amount);
@@ -1552,14 +1560,13 @@
     return addNewKeyValue(row, family, qualifier, value, amount);
   }
   
-  private long addNewKeyValue(byte [] row, byte [] family, byte [] qualifier, 
+  private ValueAndSize addNewKeyValue(byte [] row, byte [] family, byte [] qualifier,
       long value, long amount) {
     long newValue = value + amount;
     KeyValue newKv = new KeyValue(row, family, qualifier,
         System.currentTimeMillis(),
         Bytes.toBytes(newValue));
     add(newKv);
-    return newValue;
+    return new ValueAndSize(newValue, newKv.heapSize());
   }
-  
 }



Mime
View raw message