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 SummaryFieldsModifier and TypeFieldDescriptionprivate MutableSegmentprivate final CellComparatorprivate final org.apache.hadoop.conf.Configurationstatic final longstatic final longprivate static final longprotected RegionServicesForStoresprotected ImmutableSegmentprotected longprivate long
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedAbstractMemStore(org.apache.hadoop.conf.Configuration conf, CellComparator c, RegionServicesForStores regionServices) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidadd(Iterable<ExtendedCell> cells, MemStoreSizing memstoreSizing) Write the updatesvoidadd(ExtendedCell cell, MemStoreSizing memstoreSizing) Write an updatestatic voidaddToScanners(List<? extends Segment> segments, long readPt, List<KeyValueScanner> scanners) protected static voidaddToScanners(Segment segment, long readPt, List<KeyValueScanner> scanners) voidclearSnapshot(long id) This method is protected underHStore#lockwrite lock,
 and this method is used byHStore#updateStorefilesafter flushing is completed.
 The passed snapshot was successfully persisted; it can be let go.voidclose()Close the memstore.private static ExtendedCelldeepCopyIfNeeded(ExtendedCell cell) protected voiddoAdd(MutableSegment currentActive, ExtendedCell cell, MemStoreSizing memstoreSizing) private voiddoAddOrUpsert(ExtendedCell cell, long readpoint, MemStoreSizing memstoreSizing, boolean doAdd) protected voidprivate voiddoUpsert(MutableSegment currentActive, ExtendedCell cell, long readpoint, MemStoreSizing memstoreSizing) protected voiddump(org.slf4j.Logger log) (package private) MutableSegmentprotected CellComparatorprotected org.apache.hadoop.conf.Configurationprotected ExtendedCellReturns Return lowest of a or b or null if both a and b are nullprotected ExtendedCellgetNextRow(ExtendedCell key, NavigableSet<ExtendedCell> set) Returns an ordered list of segments from most recent to oldest in memstore(package private) ImmutableSegmentReturn the size of the snapshot(s) if anyprotected abstract longheapSize()private voidinternalAdd(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 longkeySize()Returns The total size of cells in this memstore.private ExtendedCellmaybeCloneWithAllocator(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 voidpostUpdate(MutableSegment currentActive) Issue any post update synchronization and testsprotected abstract booleanpreUpdate(MutableSegment currentActive, ExtendedCell cell, MemStoreSizing memstoreSizing) Issue any synchronization and test needed before applying the updateprotected voidprotected voidprivate voidprotected abstract booleanlongReturns Oldest timestamp of all the Cells in the MemStoretoString()abstract voidupdateLowestUnflushedSequenceIdInWAL(boolean onlyIfMoreRecent) Updates the wal with the lowest sequence id (oldest entry) that is still in memoryvoidupsert(Iterable<ExtendedCell> cells, long readpoint, MemStoreSizing memstoreSizing) Update or insert the specified cells.private voidupsert(ExtendedCell cell, long readpoint, MemStoreSizing memstoreSizing) Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.hadoop.hbase.regionserver.MemStoregetFlushableSize, 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- 
AbstractMemStoreprotected AbstractMemStore(org.apache.hadoop.conf.Configuration conf, CellComparator c, RegionServicesForStores regionServices) 
 
- 
- 
Method Details- 
addToScannerspublic static void addToScanners(List<? extends Segment> segments, long readPt, List<KeyValueScanner> scanners) 
- 
addToScanners
- 
resetActive
- 
resetTimeOfOldestEdit
- 
updateLowestUnflushedSequenceIdInWALUpdates 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
 
- 
addDescription copied from interface:MemStoreWrite the updates
- 
addDescription copied from interface:MemStoreWrite an update
- 
upsert
- 
doAddOrUpsertprivate void doAddOrUpsert(ExtendedCell cell, long readpoint, MemStoreSizing memstoreSizing, boolean doAdd) 
- 
doAddprotected void doAdd(MutableSegment currentActive, ExtendedCell cell, MemStoreSizing memstoreSizing) 
- 
doUpsertprivate void doUpsert(MutableSegment currentActive, ExtendedCell cell, long readpoint, MemStoreSizing memstoreSizing) 
- 
preUpdateprotected 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 updated
- cell- the cell to be added
- memstoreSizing- object to accumulate region size changes
- Returns:
- true iff can proceed with applying the update
 
- 
postUpdateIssue any post update synchronization and tests- Parameters:
- currentActive- updated segment
 
- 
deepCopyIfNeeded
- 
upsertDescription copied from interface:MemStoreUpdate 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. 
- 
timeOfOldestEditReturns Oldest timestamp of all the Cells in the MemStore- Specified by:
- timeOfOldestEditin interface- MemStore
 
- 
clearSnapshotThis method is protected underHStore#lockwrite lock,
 and this method is used byHStore#updateStorefilesafter flushing is completed.
 The passed snapshot was successfully persisted; it can be let go.- Specified by:
- clearSnapshotin interface- MemStore
- Parameters:
- id- Id of the snapshot to clean out.
- Throws:
- UnexpectedStateException
- See Also:
 
- 
doClearSnapShot
- 
getSnapshotSizeDescription copied from interface:MemStoreReturn the size of the snapshot(s) if any- Specified by:
- getSnapshotSizein interface- MemStore
- Returns:
- size of the memstore snapshot
 
- 
toString
- 
getConfiguration
- 
dump
- 
getLowestReturns Return lowest of a or b or null if both a and b are null
- 
maybeCloneWithAllocatorprivate 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 clone
- forceCloneOfBigCell- true only during the process of flattening to CellChunkMap.
- Returns:
- either the given cell or its clone
 
- 
internalAddprivate 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 add
- mslabUsed- whether using MSLAB
- memstoreSizing- object to accumulate changed size
 
- 
sizeAddedPreOperation
- 
setOldestEditTimeToNow
- 
keySizeReturns 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
- 
closeDescription copied from interface:MemStoreClose 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. 
- 
getSegmentsReturns an ordered list of segments from most recent to oldest in memstore- Throws:
- IOException
 
 
-