org.apache.hadoop.hbase.regionserver
Class MemStore

java.lang.Object
  extended by org.apache.hadoop.hbase.regionserver.MemStore
All Implemented Interfaces:
HeapSize

public class MemStore
extends Object
implements HeapSize

The MemStore holds in-memory modifications to the Store. Modifications are KeyValues. When asked to flush, current memstore is moved to snapshot and is cleared. We continue to serve edits out of new memstore and backing snapshot until flusher reports in that the flush succeeded. At this point we let the snapshot go. TODO: Adjust size of the memstore when we remove items because they have been deleted. TODO: With new KVSLS, need to make sure we update HeapSize with difference in KV size.


Nested Class Summary
protected  class MemStore.MemStoreScanner
           
 
Field Summary
static long DEEP_OVERHEAD
           
static long FIXED_OVERHEAD
           
 
Constructor Summary
MemStore()
          Default constructor.
MemStore(org.apache.hadoop.conf.Configuration conf, KeyValue.KVComparator c)
          Constructor.
 
Method Summary
 TimeRangeTracker getSnapshotTimeRangeTracker()
           
 long heapSize()
          Get the entire heap usage for this MemStore not including keys in the snapshot.
 long keySize()
          Get the heap usage of KVs in this MemStore.
static void main(String[] args)
          Code to help figure if our approximation of object heap sizes is close enough.
 boolean shouldSeek(Scan scan)
          Check if this memstore may contain the required keys
 long updateColumnValue(byte[] row, byte[] family, byte[] qualifier, long newValue, long now)
          Given the specs of a column, update it, first by inserting a new record, then removing the old one.
 long upsert(List<KeyValue> kvs)
          Update or insert the specified KeyValues.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FIXED_OVERHEAD

public static final long FIXED_OVERHEAD

DEEP_OVERHEAD

public static final long DEEP_OVERHEAD
Constructor Detail

MemStore

public MemStore()
Default constructor. Used for tests.


MemStore

public MemStore(org.apache.hadoop.conf.Configuration conf,
                KeyValue.KVComparator c)
Constructor.

Parameters:
c - Comparator
Method Detail

updateColumnValue

public long updateColumnValue(byte[] row,
                              byte[] family,
                              byte[] qualifier,
                              long newValue,
                              long now)
Given the specs of a column, update it, first by inserting a new record, then removing the old one. Since there is only 1 KeyValue involved, the memstoreTS will be set to 0, thus ensuring that they instantly appear to anyone. The underlying store will ensure that the insert/delete each are atomic. A scanner/reader will either get the new value, or the old value and all readers will eventually only see the new value after the old was removed.

Parameters:
row -
family -
qualifier -
newValue -
now -
Returns:
Timestamp

upsert

public long upsert(List<KeyValue> kvs)
Update or insert the specified KeyValues.

For each KeyValue, insert into MemStore. This will atomically upsert the value for that row/family/qualifier. If a KeyValue did already exist, it will then be removed.

Currently the memstoreTS is kept at 0 so as each insert happens, it will be immediately visible. May want to change this so it is atomic across all KeyValues.

This is called under row lock, so Get operations will still see updates atomically. Scans will only see each KeyValue update as atomic.

Parameters:
kvs -
Returns:
change in memstore size

shouldSeek

public boolean shouldSeek(Scan scan)
Check if this memstore may contain the required keys

Parameters:
scan -
Returns:
False if the key definitely does not exist in this Memstore

getSnapshotTimeRangeTracker

public TimeRangeTracker getSnapshotTimeRangeTracker()

heapSize

public long heapSize()
Get the entire heap usage for this MemStore not including keys in the snapshot.

Specified by:
heapSize in interface HeapSize
Returns:
Approximate 'exclusive deep size' of implementing object. Includes count of payload and hosting object sizings.

keySize

public long keySize()
Get the heap usage of KVs in this MemStore.


main

public static void main(String[] args)
Code to help figure if our approximation of object heap sizes is close enough. See hbase-900. Fills memstores then waits so user can heap dump and bring up resultant hprof in something like jprofiler which allows you get 'deep size' on objects.

Parameters:
args - main args


Copyright © 2011 The Apache Software Foundation. All Rights Reserved.