@InterfaceAudience.Private public class CompactionPipeline extends Object
CompactingMemStore
, is a FIFO queue of segments.
It supports pushing a segment at the head of the pipeline and removing a segment from the
tail when it is flushed to disk.
It also supports swap method to allow the in-memory compaction swap a subset of the segments
at the tail of the pipeline with a new (compacted) one. This swap succeeds only if the version
number passed with the list of segments to swap is the same as the current version of the
pipeline.
Essentially, there are two methods which can change the structure of the pipeline: pushHead()
and swap(), the later is used both by a flush to disk and by an in-memory compaction.
The pipeline version is updated by swap(); it allows to identify conflicting operations at the
suffix of the pipeline.
The synchronization model is copy-on-write. Methods which change the structure of the
pipeline (pushHead() and swap()) apply their changes in the context of a lock. They also make
a read-only copy of the pipeline's list. Read methods read from a read-only copy. If a read
method accesses the read-only copy more than once it makes a local copy of it
to ensure it accesses the same copy.
The methods getVersionedList(), getVersionedTail(), and flattenOneSegment() are also
protected by a lock since they need to have a consistent (atomic) view of the pipeline list
and version number.Modifier and Type | Field and Description |
---|---|
static long |
DEEP_OVERHEAD |
static long |
FIXED_OVERHEAD |
Constructor and Description |
---|
CompactionPipeline(RegionServicesForStores region) |
Modifier and Type | Method and Description |
---|---|
boolean |
flattenOneSegment(long requesterVersion,
CompactingMemStore.IndexType idxType,
MemStoreCompactionStrategy.Action action)
If the caller holds the current version, go over the the pipeline and try to flatten each
segment.
|
long |
getMinSequenceId() |
MemStoreSize |
getPipelineSize() |
List<? extends Segment> |
getSegments() |
Segment |
getTail() |
MemStoreSize |
getTailSize() |
VersionedSegmentsList |
getVersionedList() |
VersionedSegmentsList |
getVersionedTail() |
boolean |
isEmpty() |
boolean |
pushHead(MutableSegment segment) |
long |
size() |
boolean |
swap(VersionedSegmentsList versionedList,
ImmutableSegment segment,
boolean closeSuffix,
boolean updateRegionSize)
Swaps the versioned list at the tail of the pipeline with a new segment.
|
public static final long FIXED_OVERHEAD
public static final long DEEP_OVERHEAD
public CompactionPipeline(RegionServicesForStores region)
public boolean pushHead(MutableSegment segment)
public VersionedSegmentsList getVersionedList()
public VersionedSegmentsList getVersionedTail()
public boolean swap(VersionedSegmentsList versionedList, ImmutableSegment segment, boolean closeSuffix, boolean updateRegionSize)
versionedList
- suffix of the pipeline to be replaced can be tail or all the pipelinesegment
- new segment to replace the suffix. Can be null if the suffix just needs to be
removed.closeSuffix
- whether to close the suffix (to release memory), as part of swapping it out
During index merge op this will be false and for compaction it will be true.updateRegionSize
- whether to update the region size. Update the region size,
when the pipeline is swapped as part of in-memory-flush and
further merge/compaction. Don't update the region size when the
swap is result of the snapshot (flush-to-disk).public boolean flattenOneSegment(long requesterVersion, CompactingMemStore.IndexType idxType, MemStoreCompactionStrategy.Action action)
public boolean isEmpty()
public long size()
public long getMinSequenceId()
public MemStoreSize getTailSize()
public MemStoreSize getPipelineSize()
public Segment getTail()
Copyright © 2007–2019 Cloudera. All rights reserved.