@InterfaceAudience.Private public class DefaultMemStore extends Object implements MemStore
Cell
s. When asked to flush, current memstore is moved
to snapshot and is cleared. We continue to serve edits out of new memstore
and backing snapshot until flusher reports in that the flush succeeded. At
this point we let the snapshot go.
The MemStore functions should not be called in parallel. Callers should hold
write and read locks. This is done in HStore
.
Modifier and Type | Class and Description |
---|---|
private static class |
DefaultMemStore.Member |
protected class |
DefaultMemStore.MemStoreScanner |
Modifier and Type | Field and Description |
---|---|
(package private) MemStoreLAB |
allocator |
(package private) CellSkipListSet |
cellSet |
(package private) KeyValue.KVComparator |
comparator |
private org.apache.hadoop.conf.Configuration |
conf |
static long |
DEEP_OVERHEAD |
static long |
FIXED_OVERHEAD |
private static org.apache.commons.logging.Log |
LOG |
(package private) static String |
MSLAB_CLASS_NAME |
(package private) AtomicLong |
size |
(package private) CellSkipListSet |
snapshot |
(package private) MemStoreLAB |
snapshotAllocator |
(package private) long |
snapshotId |
private long |
snapshotSize |
(package private) TimeRangeTracker |
snapshotTimeRangeTracker |
(package private) boolean |
tagsPresent |
(package private) long |
timeOfOldestEdit |
(package private) TimeRangeTracker |
timeRangeTracker |
private static boolean |
USEMSLAB_DEFAULT |
(package private) static String |
USEMSLAB_KEY |
Constructor and Description |
---|
DefaultMemStore()
Default constructor.
|
DefaultMemStore(org.apache.hadoop.conf.Configuration conf,
KeyValue.KVComparator c)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
long |
add(Cell cell)
Write an update
|
private boolean |
addToCellSet(Cell e) |
void |
clearSnapshot(long id)
The passed snapshot was successfully persisted; it can be let go.
|
long |
delete(Cell deleteCell)
Write a delete
|
(package private) void |
dump() |
(package private) int |
getCellLength(Cell cell)
Get cell length after serialized in
KeyValue |
long |
getFlushableSize()
On flush, how much memory we will clear.
|
private Cell |
getLowest(Cell a,
Cell b) |
(package private) Cell |
getNextRow(Cell cell) |
private Cell |
getNextRow(Cell key,
NavigableSet<Cell> set) |
void |
getRowKeyAtOrBefore(GetClosestRowBeforeTracker state)
Find the key that matches row exactly, or the one that immediately precedes it.
|
private void |
getRowKeyAtOrBefore(NavigableSet<Cell> set,
GetClosestRowBeforeTracker state) |
private void |
getRowKeyBefore(NavigableSet<Cell> set,
GetClosestRowBeforeTracker state) |
List<KeyValueScanner> |
getScanners(long readPt) |
long |
getSnapshotSize()
Return the size of the snapshot(s) if any
|
long |
heapSize()
Get the entire heap usage for this MemStore not including keys in the
snapshot.
|
(package private) static long |
heapSizeChange(Cell cell,
boolean notpresent) |
private long |
internalAdd(Cell toAdd,
boolean mslabUsed)
Internal version of add() that doesn't clone Cells with the
allocator, and doesn't take the lock.
|
private long |
keySize() |
static void |
main(String[] args)
Code to help figure if our approximation of object heap sizes is close
enough.
|
private Cell |
maybeCloneWithAllocator(Cell cell) |
private DefaultMemStore.Member |
memberOfPreviousRow(NavigableSet<Cell> set,
GetClosestRowBeforeTracker state,
Cell firstOnRow) |
private boolean |
removeFromCellSet(Cell e) |
void |
rollback(Cell cell)
Remove n key from the memstore.
|
(package private) void |
setOldestEditTimeToNow() |
boolean |
shouldSeek(Scan scan,
Store store,
long oldestUnexpiredTS)
Check if this memstore may contain the required keys
|
long |
size() |
MemStoreSnapshot |
snapshot()
Creates a snapshot of the current memstore.
|
long |
timeOfOldestEdit() |
long |
updateColumnValue(byte[] row,
byte[] family,
byte[] qualifier,
long newValue,
long now)
Only used by tests.
|
private long |
upsert(Cell cell,
long readpoint)
Inserts the specified KeyValue into MemStore and deletes any existing
versions of the same row/family/qualifier as the specified KeyValue.
|
long |
upsert(Iterable<Cell> cells,
long readpoint)
Update or insert the specified KeyValues.
|
private boolean |
walkForwardInSingleRow(SortedSet<Cell> set,
Cell firstOnRow,
GetClosestRowBeforeTracker state) |
private static final org.apache.commons.logging.Log LOG
static final String USEMSLAB_KEY
private static final boolean USEMSLAB_DEFAULT
static final String MSLAB_CLASS_NAME
private org.apache.hadoop.conf.Configuration conf
volatile CellSkipListSet cellSet
volatile CellSkipListSet snapshot
final KeyValue.KVComparator comparator
final AtomicLong size
private volatile long snapshotSize
volatile long timeOfOldestEdit
TimeRangeTracker timeRangeTracker
TimeRangeTracker snapshotTimeRangeTracker
volatile MemStoreLAB allocator
volatile MemStoreLAB snapshotAllocator
volatile long snapshotId
volatile boolean tagsPresent
public static final long FIXED_OVERHEAD
public static final long DEEP_OVERHEAD
public DefaultMemStore()
public DefaultMemStore(org.apache.hadoop.conf.Configuration conf, KeyValue.KVComparator c)
c
- Comparatorvoid dump()
public MemStoreSnapshot snapshot()
clearSnapshot(long)
snapshot
in interface MemStore
MemStoreSnapshot
public void clearSnapshot(long id) throws UnexpectedStateException
clearSnapshot
in interface MemStore
id
- Id of the snapshot to clean out.UnexpectedStateException
snapshot()
public long getFlushableSize()
MemStore
getFlushableSize
in interface MemStore
public long getSnapshotSize()
MemStore
getSnapshotSize
in interface MemStore
public long add(Cell cell)
public long timeOfOldestEdit()
timeOfOldestEdit
in interface MemStore
private boolean addToCellSet(Cell e)
private boolean removeFromCellSet(Cell e)
void setOldestEditTimeToNow()
private long internalAdd(Cell toAdd, boolean mslabUsed)
toAdd
- the cell to addmslabUsed
- whether using MSLABpublic void rollback(Cell cell)
public long delete(Cell deleteCell)
Cell getNextRow(Cell cell)
cell
- Find the row that comes after this one. If null, we return the
first.private Cell getNextRow(Cell key, NavigableSet<Cell> set)
public void getRowKeyAtOrBefore(GetClosestRowBeforeTracker state)
MemStore
getRowKeyAtOrBefore
in interface MemStore
state
- column/delete tracking stateprivate void getRowKeyAtOrBefore(NavigableSet<Cell> set, GetClosestRowBeforeTracker state)
private boolean walkForwardInSingleRow(SortedSet<Cell> set, Cell firstOnRow, GetClosestRowBeforeTracker state)
private void getRowKeyBefore(NavigableSet<Cell> set, GetClosestRowBeforeTracker state)
public long updateColumnValue(byte[] row, byte[] family, byte[] qualifier, long newValue, long now)
updateColumnValue
in interface MemStore
row
- family
- qualifier
- newValue
- now
- public long upsert(Iterable<Cell> cells, long readpoint)
For each KeyValue, insert into MemStore. This will atomically upsert the value for that row/family/qualifier. If a KeyValue 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.
private long upsert(Cell cell, long readpoint)
First, the specified KeyValue is inserted into the Memstore.
If there are any existing KeyValues in this MemStore with the same row, family, and qualifier, they are removed.
Callers must hold the read lock.
cell
- private DefaultMemStore.Member memberOfPreviousRow(NavigableSet<Cell> set, GetClosestRowBeforeTracker state, Cell firstOnRow)
public List<KeyValueScanner> getScanners(long readPt)
getScanners
in interface MemStore
public boolean shouldSeek(Scan scan, Store store, long oldestUnexpiredTS)
scan
- scanstore
- holds reference to cfoldestUnexpiredTS
- static long heapSizeChange(Cell cell, boolean notpresent)
private long keySize()
public long heapSize()
public long size()
public static void main(String[] args)
args
- main argsCopyright © 2007–2019 The Apache Software Foundation. All rights reserved.