public class Hash2<K,V> extends Object
OptimisticLock| Constructor and Description |
|---|
Hash2(org.cache2k.Cache _cache) |
| Modifier and Type | Method and Description |
|---|---|
long |
calcEntryCount()
Count the entries in the hash table, by scanning through the hash table.
|
void |
calcHashCollisionInfo(CollisionInfo inf) |
void |
checkExpand(int _hash)
Checks whether expansion is needed and expand when
insertWithinLock(Entry, int, int) is used. |
void |
clearWhenLocked() |
void |
close()
Close the cache by discarding the entry table.
|
int |
getClearOrCloseCount() |
Entry<K,V>[] |
getEntries()
Entry table for used by the iterator.
|
long |
getEntryCapacity() |
OptimisticLock |
getSegmentLock(int _hash) |
long |
getSegmentMaxFill()
For testing
|
long |
getSize() |
Entry<K,V> |
insertWithinLock(Entry<K,V> e,
int _hash,
int _keyValue)
Insert an entry.
|
protected boolean |
keyObjIsEqual(K key,
Entry e) |
Entry<K,V> |
lookup(K key,
int _hash,
int _keyValue)
Lookup the entry in the hash table and return it.
|
protected int |
modifiedHashCode(int hc) |
boolean |
remove(Entry<K,V> e)
Remove existing entry from the hash.
|
boolean |
removeWithinLock(Entry<K,V> e,
int _hash) |
<T> T |
runTotalLocked(Job<T> j)
Lock all segments and run the job.
|
public Hash2(org.cache2k.Cache _cache)
_cache - Cache reference only needed for the cache name in case of an exceptionpublic long getEntryCapacity()
public long getSegmentMaxFill()
public Entry<K,V> lookup(K key, int _hash, int _keyValue)
public Entry<K,V> insertWithinLock(Entry<K,V> e, int _hash, int _keyValue)
public void checkExpand(int _hash)
insertWithinLock(Entry, int, int) is used.
No lock may be hold when calling this method, since the table must be locked completely using
the proper lock order.
Need for expansion is only checked by comparing whether the associated segment is full. Should be called after insert after giving up the lock.
public OptimisticLock getSegmentLock(int _hash)
public boolean remove(Entry<K,V> e)
protected int modifiedHashCode(int hc)
public long getSize()
public <T> T runTotalLocked(Job<T> j)
public void clearWhenLocked()
public int getClearOrCloseCount()
public void close()
Closing will be visible to other threads, because of the guarantees of the locking. Using the entry table for closing has the advantage that the close check collapses with the implicit null check and has no additional overhead.
public void calcHashCollisionInfo(CollisionInfo inf)
public long calcEntryCount()
cache2k API documentation. Copyright © 2000–2019 headissue GmbH, Munich.