public static class Caches.HashTable extends EngineWrapper implements Engine
EngineWrapper.CloseOnJVMShutdown, EngineWrapper.ImmutabilityCheckEngine, EngineWrapper.ReadOnlyEngine, EngineWrapper.SerializerCheckEngineWrapper, EngineWrapper.SynchronizedEngineWrapper
Modifier and Type | Field and Description |
---|---|
protected int |
cacheMaxSize |
protected int |
cacheMaxSizeMask |
protected long |
hashSalt
Salt added to keys before hashing, so it is harder to trigger hash collision attack.
|
protected org.mapdb.Caches.HashTable.HashItem[] |
items |
protected ReentrantLock[] |
locks |
CLOSED
CATALOG_RECID, CHECK_RECORD, CLASS_INFO_RECID, LAST_RESERVED_RECID
Constructor and Description |
---|
Caches.HashTable(Engine engine,
int cacheMaxSize,
boolean disableLocks) |
Modifier and Type | Method and Description |
---|---|
void |
clearCache()
clears any underlying cache
|
void |
close()
Close store/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
Recid must be a number returned by 'put' method.
|
<A> A |
get(long recid,
Serializer<A> serializer)
Get existing record.
|
<A> long |
put(A value,
Serializer<A> serializer)
Insert new record.
|
void |
rollback()
Undoes all changes made in the current transaction.
|
<A> void |
update(long recid,
A value,
Serializer<A> serializer)
Update existing record with new value.
|
canRollback, canSnapshot, checkClosed, closeListenerRegister, closeListenerUnregister, commit, compact, getSerializerPojo, getWrappedEngine, isClosed, isReadOnly, preallocate, preallocate, snapshot
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canRollback, canSnapshot, closeListenerRegister, closeListenerUnregister, commit, compact, getSerializerPojo, isClosed, isReadOnly, preallocate, preallocate, snapshot
protected final ReentrantLock[] locks
protected org.mapdb.Caches.HashTable.HashItem[] items
protected final int cacheMaxSize
protected final int cacheMaxSizeMask
protected final long hashSalt
public Caches.HashTable(Engine engine, int cacheMaxSize, boolean disableLocks)
public <A> long put(A value, Serializer<A> serializer)
Engine
put
in interface Engine
put
in class EngineWrapper
value
- records to be addedserializer
- used to convert record into/from binary formpublic <A> A get(long recid, Serializer<A> serializer)
Engine
get
in interface Engine
get
in class EngineWrapper
recid
- (record identifier) under which record was persistedserializer
- used to deserialize record from binary formpublic <A> void update(long recid, A value, Serializer<A> serializer)
Engine
update
in interface Engine
update
in class EngineWrapper
recid
- (record identifier) under which record was persisted.value
- new record value to be storedserializer
- used to serialize record into binary formpublic <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
compareAndSwap
in class EngineWrapper
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
delete
in interface Engine
delete
in class EngineWrapper
recid
- (record identifier) under which was record persistedserializer
- which may be used in some circumstances to deserialize and store old objectpublic void close()
Engine
NullPointerException
There is an configuration option DBMaker.closeOnJvmShutdown()
which uses shutdown hook to automatically
close Engine when JVM shutdowns.close
in interface Engine
close
in class EngineWrapper
public void rollback()
Engine
UnsupportedOperationException
.rollback
in interface Engine
rollback
in class EngineWrapper
public void clearCache()
Engine
clearCache
in interface Engine
clearCache
in class EngineWrapper
Copyright © 2014. All Rights Reserved.