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
Cells. 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
FieldsModifier and TypeFieldDescriptionstatic final longstatic final longprivate static final org.slf4j.LoggerFields inherited from class org.apache.hadoop.hbase.regionserver.AbstractMemStore
regionServices, snapshot, snapshotId -
Constructor Summary
ConstructorsConstructorDescriptionDefault 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) ExtendedCellgetNextRow(ExtendedCell cell) getScanners(long readPt) Returns an ordered list of segments from most recent to oldest in memstoreprotected longheapSize()booleanisSloppy()protected longkeySize()Returns The total size of cells in this memstore.static voidCode to help figure if our approximation of object heap sizes is close enough.protected voidpostUpdate(MutableSegment currentActive) Issue any post update synchronization and testslongThis method is called before the flush is executed.protected booleanpreUpdate(MutableSegment currentActive, ExtendedCell cell, MemStoreSizing memstoreSizing) Issue any synchronization and test needed before applying the updatesize()protected booleansnapshot()Creates a snapshot of the current memstore.voidupdateLowestUnflushedSequenceIdInWAL(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, upsertMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:MemStoreFlush 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:AbstractMemStoreReturns The total size of cells in this memstore. We will not consider cells in the snapshot- Specified by:
keySizein classAbstractMemStore
-
heapSize
- Specified by:
heapSizein 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:AbstractMemStoreReturns an ordered list of segments from most recent to oldest in memstore- Specified by:
getSegmentsin 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:AbstractMemStoreUpdates the wal with the lowest sequence id (oldest entry) that is still in memory- Specified by:
updateLowestUnflushedSequenceIdInWALin 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
protected boolean preUpdate(MutableSegment currentActive, ExtendedCell cell, MemStoreSizing memstoreSizing) Description copied from class:AbstractMemStoreIssue any synchronization and test needed before applying the update- Specified by:
preUpdatein 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:AbstractMemStoreIssue any post update synchronization and tests- Specified by:
postUpdatein classAbstractMemStore- Parameters:
currentActive- updated segment
-
sizeAddedPreOperation
- Specified by:
sizeAddedPreOperationin 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:MemStoreThis 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
-