public static class Caches.HashTable extends EngineWrapper implements Engine
| Modifier and Type | Class and Description |
|---|---|
private static class |
Caches.HashTable.HashItem |
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 Caches.HashTable.HashItem[] |
items |
protected java.util.concurrent.locks.ReentrantLock[] |
locks |
CLOSEDCATALOG_RECID, CHECK_RECORD, CLASS_INFO_RECID, LAST_RESERVED_RECID| Constructor and Description |
|---|
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.
|
private int |
position(long recid) |
<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, snapshotclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcanRollback, canSnapshot, closeListenerRegister, closeListenerUnregister, commit, compact, getSerializerPojo, isClosed, isReadOnly, preallocate, preallocate, snapshotprotected final java.util.concurrent.locks.ReentrantLock[] locks
protected Caches.HashTable.HashItem[] items
protected final int cacheMaxSize
protected final int cacheMaxSizeMask
protected final long hashSalt
public HashTable(Engine engine, int cacheMaxSize, boolean disableLocks)
public <A> long put(A value,
Serializer<A> serializer)
Engineput in interface Engineput in class EngineWrappervalue - records to be addedserializer - used to convert record into/from binary formpublic <A> A get(long recid,
Serializer<A> serializer)
Engineget in interface Engineget in class EngineWrapperrecid - (record identifier) under which record was persistedserializer - used to deserialize record from binary formprivate int position(long recid)
public <A> void update(long recid,
A value,
Serializer<A> serializer)
Engineupdate in interface Engineupdate in class EngineWrapperrecid - (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)
EngineoldValue==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 EnginecompareAndSwap in class EngineWrapperrecid - (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)
Enginedelete in interface Enginedelete in class EngineWrapperrecid - (record identifier) under which was record persistedserializer - which may be used in some circumstances to deserialize and store old objectpublic void close()
EngineNullPointerException
There is an configuration option DBMaker.closeOnJvmShutdown() which uses shutdown hook to automatically
close Engine when JVM shutdowns.close in interface Engineclose in class EngineWrapperpublic void rollback()
EngineUnsupportedOperationException.rollback in interface Enginerollback in class EngineWrapperpublic void clearCache()
EngineclearCache in interface EngineclearCache in class EngineWrapper