Class Segment
java.lang.Object
org.apache.hadoop.hbase.regionserver.Segment
- All Implemented Interfaces:
MemStoreSizing
- Direct Known Subclasses:
ImmutableSegment
,MutableSegment
This is an abstraction of a segment maintained in a memstore, e.g., the active cell set or its
snapshot. This abstraction facilitates the management of the compaction pipeline and the shifts
of these segments from active set to snapshot set in the default implementation.
-
Field Summary
Modifier and TypeFieldDescriptionprivate AtomicReference<CellSet>
private final CellComparator
static final long
static final long
private MemStoreLAB
protected final MemStoreSizing
protected long
protected boolean
protected final TimeRangeTracker
private ReentrantReadWriteLock
Fields inherited from interface org.apache.hadoop.hbase.regionserver.MemStoreSizing
DUD
-
Constructor Summary
ModifierConstructorDescriptionprotected
Segment
(CellComparator comparator, List<ImmutableSegment> segments, TimeRangeTracker trt) protected
Segment
(CellComparator comparator, TimeRangeTracker trt) protected
Segment
(CellSet cellSet, CellComparator comparator, MemStoreLAB memStoreLAB, TimeRangeTracker trt) protected
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closing a segment before it is being discardedint
boolean
compareAndSetDataSize
(long expected, long updated) int
compareRows
(Cell left, Cell right) void
(package private) void
dump
(org.slf4j.Logger log) Dumps all cells of the segment into the given log(package private) static int
getCellLength
(Cell cell) Get cell length after serialized inKeyValue
int
protected CellSet
Returns a set of all cells in the segmentprotected CellComparator
Returns the Cell comparator used by this segmentlong
long
(package private) MemStoreLAB
long
long
protected KeyValueScanner
getScanner
(long readPoint) Creates the scanner for the given read pointgetScanners
(long readPoint) private ReentrantReadWriteLock
protected long
heapSizeChange
(Cell cell, boolean allocated) long
incMemStoreSize
(long delta, long heapOverhead, long offHeapOverhead, int cellsCount) Returns The new dataSize ONLY as a conveniencevoid
protected long
indexEntryOffHeapSize
(boolean offHeap) protected long
indexEntryOnHeapSize
(boolean onHeap) protected abstract long
protected void
internalAdd
(Cell cell, boolean mslabUsed, MemStoreSizing memstoreSizing, boolean sizeAddedPreOperation) boolean
isEmpty()
Returns whether the segment has any cellsboolean
iterator()
last()
maybeCloneWithAllocator
(Cell 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 long
offHeapSizeChange
(Cell cell, boolean allocated) protected Segment
setCellSet
(CellSet cellSetOld, CellSet cellSetNew) Setting the CellSet of the segment - used only for flat immutable segment for setting immutable CellSet after its creation in immutable segment constructorboolean
void
boolean
shouldSeek
(TimeRange tr, long oldestUnexpiredTS) Returns a subset of the segment cell set, which starts with the given celltoString()
protected void
updateMetaInfo
(Cell cellToAdd, boolean succ, boolean mslabUsed, MemStoreSizing memstoreSizing, boolean sizeAddedPreOperation) protected void
updateMetaInfo
(Cell cellToAdd, boolean succ, MemStoreSizing memstoreSizing) void
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.MemStoreSizing
decMemStoreSize, decMemStoreSize, incMemStoreSize
-
Field Details
-
FIXED_OVERHEAD
-
DEEP_OVERHEAD
-
cellSet
-
comparator
-
updatesLock
-
minSequenceId
-
memStoreLAB
-
memStoreSizing
-
timeRangeTracker
-
tagsPresent
-
-
Constructor Details
-
Segment
-
Segment
-
Segment
protected Segment(CellSet cellSet, CellComparator comparator, MemStoreLAB memStoreLAB, TimeRangeTracker trt) -
Segment
-
-
Method Details
-
getScanner
Creates the scanner for the given read point- Returns:
- a scanner for the given read point
-
getScanners
-
isEmpty
Returns whether the segment has any cells -
close
Closing a segment before it is being discarded -
maybeCloneWithAllocator
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.- Returns:
- either the given cell or its clone
-
getCellLength
Get cell length after serialized inKeyValue
-
shouldSeek
-
isTagsPresent
-
incScannerCount
-
decScannerCount
-
setCellSet
Setting the CellSet of the segment - used only for flat immutable segment for setting immutable CellSet after its creation in immutable segment constructor- Returns:
- this object
-
getMemStoreSize
- Specified by:
getMemStoreSize
in interfaceMemStoreSizing
- Returns:
- Use this datastructure to return all three settings,
MemStoreSizing.getDataSize()
,MemStoreSizing.getHeapSize()
, andMemStoreSizing.getOffHeapSize()
, in the one go.
-
getDataSize
- Specified by:
getDataSize
in interfaceMemStoreSizing
-
getHeapSize
- Specified by:
getHeapSize
in interfaceMemStoreSizing
-
getOffHeapSize
- Specified by:
getOffHeapSize
in interfaceMemStoreSizing
-
getCellsCount
- Specified by:
getCellsCount
in interfaceMemStoreSizing
-
incMemStoreSize
Description copied from interface:MemStoreSizing
Returns The new dataSize ONLY as a convenience- Specified by:
incMemStoreSize
in interfaceMemStoreSizing
-
waitForUpdates
-
compareAndSetDataSize
- Specified by:
compareAndSetDataSize
in interfaceMemStoreSizing
-
getMinSequenceId
-
getTimeRangeTracker
-
last
-
iterator
-
headSet
-
compare
-
compareRows
-
getCellSet
Returns a set of all cells in the segment -
getComparator
Returns the Cell comparator used by this segment- Returns:
- the Cell comparator used by this segment
-
internalAdd
protected void internalAdd(Cell cell, boolean mslabUsed, MemStoreSizing memstoreSizing, boolean sizeAddedPreOperation) -
updateMetaInfo
protected void updateMetaInfo(Cell cellToAdd, boolean succ, boolean mslabUsed, MemStoreSizing memstoreSizing, boolean sizeAddedPreOperation) -
updateMetaInfo
-
heapSizeChange
- Returns:
- The increase in heap size because of this cell addition. This includes this cell POJO's heap size itself and additional overhead because of addition on to CSLM.
-
offHeapSizeChange
-
indexEntryOnHeapSize
-
indexEntryOffHeapSize
-
indexEntrySize
-
tailSet
Returns a subset of the segment cell set, which starts with the given cell- Parameters:
firstCell
- a cell in the segment- Returns:
- a subset of the segment cell set, which starts with the given cell
-
getMemStoreLAB
-
dump
Dumps all cells of the segment into the given log -
toString
-
getUpdatesLock
-