Class AbstractMemStore
java.lang.Object
org.apache.hadoop.hbase.regionserver.AbstractMemStore
- All Implemented Interfaces:
Closeable
,AutoCloseable
,MemStore
- Direct Known Subclasses:
CompactingMemStore
,DefaultMemStore
An abstract class, which implements the behaviour shared by all concrete memstore instances.
-
Field Summary
Modifier and TypeFieldDescriptionprivate MutableSegment
private final CellComparator
private final org.apache.hadoop.conf.Configuration
static final long
static final long
private static final long
protected RegionServicesForStores
protected ImmutableSegment
protected long
private long
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractMemStore
(org.apache.hadoop.conf.Configuration conf, CellComparator c, RegionServicesForStores regionServices) -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(Iterable<ExtendedCell> cells, MemStoreSizing memstoreSizing) Write the updatesvoid
add
(ExtendedCell cell, MemStoreSizing memstoreSizing) Write an updatestatic void
addToScanners
(List<? extends Segment> segments, long readPt, List<KeyValueScanner> scanners) protected static void
addToScanners
(Segment segment, long readPt, List<KeyValueScanner> scanners) void
clearSnapshot
(long id) This method is protected underHStore#lock
write lock,
and this method is used byHStore#updateStorefiles
after flushing is completed.
The passed snapshot was successfully persisted; it can be let go.void
close()
Close the memstore.private static ExtendedCell
deepCopyIfNeeded
(ExtendedCell cell) protected void
doAdd
(MutableSegment currentActive, ExtendedCell cell, MemStoreSizing memstoreSizing) private void
doAddOrUpsert
(ExtendedCell cell, long readpoint, MemStoreSizing memstoreSizing, boolean doAdd) protected void
private void
doUpsert
(MutableSegment currentActive, ExtendedCell cell, long readpoint, MemStoreSizing memstoreSizing) protected void
dump
(org.slf4j.Logger log) (package private) MutableSegment
protected CellComparator
protected org.apache.hadoop.conf.Configuration
protected ExtendedCell
Returns Return lowest of a or b or null if both a and b are nullprotected ExtendedCell
getNextRow
(ExtendedCell key, NavigableSet<ExtendedCell> set) Returns an ordered list of segments from most recent to oldest in memstore(package private) ImmutableSegment
Return the size of the snapshot(s) if anyprotected abstract long
heapSize()
private void
internalAdd
(MutableSegment currentActive, ExtendedCell toAdd, boolean mslabUsed, MemStoreSizing memstoreSizing) Internal version of add() that doesn't clone Cells with the allocator, and doesn't take the lock.protected abstract long
keySize()
Returns The total size of cells in this memstore.private ExtendedCell
maybeCloneWithAllocator
(MutableSegment currentActive, ExtendedCell cell, boolean forceCloneOfBigCell) If the segment has a memory allocator the cell is being cloned to this space, and returned; Otherwise the given cell is returned When a cell's size is too big (bigger than maxAlloc), it is not allocated on MSLAB.protected abstract void
postUpdate
(MutableSegment currentActive) Issue any post update synchronization and testsprotected abstract boolean
preUpdate
(MutableSegment currentActive, ExtendedCell cell, MemStoreSizing memstoreSizing) Issue any synchronization and test needed before applying the updateprotected void
protected void
private void
protected abstract boolean
long
Returns Oldest timestamp of all the Cells in the MemStoretoString()
abstract void
updateLowestUnflushedSequenceIdInWAL
(boolean onlyIfMoreRecent) Updates the wal with the lowest sequence id (oldest entry) that is still in memoryvoid
upsert
(Iterable<ExtendedCell> cells, long readpoint, MemStoreSizing memstoreSizing) Update or insert the specified cells.private void
upsert
(ExtendedCell cell, long readpoint, MemStoreSizing memstoreSizing) 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
getFlushableSize, getScanners, isSloppy, preFlushSeqIDEstimation, size, snapshot, startReplayingFromWAL, stopReplayingFromWAL
-
Field Details
-
NO_SNAPSHOT_ID
- See Also:
-
conf
-
comparator
-
active
-
snapshot
-
snapshotId
-
timeOfOldestEdit
-
regionServices
-
FIXED_OVERHEAD
-
DEEP_OVERHEAD
-
-
Constructor Details
-
AbstractMemStore
protected AbstractMemStore(org.apache.hadoop.conf.Configuration conf, CellComparator c, RegionServicesForStores regionServices)
-
-
Method Details
-
addToScanners
public static void addToScanners(List<? extends Segment> segments, long readPt, List<KeyValueScanner> scanners) -
addToScanners
-
resetActive
-
resetTimeOfOldestEdit
-
updateLowestUnflushedSequenceIdInWAL
Updates the wal with the lowest sequence id (oldest entry) that is still in memory- 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
-
add
Description copied from interface:MemStore
Write the updates -
add
Description copied from interface:MemStore
Write an update -
upsert
-
doAddOrUpsert
private void doAddOrUpsert(ExtendedCell cell, long readpoint, MemStoreSizing memstoreSizing, boolean doAdd) -
doAdd
protected void doAdd(MutableSegment currentActive, ExtendedCell cell, MemStoreSizing memstoreSizing) -
doUpsert
private void doUpsert(MutableSegment currentActive, ExtendedCell cell, long readpoint, MemStoreSizing memstoreSizing) -
preUpdate
protected abstract boolean preUpdate(MutableSegment currentActive, ExtendedCell cell, MemStoreSizing memstoreSizing) Issue any synchronization and test needed before applying the update- 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
Issue any post update synchronization and tests- Parameters:
currentActive
- updated segment
-
deepCopyIfNeeded
-
upsert
Description copied from interface:MemStore
Update or insert the specified cells.For each Cell, insert into MemStore. This will atomically upsert the value for that row/family/qualifier. If a Cell 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.
-
timeOfOldestEdit
Returns Oldest timestamp of all the Cells in the MemStore- Specified by:
timeOfOldestEdit
in interfaceMemStore
-
clearSnapshot
This method is protected underHStore#lock
write lock,
and this method is used byHStore#updateStorefiles
after flushing is completed.
The passed snapshot was successfully persisted; it can be let go.- Specified by:
clearSnapshot
in interfaceMemStore
- Parameters:
id
- Id of the snapshot to clean out.- Throws:
UnexpectedStateException
- See Also:
-
doClearSnapShot
-
getSnapshotSize
Description copied from interface:MemStore
Return the size of the snapshot(s) if any- Specified by:
getSnapshotSize
in interfaceMemStore
- Returns:
- size of the memstore snapshot
-
toString
-
getConfiguration
-
dump
-
getLowest
Returns Return lowest of a or b or null if both a and b are null -
maybeCloneWithAllocator
private ExtendedCell maybeCloneWithAllocator(MutableSegment currentActive, ExtendedCell cell, boolean forceCloneOfBigCell) If the segment has a memory allocator the cell is being cloned to this space, and returned; Otherwise the given cell is returned When a cell's size is too big (bigger than maxAlloc), it is not allocated on MSLAB. Since the process of flattening to CellChunkMap assumes that all cells are allocated on MSLAB, during this process, the input parameter forceCloneOfBigCell is set to 'true' and the cell is copied into MSLAB.- Parameters:
cell
- the cell to cloneforceCloneOfBigCell
- true only during the process of flattening to CellChunkMap.- Returns:
- either the given cell or its clone
-
internalAdd
private void internalAdd(MutableSegment currentActive, ExtendedCell toAdd, boolean mslabUsed, MemStoreSizing memstoreSizing) Internal version of add() that doesn't clone Cells with the allocator, and doesn't take the lock. Callers should ensure they already have the read lock taken- Parameters:
toAdd
- the cell to addmslabUsed
- whether using MSLABmemstoreSizing
- object to accumulate changed size
-
sizeAddedPreOperation
-
setOldestEditTimeToNow
-
keySize
Returns The total size of cells in this memstore. We will not consider cells in the snapshot -
heapSize
- Returns:
- The total heap size of cells in this memstore. We will not consider cells in the snapshot
-
getComparator
-
getActive
-
getSnapshot
-
close
Description copied from interface:MemStore
Close the memstore.Usually this should only be called when there is nothing in the memstore, unless we are going to abort ourselves.
For normal cases, this method is only used to fix the reference counting, see HBASE-27941.
-
getSegments
Returns an ordered list of segments from most recent to oldest in memstore- Throws:
IOException
-