@InterfaceAudience.Private public class CompactingMemStore extends AbstractMemStore
Modifier and Type | Class and Description |
---|---|
static class |
CompactingMemStore.IndexType
Types of indexes (part of immutable segments) to be used after flattening, compaction, or merge
are applied.
|
private class |
CompactingMemStore.InMemoryCompactionRunnable
The in-memory-flusher thread performs the flush asynchronously.
|
Modifier and Type | Field and Description |
---|---|
protected AtomicBoolean |
allowCompaction |
static String |
COMPACTING_MEMSTORE_TYPE_DEFAULT |
static String |
COMPACTING_MEMSTORE_TYPE_KEY |
protected MemStoreCompactor |
compactor |
private boolean |
compositeSnapshot |
static long |
DEEP_OVERHEAD |
static int |
IN_MEMORY_CONPACTION_POOL_SIZE_DEFAULT |
static String |
IN_MEMORY_CONPACTION_POOL_SIZE_KEY |
private static int |
IN_MEMORY_FLUSH_MULTIPLIER |
static String |
IN_MEMORY_FLUSH_THRESHOLD_FACTOR_KEY |
private CompactingMemStore.IndexType |
indexType |
private AtomicBoolean |
inMemoryCompactionInProgress |
private long |
inmemoryFlushSize |
private boolean |
inWalReplay |
private static org.slf4j.Logger |
LOG |
private CompactionPipeline |
pipeline |
private HStore |
store |
FIXED_OVERHEAD, regionServices, snapshot, snapshotId
Constructor and Description |
---|
CompactingMemStore(org.apache.hadoop.conf.Configuration conf,
CellComparator c,
HStore store,
RegionServicesForStores regionServices,
MemoryCompactionPolicy compactionPolicy) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
checkAndAddToActiveSize(MutableSegment currActive,
Cell cellToAdd,
MemStoreSizing memstoreSizing)
Check whether anything need to be done based on the current active set size.
|
protected List<KeyValueScanner> |
createList(int capacity) |
protected MemStoreCompactor |
createMemStoreCompactor(MemoryCompactionPolicy compactionPolicy) |
void |
debug() |
void |
flattenOneSegment(long requesterVersion,
MemStoreCompactionStrategy.Action action) |
(package private) void |
flushInMemory() |
protected void |
flushInMemory(MutableSegment currActive) |
String |
getFamilyName() |
private byte[] |
getFamilyNameInBytes() |
MemStoreSize |
getFlushableSize()
Flush will first clear out the data in snapshot if any (It will take a second flush invocation
to clear the current Cell set).
|
VersionedSegmentsList |
getImmutableSegments() |
CompactingMemStore.IndexType |
getIndexType() |
(package private) long |
getInmemoryFlushSize() |
private Segment |
getLastSegment() |
(package private) Cell |
getNextRow(Cell cell) |
private ThreadPoolExecutor |
getPool() |
private RegionServicesForStores |
getRegionServices() |
List<KeyValueScanner> |
getScanners(long readPt)
This method is protected under HStore read lock.
|
protected List<Segment> |
getSegments()
Returns an ordered list of segments from most recent to oldest in memstore
|
long |
getSmallestReadPoint() |
HStore |
getStore() |
boolean |
hasImmutableSegments() |
protected long |
heapSize() |
private void |
initInmemoryFlushSize(org.apache.hadoop.conf.Configuration conf) |
(package private) void |
inMemoryCompaction() |
(package private) boolean |
isMemStoreFlushingInMemory() |
boolean |
isSloppy() |
protected long |
keySize()
Returns The total size of cells in this memstore.
|
protected void |
postUpdate(MutableSegment currentActive)
Issue any post update synchronization and tests
|
long |
preFlushSeqIDEstimation()
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 update For compacting memstore
this means checking the update can increase the size without overflow
|
protected void |
pushActiveToPipeline(MutableSegment currActive,
boolean checkEmpty)
NOTE: When
flushInMemory(MutableSegment) calls this method, due to
concurrent writes and because we first add cell size to currActive.getDataSize and then
actually add cell to currActive.cellSet, it is possible that currActive.getDataSize could not
accommodate cellToAdd but currActive.cellSet is still empty if pending writes which not yet add
cells to currActive.cellSet,so for
flushInMemory(MutableSegment) ,checkEmpty parameter is false. |
private void |
pushPipelineToSnapshot() |
private void |
pushTailToSnapshot() |
private void |
pushToSnapshot(List<ImmutableSegment> segments) |
void |
setCompositeSnapshot(boolean useCompositeSnapshot) |
(package private) void |
setIndexType(CompactingMemStore.IndexType type) |
void |
setInMemoryCompactionCompleted() |
protected boolean |
setInMemoryCompactionFlag() |
MemStoreSize |
size() |
protected boolean |
sizeAddedPreOperation() |
MemStoreSnapshot |
snapshot()
Push the current active memstore segment into the pipeline and create a snapshot of the tail of
current compaction pipeline Snapshot must be cleared by call to
AbstractMemStore.clearSnapshot(long) . |
void |
startReplayingFromWAL()
This message intends to inform the MemStore that next coming updates are going to be part of
the replaying edits from WAL
|
private void |
stopCompaction()
The request to cancel the compaction asynchronous task (caused by in-memory flush) The
compaction may still happen if the request was sent too late Non-blocking request
|
void |
stopReplayingFromWAL()
This message intends to inform the MemStore that the replaying edits from WAL are done
|
boolean |
swapCompactedSegments(VersionedSegmentsList versionedList,
ImmutableSegment result,
boolean merge) |
protected boolean |
swapPipelineWithNull(VersionedSegmentsList segments) |
private void |
tryFlushInMemoryAndCompactingAsync(MutableSegment currActive)
Try to flush the currActive in memory and submit the background
CompactingMemStore.InMemoryCompactionRunnable to
RegionServicesForStores.getInMemoryCompactionPool() . |
void |
updateLowestUnflushedSequenceIdInWAL(boolean onlyIfGreater)
Updates the wal with the lowest sequence id (oldest entry) that is still in memory
|
add, add, addToScanners, addToScanners, clearSnapshot, doAdd, doClearSnapShot, dump, getActive, getComparator, getConfiguration, getLowest, getNextRow, getSnapshot, getSnapshotSize, resetActive, resetTimeOfOldestEdit, timeOfOldestEdit, toString, upsert
public static final String COMPACTING_MEMSTORE_TYPE_KEY
public static final String COMPACTING_MEMSTORE_TYPE_DEFAULT
public static final String IN_MEMORY_FLUSH_THRESHOLD_FACTOR_KEY
private static final int IN_MEMORY_FLUSH_MULTIPLIER
public static final String IN_MEMORY_CONPACTION_POOL_SIZE_KEY
public static final int IN_MEMORY_CONPACTION_POOL_SIZE_DEFAULT
private static final org.slf4j.Logger LOG
private CompactionPipeline pipeline
protected MemStoreCompactor compactor
private long inmemoryFlushSize
private final AtomicBoolean inMemoryCompactionInProgress
private boolean inWalReplay
protected final AtomicBoolean allowCompaction
private boolean compositeSnapshot
private CompactingMemStore.IndexType indexType
public static final long DEEP_OVERHEAD
public CompactingMemStore(org.apache.hadoop.conf.Configuration conf, CellComparator c, HStore store, RegionServicesForStores regionServices, MemoryCompactionPolicy compactionPolicy) throws IOException
IOException
protected MemStoreCompactor createMemStoreCompactor(MemoryCompactionPolicy compactionPolicy) throws IllegalArgumentIOException
IllegalArgumentIOException
private void initInmemoryFlushSize(org.apache.hadoop.conf.Configuration conf)
public MemStoreSize size()
public long preFlushSeqIDEstimation()
HConstants.NO_SEQNUM
.public boolean isSloppy()
public MemStoreSnapshot snapshot()
AbstractMemStore.clearSnapshot(long)
.
AbstractMemStore.clearSnapshot(long)
.MemStoreSnapshot
public MemStoreSize getFlushableSize()
MemStore
public void setInMemoryCompactionCompleted()
protected boolean setInMemoryCompactionFlag()
protected long keySize()
AbstractMemStore
keySize
in class AbstractMemStore
protected long heapSize()
heapSize
in class AbstractMemStore
public void updateLowestUnflushedSequenceIdInWAL(boolean onlyIfGreater)
AbstractMemStore
updateLowestUnflushedSequenceIdInWAL
in class AbstractMemStore
onlyIfGreater
- a flag that marks whether to update the sequence id no matter what or
only if it is greater than the previous sequence idpublic void startReplayingFromWAL()
public void stopReplayingFromWAL()
protected boolean preUpdate(MutableSegment currentActive, Cell cell, MemStoreSizing memstoreSizing)
preUpdate
in class AbstractMemStore
currentActive
- the segment to be updatedcell
- the cell to be addedmemstoreSizing
- object to accumulate region size changesprotected void postUpdate(MutableSegment currentActive)
AbstractMemStore
postUpdate
in class AbstractMemStore
currentActive
- updated segmentprotected boolean sizeAddedPreOperation()
sizeAddedPreOperation
in class AbstractMemStore
protected List<Segment> getSegments()
AbstractMemStore
getSegments
in class AbstractMemStore
public void setCompositeSnapshot(boolean useCompositeSnapshot)
public boolean swapCompactedSegments(VersionedSegmentsList versionedList, ImmutableSegment result, boolean merge)
public void flattenOneSegment(long requesterVersion, MemStoreCompactionStrategy.Action action)
requesterVersion
- The caller must hold the VersionedList of the pipeline with version
taken earlier. This version must be passed as a parameter here. The
flattening happens only if versions match.void setIndexType(CompactingMemStore.IndexType type)
public CompactingMemStore.IndexType getIndexType()
public boolean hasImmutableSegments()
public VersionedSegmentsList getImmutableSegments()
public long getSmallestReadPoint()
public String getFamilyName()
public List<KeyValueScanner> getScanners(long readPt) throws IOException
IOException
protected List<KeyValueScanner> createList(int capacity)
protected boolean checkAndAddToActiveSize(MutableSegment currActive, Cell cellToAdd, MemStoreSizing memstoreSizing)
currActive
- intended segment to updatecellToAdd
- cell to be added to the segmentmemstoreSizing
- object to accumulate changed sizeprivate void tryFlushInMemoryAndCompactingAsync(MutableSegment currActive)
CompactingMemStore.InMemoryCompactionRunnable
to
RegionServicesForStores.getInMemoryCompactionPool()
. Just one thread can do the actual
flushing in memory.currActive
- current Active Segment to be flush in memory.void flushInMemory()
protected void flushInMemory(MutableSegment currActive)
void inMemoryCompaction()
private Segment getLastSegment()
private byte[] getFamilyNameInBytes()
private ThreadPoolExecutor getPool()
private void stopCompaction()
protected void pushActiveToPipeline(MutableSegment currActive, boolean checkEmpty)
flushInMemory(MutableSegment)
calls this method, due to
concurrent writes and because we first add cell size to currActive.getDataSize and then
actually add cell to currActive.cellSet, it is possible that currActive.getDataSize could not
accommodate cellToAdd but currActive.cellSet is still empty if pending writes which not yet add
cells to currActive.cellSet,so for
flushInMemory(MutableSegment)
,checkEmpty parameter is false. But if
snapshot()
called this method,because there is no pending
write,checkEmpty parameter could be true. nnprivate void pushTailToSnapshot()
private void pushPipelineToSnapshot()
protected boolean swapPipelineWithNull(VersionedSegmentsList segments)
private void pushToSnapshot(List<ImmutableSegment> segments)
private RegionServicesForStores getRegionServices()
boolean isMemStoreFlushingInMemory()
Cell getNextRow(Cell cell)
cell
- Find the row that comes after this one. If null, we return the first.long getInmemoryFlushSize()
public void debug()
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.