HBASE-7883 Update memstore size when removing the entries in append operation (Himanshu)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1448480 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1a766c42a1
commit
434d38a5a8
|
@ -586,7 +586,9 @@ public class MemStore implements HeapSize {
|
||||||
// which means we can prove that no scanner will see this version
|
// which means we can prove that no scanner will see this version
|
||||||
|
|
||||||
// false means there was a change, so give us the size.
|
// false means there was a change, so give us the size.
|
||||||
addedSize -= heapSizeChange(cur, true);
|
long delta = heapSizeChange(cur, true);
|
||||||
|
addedSize -= delta;
|
||||||
|
this.size.addAndGet(-delta);
|
||||||
it.remove();
|
it.remove();
|
||||||
} else {
|
} else {
|
||||||
versionsVisible++;
|
versionsVisible++;
|
||||||
|
|
|
@ -846,6 +846,36 @@ public class TestMemStore extends TestCase {
|
||||||
Integer.toString(i2));
|
Integer.toString(i2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
|
|
||||||
|
List<KeyValue> l = new ArrayList<KeyValue>();
|
||||||
|
KeyValue kv1 = KeyValueTestUtil.create("r", "f", "q", 100, "v");
|
||||||
|
KeyValue kv2 = KeyValueTestUtil.create("r", "f", "q", 101, "v");
|
||||||
|
KeyValue kv3 = KeyValueTestUtil.create("r", "f", "q", 102, "v");
|
||||||
|
|
||||||
|
kv1.setMvccVersion(1); kv2.setMvccVersion(1);kv3.setMvccVersion(1);
|
||||||
|
l.add(kv1); l.add(kv2); l.add(kv3);
|
||||||
|
|
||||||
|
this.memstore.upsert(l, 2);// readpoint is 2
|
||||||
|
long newSize = this.memstore.size.get();
|
||||||
|
assert(newSize > oldSize);
|
||||||
|
|
||||||
|
KeyValue kv4 = KeyValueTestUtil.create("r", "f", "q", 104, "v");
|
||||||
|
kv4.setMvccVersion(1);
|
||||||
|
l.clear(); l.add(kv4);
|
||||||
|
this.memstore.upsert(l, 3);
|
||||||
|
assertEquals(newSize, this.memstore.size.get());
|
||||||
|
//this.memstore = null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds {@link #ROW_COUNT} rows and {@link #QUALIFIER_COUNT}
|
* Adds {@link #ROW_COUNT} rows and {@link #QUALIFIER_COUNT}
|
||||||
* @param hmc Instance to add rows to.
|
* @param hmc Instance to add rows to.
|
||||||
|
|
Loading…
Reference in New Issue