hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From la...@apache.org
Subject svn commit: r1450084 - in /hbase/branches/0.94/src: main/java/org/apache/hadoop/hbase/regionserver/MemStore.java test/java/org/apache/hadoop/hbase/regionserver/TestMemStore.java
Date Tue, 26 Feb 2013 08:51:53 GMT
Author: larsh
Date: Tue Feb 26 08:51:52 2013
New Revision: 1450084

URL: http://svn.apache.org/r1450084
Log:
HBASE-7883 Update memstore size when removing the entries in append operation (Himanshu Vashishtha)

Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/MemStore.java
    hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemStore.java

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/MemStore.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/MemStore.java?rev=1450084&r1=1450083&r2=1450084&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/MemStore.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/MemStore.java Tue
Feb 26 08:51:52 2013
@@ -584,7 +584,9 @@ public class MemStore implements HeapSiz
         if (kv.getType() == KeyValue.Type.Put.getCode() &&
             kv.getMemstoreTS() == 0) {
           // false means there was a change, so give us the size.
-          addedSize -= heapSizeChange(kv, true);
+          long delta = heapSizeChange(cur, true);
+          addedSize -= delta;
+          this.size.addAndGet(-delta);
           it.remove();
         }
       } else {

Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemStore.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemStore.java?rev=1450084&r1=1450083&r2=1450084&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemStore.java
(original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemStore.java
Tue Feb 26 08:51:52 2013
@@ -25,6 +25,7 @@ import java.lang.management.MemoryMXBean
 import java.rmi.UnexpectedException;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicReference;
 
@@ -850,7 +851,26 @@ public class TestMemStore extends TestCa
   }
 
   /**
-   * Adds {@link #ROW_COUNT} rows and {@link #QUALIFIER_COUNT}
+   * Add keyvalues with a fixed memstoreTs, and checks that memstore size is decreased
+   * as older keyvalues are deleted from the memstore.
+   * @throws Exception
+   */
+  public void testUpsertMemstoreSize() throws Exception {
+    Configuration conf = HBaseConfiguration.create();
+    memstore = new MemStore(conf, KeyValue.COMPARATOR);
+    long oldSize = memstore.size.get();
+    
+    KeyValue kv1 = KeyValueTestUtil.create("r", "f", "q", 100, "v");
+    this.memstore.upsert(Collections.singletonList(kv1));
+    long newSize = this.memstore.size.get();
+    assert(newSize > oldSize);
+    
+    KeyValue kv2 = KeyValueTestUtil.create("r", "f", "q", 101, "v");
+    this.memstore.upsert(Collections.singletonList(kv2));
+    assertEquals(newSize, this.memstore.size.get());
+  }
+
+  /**   * Adds {@link #ROW_COUNT} rows and {@link #QUALIFIER_COUNT}
    * @param hmc Instance to add rows to.
    * @return How many rows we added.
    * @throws IOException



Mime
View raw message