public abstract class Store extends Object implements Engine
| Modifier and Type | Class and Description |
|---|---|
static class |
Store.Cache
Cache implementation, part of
Store class. |
static class |
Store.LongList |
static class |
Store.LongLongMap
Open Hash Map which uses primitive long as values and keys.
|
static class |
Store.LongObjectMap<V>
Open Hash Map which uses primitive long as keys.
|
static class |
Store.LongObjectObjectMap<V1,V2>
Open Hash Map which uses primitive long as keys.
|
static class |
Store.LongQueue
Queue of primitive long.
|
static class |
Store.MemoryBarrierLessLock
Lock which blocks parallel execution, but does not use MemoryBarrier (and does not flush CPU cache)
|
static class |
Store.ReadWriteSingleLock
fake read/write lock which in fact locks on single write lock
|
Engine.CloseOnJVMShutdown, Engine.ReadOnly, Engine.ReadOnlyWrapper| Modifier and Type | Field and Description |
|---|---|
protected Store.Cache[] |
caches |
protected boolean |
checksum |
protected boolean |
closed |
protected ReentrantLock |
commitLock
protects lifecycle methods such as commit, rollback and close()
|
protected boolean |
compress |
protected boolean |
deserializeExtra |
protected boolean |
encrypt |
protected EncryptionXTEA |
encryptionXTEA |
protected static long |
FEAT_COMP_LZF |
protected static long |
FEAT_CRC |
protected static long |
FEAT_ENC_XTEA |
protected boolean |
fileLockDisable |
protected DataIO.HeartbeatFileLock |
fileLockHeartbeat |
protected String |
fileName |
protected static long |
HEAD_CHECKSUM |
protected static long |
HEAD_FEATURES |
static int |
LOCKING_STRATEGY_NOLOCK |
static int |
LOCKING_STRATEGY_READWRITELOCK |
static int |
LOCKING_STRATEGY_WRITELOCK |
protected int |
lockMask |
protected ReadWriteLock[] |
locks
protects data from being overwritten while read
|
protected int |
lockScale |
protected static Logger |
LOG |
protected ThreadLocal<CompressLZF> |
LZF |
protected AtomicLong |
metricsDataRead |
protected AtomicLong |
metricsDataWrite |
protected AtomicLong |
metricsRecordRead |
protected AtomicLong |
metricsRecordWrite |
static Lock |
NOLOCK
fake lock
|
protected boolean |
readonly |
protected AtomicReference<DataIO.DataOutputByteArray> |
recycledDataOut |
protected boolean |
snapshotEnable |
protected ReentrantLock |
structuralLock
protects structural layout of records.
|
protected Volume.VolumeFactory |
volumeFactory |
CLOSED_ENGINE, RECID_CLASS_CATALOG, RECID_FIRST, RECID_LAST_RESERVED, RECID_NAME_CATALOG, RECID_RECORD_CHECK| Modifier | Constructor and Description |
|---|---|
protected |
Store(String fileName,
Volume.VolumeFactory volumeFactory,
Store.Cache cache,
int lockScale,
int lockingStrategy,
boolean checksum,
boolean compress,
byte[] password,
boolean readonly,
boolean snapshotEnable,
boolean fileLockDisable,
DataIO.HeartbeatFileLock fileLockHeartbeat) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
assertReadLocked(long recid) |
protected void |
assertWriteLocked(int segment) |
abstract void |
backup(OutputStream out,
boolean incremental) |
abstract void |
backupRestore(InputStream[] in) |
boolean |
canSnapshot() |
protected void |
checkFeaturesBitmap(long feat) |
void |
clearCache()
clears any underlying cache
|
<A> boolean |
compareAndSwap(long recid,
A expectedOldValue,
A newValue,
Serializer<A> serializer)
Updates existing record in atomic (Compare And Swap) manner.
|
<A> void |
delete(long recid,
Serializer<A> serializer)
Remove existing record from store/cache
|
protected abstract <A> void |
delete2(long recid,
Serializer<A> serializer) |
protected <A> A |
deserialize(Serializer<A> serializer,
int size,
DataInput input) |
abstract boolean |
fileLoad()
If underlying storage is memory-mapped-file, this method will try to
load and precache all file data into disk cache.
|
static Store |
forDB(DB db)
traverses Engine wrappers and returns underlying
Store |
static Store |
forEngine(Engine e)
traverses Engine wrappers and returns underlying
Store |
<A> A |
get(long recid,
Serializer<A> serializer)
Get existing record.
|
protected abstract <A> A |
get2(long recid,
Serializer<A> serializer) |
abstract long |
getCurrSize() |
abstract long |
getFreeSize() |
Engine |
getWrappedEngine()
if this is wrapper return underlying engine, or null
|
void |
init() |
boolean |
isClosed()
Checks whether Engine was closed.
|
boolean |
isReadOnly()
Check if you can write into this Engine.
|
protected int |
lockPos(long recid) |
protected long |
longParityGet(long value) |
protected long |
longParitySet(long value) |
protected long |
makeFeaturesBitmap() |
void |
metricsCollect(Map<String,Long> map)
puts metrics into given map
|
protected DataIO.DataOutputByteArray |
newDataOut2() |
protected <A> DataIO.DataOutputByteArray |
serialize(A value,
Serializer<A> serializer) |
<A> void |
update(long recid,
A value,
Serializer<A> serializer)
Update existing record with new value.
|
protected abstract void |
update2(long recid,
DataIO.DataOutputByteArray out) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcanRollback, close, commit, compact, preallocate, put, rollback, snapshotprotected static final Logger LOG
protected static final long FEAT_COMP_LZF
protected static final long FEAT_ENC_XTEA
protected static final long FEAT_CRC
protected static final long HEAD_CHECKSUM
protected static final long HEAD_FEATURES
protected final ReentrantLock structuralLock
protected final ReentrantLock commitLock
protected final ReadWriteLock[] locks
protected final int lockScale
protected final int lockMask
protected volatile boolean closed
protected final boolean readonly
protected final String fileName
protected final Volume.VolumeFactory volumeFactory
protected final boolean checksum
protected final boolean compress
protected final boolean encrypt
protected final EncryptionXTEA encryptionXTEA
protected final ThreadLocal<CompressLZF> LZF
protected final boolean snapshotEnable
protected final boolean fileLockDisable
protected final AtomicLong metricsDataWrite
protected final AtomicLong metricsRecordWrite
protected final AtomicLong metricsDataRead
protected final AtomicLong metricsRecordRead
protected final boolean deserializeExtra
protected DataIO.HeartbeatFileLock fileLockHeartbeat
protected final Store.Cache[] caches
public static final int LOCKING_STRATEGY_READWRITELOCK
public static final int LOCKING_STRATEGY_WRITELOCK
public static final int LOCKING_STRATEGY_NOLOCK
protected final AtomicReference<DataIO.DataOutputByteArray> recycledDataOut
public static final Lock NOLOCK
protected Store(String fileName, Volume.VolumeFactory volumeFactory, Store.Cache cache, int lockScale, int lockingStrategy, boolean checksum, boolean compress, byte[] password, boolean readonly, boolean snapshotEnable, boolean fileLockDisable, DataIO.HeartbeatFileLock fileLockHeartbeat)
public void init()
protected void checkFeaturesBitmap(long feat)
protected long makeFeaturesBitmap()
public <A> A get(long recid,
Serializer<A> serializer)
EngineGet existing record.
Recid must be a number returned by 'put' method. Behaviour for invalid recid (random number or already deleted record) is not defined, typically it returns null or throws 'EndOfFileException'
protected abstract <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 <A> DataIO.DataOutputByteArray serialize(A value, Serializer<A> serializer)
protected DataIO.DataOutputByteArray newDataOut2()
protected <A> A deserialize(Serializer<A> serializer, int size, DataInput input)
protected abstract void update2(long recid,
DataIO.DataOutputByteArray out)
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 Enginerecid - (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 formpublic <A> void delete(long recid,
Serializer<A> serializer)
EngineRemove existing record from store/cache
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 abstract <A> void delete2(long recid,
Serializer<A> serializer)
protected final int lockPos(long recid)
protected void assertReadLocked(long recid)
protected void assertWriteLocked(int segment)
public boolean isClosed()
Enginepublic boolean isReadOnly()
EngineisReadOnly in interface Enginepublic static Store forEngine(Engine e)
Storepublic abstract long getCurrSize()
public abstract long getFreeSize()
public abstract boolean fileLoad()
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 clearCache()
EngineclearCache in interface Enginepublic abstract void backup(OutputStream out, boolean incremental)
public abstract void backupRestore(InputStream[] in)
public Engine getWrappedEngine()
EnginegetWrappedEngine in interface Enginepublic boolean canSnapshot()
canSnapshot in interface Engineprotected final long longParitySet(long value)
protected final long longParityGet(long value)
Copyright © 2015. All Rights Reserved.