public class StoreHeap extends Store
| Modifier and Type | Class and Description |
|---|---|
static class |
StoreHeap.Snapshot |
Store.Cache, Store.LongList, Store.LongLongMap, Store.LongObjectMap<V>, Store.LongObjectObjectMap<V1,V2>, Store.LongQueue, Store.MemoryBarrierLessLock, Store.ReadWriteSingleLockEngine.CloseOnJVMShutdown, Engine.ReadOnly, Engine.ReadOnlyWrapper| Modifier and Type | Field and Description |
|---|---|
protected Store.LongObjectMap[] |
data |
protected long[] |
freeRecid |
protected int |
freeRecidTail |
protected long |
maxRecid |
protected Lock |
newRecidLock |
protected static Object |
NULL |
protected Store.LongObjectMap[] |
rollback |
protected List<StoreHeap.Snapshot> |
snapshots |
protected static Object |
TOMBSTONE |
caches, checksum, closed, commitLock, compress, deserializeExtra, encrypt, encryptionXTEA, FEAT_COMP_LZF, FEAT_CRC, FEAT_ENC_XTEA, fileLockDisable, fileLockHeartbeat, fileName, HEAD_CHECKSUM, HEAD_FEATURES, LOCKING_STRATEGY_NOLOCK, LOCKING_STRATEGY_READWRITELOCK, LOCKING_STRATEGY_WRITELOCK, lockMask, locks, lockScale, LOG, LZF, metricsDataRead, metricsDataWrite, metricsRecordRead, metricsRecordWrite, NOLOCK, readonly, recycledDataOut, snapshotEnable, structuralLock, volumeFactoryCLOSED_ENGINE, RECID_CLASS_CATALOG, RECID_FIRST, RECID_LAST_RESERVED, RECID_NAME_CATALOG, RECID_RECORD_CHECK| Constructor and Description |
|---|
StoreHeap(boolean txDisabled,
int lockScale,
int lockingStrategy,
boolean snapshotEnable) |
| Modifier and Type | Method and Description |
|---|---|
protected long |
allocateRecid() |
void |
backup(OutputStream out,
boolean incremental) |
void |
backupRestore(InputStream[] in) |
boolean |
canRollback() |
void |
close()
Close store/cache.
|
void |
commit()
Makes all changes made since the previous commit/rollback permanent.
|
void |
compact() |
<A> boolean |
compareAndSwap(long recid,
A expectedOldValue,
A newValue,
Serializer<A> serializer)
Updates existing record in atomic (Compare And Swap) manner.
|
protected <A> void |
delete2(long recid,
Serializer<A> serializer) |
boolean |
fileLoad()
If underlying storage is memory-mapped-file, this method will try to
load and precache all file data into disk cache.
|
protected <A> A |
get2(long recid,
Serializer<A> serializer) |
long |
getCurrSize() |
long |
getFreeSize() |
long |
preallocate()
Preallocates recid for not yet created record.
|
<A> long |
put(A value,
Serializer<A> serializer)
Insert new record.
|
void |
rollback()
Undoes all changes made in the current transaction.
|
Engine |
snapshot()
Returns read-only snapshot of data in Engine.
|
<A> void |
update(long recid,
A value,
Serializer<A> serializer)
Update existing record with new value.
|
protected void |
update2(long recid,
DataIO.DataOutputByteArray out) |
protected void |
updateOld(int pos,
long recid,
Object old) |
assertReadLocked, assertWriteLocked, canSnapshot, checkFeaturesBitmap, clearCache, delete, deserialize, forDB, forEngine, get, getWrappedEngine, init, isClosed, isReadOnly, lockPos, longParityGet, longParitySet, makeFeaturesBitmap, metricsCollect, newDataOut2, serializeprotected final Store.LongObjectMap[] data
protected final Store.LongObjectMap[] rollback
protected static final Object TOMBSTONE
protected static final Object NULL
protected long[] freeRecid
protected int freeRecidTail
protected long maxRecid
protected final Lock newRecidLock
protected List<StoreHeap.Snapshot> snapshots
public StoreHeap(boolean txDisabled,
int lockScale,
int lockingStrategy,
boolean snapshotEnable)
protected <A> A get2(long recid,
Serializer<A> serializer)
public <A> void update(long recid,
A value,
Serializer<A> serializer)
EngineUpdate existing record with new value.
Recid must be a number returned by 'put' method. Behaviour for invalid recid (random number or already deleted record) is not defined, typically it throws 'EndOfFileException', but it may also corrupt store.
protected void update2(long recid,
DataIO.DataOutputByteArray out)
protected <A> void delete2(long recid,
Serializer<A> serializer)
public <A> boolean compareAndSwap(long recid,
A expectedOldValue,
A newValue,
Serializer<A> serializer)
EngineUpdates existing record in atomic (Compare And Swap) manner. Value is modified only if old value matches expected value. There are three ways to match values, MapDB may use any of them:
oldValue==expectedOldValue when old value is found in instance cacheoldValue using serializer and checking oldValue.equals(expectedOldValue)expectedOldValue using serializer and comparing binary array with already serialized oldValue
Recid must be a number returned by 'put' method. Behaviour for invalid recid (random number or already deleted record) is not defined, typically it throws 'EndOfFileException', but it may also corrupt store.
compareAndSwap in interface EnginecompareAndSwap in class Storerecid - (record identifier) under which record was persisted.expectedOldValue - old value to be compared with existing recordnewValue - to be written if values are matchingserializer - used to serialize record into binary formprotected void updateOld(int pos,
long recid,
Object old)
public long getCurrSize()
getCurrSize in class Storepublic long getFreeSize()
getFreeSize in class Storepublic boolean fileLoad()
Store
If underlying storage is memory-mapped-file, this method will try to
load and precache all file data into disk cache.
Most likely it will call MappedByteBuffer.load(),
but could also read content of entire file etc
This method will not pin data into memory, they might be removed at any time.
public void backup(OutputStream out, boolean incremental)
public void backupRestore(InputStream[] in)
backupRestore in class Storepublic long preallocate()
Engineprotected long allocateRecid()
public <A> long put(A value,
Serializer<A> serializer)
Enginevalue - records to be addedserializer - used to convert record into/from binary formpublic void close()
EngineClose store/cache. This method must be called before JVM exits to flush all caches and prevent store corruption. Also it releases resources used by MapDB (disk, memory..).
Engine can no longer be used after this method was called. If Engine is used after closing, it may
throw any exception including NullPointerException
There is an configuration option DBMaker.Maker.closeOnJvmShutdown() which uses shutdown hook to automatically
close Engine when JVM shutdowns.
public void commit()
Enginepublic void rollback()
throws UnsupportedOperationException
EngineUnsupportedOperationException.UnsupportedOperationException - if transactions are disabledpublic boolean canRollback()
public Engine snapshot() throws UnsupportedOperationException
EngineUnsupportedOperationException - if snapshots are not supported/enabledpublic void compact()
Copyright © 2015. All Rights Reserved.