Modifier and Type | Field and Description |
---|---|
protected boolean |
closed |
protected LongConcurrentHashMap<Fun.Tuple2> |
mod |
protected LongConcurrentHashMap |
old |
protected Reference<TxEngine.Tx> |
ref |
protected Collection<Long> |
usedPreallocatedRecids |
CATALOG_RECID, CHECK_RECORD, CLASS_INFO_RECID, LAST_RESERVED_RECID
Constructor and Description |
---|
Tx() |
Modifier and Type | Method and Description |
---|---|
boolean |
canRollback() |
boolean |
canSnapshot() |
void |
clearCache()
clears any underlying cache
|
void |
close()
Close store/cache.
|
void |
closeListenerRegister(Runnable closeListener) |
void |
closeListenerUnregister(Runnable closeListener) |
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
Recid must be a number returned by 'put' method.
|
<A> A |
get(long recid,
Serializer<A> serializer)
Get existing record.
|
SerializerPojo |
getSerializerPojo()
Returns default serializer associated with this engine.
|
Engine |
getWrappedEngine() |
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.
|
void |
preallocate(long[] recids)
Preallocates recids 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 LongConcurrentHashMap old
protected LongConcurrentHashMap<Fun.Tuple2> mod
protected Collection<Long> usedPreallocatedRecids
protected final Reference<TxEngine.Tx> ref
protected boolean closed
public long preallocate()
Engine
preallocate
in interface Engine
public void preallocate(long[] recids)
Engine
preallocate
in interface Engine
recids
- array to put result intopublic <A> long put(A value, Serializer<A> serializer)
Engine
public <A> A get(long recid, Serializer<A> serializer)
Engine
public <A> void update(long recid, A value, Serializer<A> serializer)
Engine
public <A> boolean compareAndSwap(long recid, A expectedOldValue, A newValue, Serializer<A> serializer)
Engine
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
compareAndSwap
in interface Engine
recid
- (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)
Engine
public void close()
Engine
NullPointerException
There is an configuration option DBMaker.closeOnJvmShutdown()
which uses shutdown hook to automatically
close Engine when JVM shutdowns.public boolean isClosed()
Engine
public void commit()
Engine
public void rollback() throws UnsupportedOperationException
Engine
UnsupportedOperationException
.rollback
in interface Engine
UnsupportedOperationException
- if transactions are disabledpublic boolean isReadOnly()
Engine
isReadOnly
in interface Engine
public boolean canRollback()
canRollback
in interface Engine
public boolean canSnapshot()
canSnapshot
in interface Engine
public Engine snapshot() throws UnsupportedOperationException
Engine
snapshot
in interface Engine
UnsupportedOperationException
- if snapshots are not supported/enabledEngineWrapper.canSnapshot()
public void clearCache()
Engine
clearCache
in interface Engine
public SerializerPojo getSerializerPojo()
Engine
getSerializerPojo
in interface Engine
public void closeListenerRegister(Runnable closeListener)
closeListenerRegister
in interface Engine
public void closeListenerUnregister(Runnable closeListener)
closeListenerUnregister
in interface Engine
public Engine getWrappedEngine()
Copyright © 2016. All rights reserved.