Engine.CloseOnJVMShutdown, Engine.ReadOnly, Engine.ReadOnlyWrapper| Modifier and Type | Field and Description |
|---|---|
protected boolean |
closed |
protected org.mapdb.LongConcurrentHashMap<Fun.Pair> |
mod |
protected org.mapdb.LongConcurrentHashMap |
old |
protected Reference<TxEngine.Tx> |
ref |
CLOSED_ENGINE, RECID_CLASS_CATALOG, RECID_FIRST, RECID_LAST_RESERVED, RECID_NAME_CATALOG, RECID_RECORD_CHECK| Constructor and Description |
|---|
TxEngine.Tx() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canRollback() |
boolean |
canSnapshot() |
void |
clearCache()
clears any underlying cache
|
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.
|
<A> void |
delete(long recid,
Serializer<A> serializer)
Remove existing record from store/cache
|
<A> A |
get(long recid,
Serializer<A> serializer)
Get existing record.
|
Engine |
getWrappedEngine()
if this is wrapper return underlying engine, or null
|
boolean |
isClosed()
Checks whether Engine was closed.
|
boolean |
isReadOnly()
Check if you can write into this Engine.
|
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 org.mapdb.LongConcurrentHashMap old
protected org.mapdb.LongConcurrentHashMap<Fun.Pair> mod
protected final Reference<TxEngine.Tx> ref
protected boolean closed
public long preallocate()
Enginepreallocate in interface Enginepublic <A> long put(A value,
Serializer<A> serializer)
Enginepublic <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'
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.
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.
public 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 boolean isClosed()
Enginepublic void commit()
Enginepublic void rollback()
throws UnsupportedOperationException
EngineUnsupportedOperationException.rollback in interface EngineUnsupportedOperationException - if transactions are disabledpublic boolean isReadOnly()
EngineisReadOnly in interface Enginepublic boolean canRollback()
canRollback in interface Enginepublic boolean canSnapshot()
canSnapshot in interface Enginepublic Engine snapshot() throws UnsupportedOperationException
Enginesnapshot in interface EngineUnsupportedOperationException - if snapshots are not supported/enabledpublic Engine getWrappedEngine()
EnginegetWrappedEngine in interface Enginepublic void clearCache()
EngineclearCache in interface EngineCopyright © 2015. All Rights Reserved.