public class HTreeMap<K,V> extends java.util.AbstractMap<K,V> implements java.util.concurrent.ConcurrentMap<K,V>, Bind.MapWithModificationListener<K,V>
ConcurrentHashMap| Modifier and Type | Class and Description |
|---|---|
(package private) class |
HTreeMap.Entry2 |
(package private) class |
HTreeMap.EntryIterator |
protected static class |
HTreeMap.ExpireLinkNode |
protected static class |
HTreeMap.ExpireRunnable |
(package private) class |
HTreeMap.HashIterator |
(package private) class |
HTreeMap.KeyIterator |
class |
HTreeMap.KeySet |
protected static class |
HTreeMap.LinkedNode<K,V>
node which holds key-value pair
|
(package private) class |
HTreeMap.ValueIterator |
| Modifier and Type | Field and Description |
|---|---|
private java.util.Set<java.util.Map.Entry<K,V>> |
_entrySet |
private java.util.Set<K> |
_keySet |
private java.util.Collection<V> |
_values |
protected static int |
BUCKET_OVERFLOW |
protected java.util.concurrent.CountDownLatch |
closeLatch |
protected java.lang.Runnable |
closeListener |
protected Atomic.Long |
counter |
protected static Serializer<long[][]> |
DIR_SERIALIZER |
protected static int |
DIV8 |
protected Engine |
engine |
protected long |
expire |
protected long |
expireAccess |
protected boolean |
expireAccessFlag |
protected boolean |
expireFlag |
protected long[] |
expireHeads |
protected long |
expireMaxSize |
protected boolean |
expireMaxSizeFlag |
protected long |
expireStoreSize |
protected long[] |
expireTails |
protected long |
expireTimeStart |
protected Hasher<K> |
hasher |
protected int |
hashSalt
Salt added to hash before rehashing, so it is harder to trigger hash collision attack.
|
protected boolean |
hasValues
is this a Map or Set? if false, entries do not have values, only keys are allowed
|
protected Serializer<K> |
keySerializer |
protected Serializer<HTreeMap.LinkedNode<K,V>> |
LN_SERIALIZER |
protected static int |
MOD8 |
protected Bind.MapListener<K,V>[] |
modListeners |
protected java.lang.Object |
modListenersLock |
protected java.util.concurrent.locks.ReentrantReadWriteLock[] |
segmentLocks |
protected long[] |
segmentRecids
list of segments, this is immutable
|
protected Fun.Function1<V,K> |
valueCreator |
protected Serializer<V> |
valueSerializer |
| Constructor and Description |
|---|
HTreeMap(Engine engine,
long counterRecid,
int hashSalt,
long[] segmentRecids,
Serializer<K> keySerializer,
Serializer<V> valueSerializer,
long expireTimeStart,
long expire,
long expireAccess,
long expireMaxSize,
long expireStoreSize,
long[] expireHeads,
long[] expireTails,
Fun.Function1<V,K> valueCreator,
Hasher hasher,
boolean disableLocks)
Opens HTreeMap
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
void |
close()
Closes underlying storage and releases all resources.
|
boolean |
containsKey(java.lang.Object o) |
boolean |
containsValue(java.lang.Object value) |
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet() |
protected void |
expireCheckSegment(int segment) |
protected void |
expireLinkAdd(int segment,
long expireNodeRecid,
long keyRecid,
int hash) |
protected void |
expireLinkBump(int segment,
long nodeRecid,
boolean access) |
protected HTreeMap.ExpireLinkNode |
expireLinkRemove(int segment,
long nodeRecid) |
protected HTreeMap.ExpireLinkNode |
expireLinkRemoveLast(int segment) |
protected void |
expirePurge() |
protected void |
expirePurgeSegment(int seg,
long removePerSegment) |
V |
get(java.lang.Object o) |
Engine |
getEngine() |
protected HTreeMap.LinkedNode<K,V> |
getInner(java.lang.Object o,
int h,
int segment) |
long |
getMaxExpireTime()
Returns maximal (newest) expiration timestamp
|
long |
getMinExpireTime()
Returns minimal (oldest) expiration timestamp
|
V |
getPeek(java.lang.Object key)
Return given value, without updating cache statistics if `expireAccess()` is true
It also does not use `valueCreator` if value is not found (always returns null if not found)
|
protected int |
hash(java.lang.Object key) |
boolean |
isEmpty() |
java.util.Set<K> |
keySet() |
void |
modificationListenerAdd(Bind.MapListener<K,V> listener)
Add new modification listener notified when Map has been updated
|
void |
modificationListenerRemove(Bind.MapListener<K,V> listener)
Remove registered notification listener
|
protected void |
notify(K key,
V oldValue,
V newValue) |
protected static long[] |
preallocateSegments(Engine engine) |
V |
put(K key,
V value) |
V |
putIfAbsent(K key,
V value) |
private V |
putInner(K key,
V value,
int h,
int segment) |
private void |
recursiveDirClear(long dirRecid) |
private long |
recursiveDirCount(long dirRecid) |
private void |
recursiveDirDelete(int h,
int level,
long[] dirRecids,
long[][] dir,
int slot) |
V |
remove(java.lang.Object key) |
boolean |
remove(java.lang.Object key,
java.lang.Object value) |
protected V |
removeInternal(java.lang.Object key,
int segment,
int h,
boolean removeExpire) |
V |
replace(K key,
V value) |
boolean |
replace(K key,
V oldValue,
V newValue) |
int |
size() |
long |
sizeLong() |
java.util.Map<K,V> |
snapshot()
Make readonly snapshot view of current Map.
|
java.util.Collection<V> |
values() |
finalize, getClass, notify, notifyAll, wait, wait, waitprotected static final int BUCKET_OVERFLOW
protected static final int DIV8
protected static final int MOD8
protected final boolean hasValues
protected final int hashSalt
protected final Atomic.Long counter
protected final Serializer<K> keySerializer
protected final Serializer<V> valueSerializer
protected final Engine engine
protected final boolean expireFlag
protected final long expireTimeStart
protected final long expire
protected final boolean expireAccessFlag
protected final long expireAccess
protected final long expireMaxSize
protected final long expireStoreSize
protected final boolean expireMaxSizeFlag
protected final long[] expireHeads
protected final long[] expireTails
protected final Fun.Function1<V,K> valueCreator
protected final java.util.concurrent.CountDownLatch closeLatch
protected final java.lang.Runnable closeListener
protected final Serializer<HTreeMap.LinkedNode<K,V>> LN_SERIALIZER
protected static final Serializer<long[][]> DIR_SERIALIZER
protected final long[] segmentRecids
protected final java.util.concurrent.locks.ReentrantReadWriteLock[] segmentLocks
private final java.util.Set<K> _keySet
private final java.util.Collection<V> _values
protected final java.lang.Object modListenersLock
protected Bind.MapListener<K,V>[] modListeners
public HTreeMap(Engine engine, long counterRecid, int hashSalt, long[] segmentRecids, Serializer<K> keySerializer, Serializer<V> valueSerializer, long expireTimeStart, long expire, long expireAccess, long expireMaxSize, long expireStoreSize, long[] expireHeads, long[] expireTails, Fun.Function1<V,K> valueCreator, Hasher hasher, boolean disableLocks)
protected static long[] preallocateSegments(Engine engine)
public boolean containsKey(java.lang.Object o)
public int size()
public long sizeLong()
sizeLong in interface Bind.MapWithModificationListener<K,V>private long recursiveDirCount(long dirRecid)
public boolean isEmpty()
public V get(java.lang.Object o)
public V getPeek(java.lang.Object key)
key - key to lookupprotected HTreeMap.LinkedNode<K,V> getInner(java.lang.Object o, int h, int segment)
public V remove(java.lang.Object key)
protected V removeInternal(java.lang.Object key, int segment, int h, boolean removeExpire)
private void recursiveDirDelete(int h,
int level,
long[] dirRecids,
long[][] dir,
int slot)
public void clear()
private void recursiveDirClear(long dirRecid)
public boolean containsValue(java.lang.Object value)
public java.util.Set<K> keySet()
public java.util.Collection<V> values()
protected int hash(java.lang.Object key)
public boolean remove(java.lang.Object key,
java.lang.Object value)
protected void expireLinkAdd(int segment,
long expireNodeRecid,
long keyRecid,
int hash)
protected void expireLinkBump(int segment,
long nodeRecid,
boolean access)
protected HTreeMap.ExpireLinkNode expireLinkRemoveLast(int segment)
protected HTreeMap.ExpireLinkNode expireLinkRemove(int segment, long nodeRecid)
public long getMaxExpireTime()
public long getMinExpireTime()
protected void expirePurge()
protected void expirePurgeSegment(int seg,
long removePerSegment)
protected void expireCheckSegment(int segment)
public java.util.Map<K,V> snapshot()
Maintaining snapshot have some overhead, underlying Engine is closed after Map view is GCed. Please make sure to release reference to this Map view, so snapshot view can be garbage collected.
public void modificationListenerAdd(Bind.MapListener<K,V> listener)
Bind.MapWithModificationListenermodificationListenerAdd in interface Bind.MapWithModificationListener<K,V>listener - callback interface notified when map changespublic void modificationListenerRemove(Bind.MapListener<K,V> listener)
Bind.MapWithModificationListenermodificationListenerRemove in interface Bind.MapWithModificationListener<K,V>listener - callback interface notified when map changespublic void close()
public Engine getEngine()