Class DefaultMemStore
java.lang.Object
org.apache.hadoop.hbase.regionserver.AbstractMemStore
org.apache.hadoop.hbase.regionserver.DefaultMemStore
- All Implemented Interfaces:
Closeable
,AutoCloseable
,MemStore
The MemStore holds in-memory modifications to the Store. Modifications are
Cell
s. 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.
The MemStore functions should not be called in parallel. Callers should hold write and read
locks. This is done in HStore
.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final long
static final long
private static final org.slf4j.Logger
Fields inherited from class org.apache.hadoop.hbase.regionserver.AbstractMemStore
regionServices, snapshot, snapshotId
-
Constructor Summary
ConstructorDescriptionDefault constructor.DefaultMemStore
(org.apache.hadoop.conf.Configuration conf, CellComparator c) Constructor.DefaultMemStore
(org.apache.hadoop.conf.Configuration conf, CellComparator c, RegionServicesForStores regionServices) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionFlush will first clear out the data in snapshot if any (It will take a second flush invocation to clear the current Cell set).(package private) Cell
getNextRow
(Cell cell) getScanners
(long readPt) Returns an ordered list of segments from most recent to oldest in memstoreprotected long
heapSize()
boolean
isSloppy()
protected long
keySize()
Returns The total size of cells in this memstore.static void
Code to help figure if our approximation of object heap sizes is close enough.protected void
postUpdate
(MutableSegment currentActive) Issue any post update synchronization and testslong
This method is called before the flush is executed.protected boolean
preUpdate
(MutableSegment currentActive, Cell cell, MemStoreSizing memstoreSizing) Issue any synchronization and test needed before applying the updatesize()
protected boolean
snapshot()
Creates a snapshot of the current memstore.void
updateLowestUnflushedSequenceIdInWAL
(boolean onlyIfMoreRecent) Updates the wal with the lowest sequence id (oldest entry) that is still in memoryMethods inherited from class org.apache.hadoop.hbase.regionserver.AbstractMemStore
add, add, addToScanners, addToScanners, clearSnapshot, close, doAdd, doClearSnapShot, dump, getActive, getComparator, getConfiguration, getLowest, getNextRow, getSnapshot, getSnapshotSize, resetActive, resetTimeOfOldestEdit, timeOfOldestEdit, toString, upsert
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.hadoop.hbase.regionserver.MemStore
startReplayingFromWAL, stopReplayingFromWAL
-
Field Details
-
LOG
-
DEEP_OVERHEAD
-
FIXED_OVERHEAD
-
-
Constructor Details
-
DefaultMemStore
public DefaultMemStore()Default constructor. Used for tests. -
DefaultMemStore
Constructor.- Parameters:
c
- Comparator
-
DefaultMemStore
public DefaultMemStore(org.apache.hadoop.conf.Configuration conf, CellComparator c, RegionServicesForStores regionServices) Constructor.- Parameters:
c
- Comparator
-
-
Method Details
-
snapshot
Creates a snapshot of the current memstore. Snapshot must be cleared by call toAbstractMemStore.clearSnapshot(long)
- Returns:
MemStoreSnapshot
-
getFlushableSize
Description copied from interface:MemStore
Flush will first clear out the data in snapshot if any (It will take a second flush invocation to clear the current Cell set). If snapshot is empty, current Cell set will be flushed.- Returns:
- On flush, how much memory we will clear.
-
keySize
Description copied from class:AbstractMemStore
Returns The total size of cells in this memstore. We will not consider cells in the snapshot- Specified by:
keySize
in classAbstractMemStore
-
heapSize
- Specified by:
heapSize
in classAbstractMemStore
- Returns:
- The total heap size of cells in this memstore. We will not consider cells in the snapshot
-
getScanners
- Returns:
- scanner over the memstore. This might include scanner over the snapshot when one is present.
- Throws:
IOException
-
getSnapshotSegments
-
getSegments
Description copied from class:AbstractMemStore
Returns an ordered list of segments from most recent to oldest in memstore- Specified by:
getSegments
in classAbstractMemStore
- Throws:
IOException
-
getNextRow
- Parameters:
cell
- Find the row that comes after this one. If null, we return the first.- Returns:
- Next row or null if none found.
-
updateLowestUnflushedSequenceIdInWAL
Description copied from class:AbstractMemStore
Updates the wal with the lowest sequence id (oldest entry) that is still in memory- Specified by:
updateLowestUnflushedSequenceIdInWAL
in classAbstractMemStore
- Parameters:
onlyIfMoreRecent
- a flag that marks whether to update the sequence id no matter what or only if it is greater than the previous sequence id
-
preUpdate
Description copied from class:AbstractMemStore
Issue any synchronization and test needed before applying the update- Specified by:
preUpdate
in classAbstractMemStore
- Parameters:
currentActive
- the segment to be updatedcell
- the cell to be addedmemstoreSizing
- object to accumulate region size changes- Returns:
- true iff can proceed with applying the update
-
postUpdate
Description copied from class:AbstractMemStore
Issue any post update synchronization and tests- Specified by:
postUpdate
in classAbstractMemStore
- Parameters:
currentActive
- updated segment
-
sizeAddedPreOperation
- Specified by:
sizeAddedPreOperation
in classAbstractMemStore
-
size
- Returns:
- Total memory occupied by this MemStore. This won't include any size occupied by the snapshot. We assume the snapshot will get cleared soon. This is not thread safe and the memstore may be changed while computing its size. It is the responsibility of the caller to make sure this doesn't happen.
-
preFlushSeqIDEstimation
Description copied from interface:MemStore
This method is called before the flush is executed.- Returns:
- an estimation (lower bound) of the unflushed sequence id in memstore after the flush is
executed. if memstore will be cleared returns
HConstants.NO_SEQNUM
.
-
isSloppy
-
main
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
-