Package one.nio.mem
Class OffheapMap<K,V>
java.lang.Object
one.nio.mem.OffheapMap<K,V>
- All Implemented Interfaces:
OffheapMapMXBean
- Direct Known Subclasses:
OffheapBlobMap,SharedMemoryMap
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassstatic classclassstatic interfacestatic classstatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final longprotected final intprotected longprotected OffheapMap<K,V>.BasicCleanup protected doubleprotected static final intprotected final AtomicIntegerprotected final AtomicLongprotected static final intprotected static final intprotected final RWLock[]protected longprotected static final org.slf4j.Loggerprotected longprotected intprotected static final longprotected longprotected static final intprotected static final intprotected longprotected static final sun.misc.Unsafe -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedOffheapMap(int capacity) protectedOffheapMap(int capacity, long address) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract longallocateEntry(K key, long hashCode, int size) protected longbucketFor(long hashCode) voidclear()final voidclose()protected voidprotected abstract voiddestroyEntry(long entry) intprotected abstract booleanintlongdoubleintgetCount()longlongintlonglongprotected abstract longprotected booleanisExpired(long entry, boolean touch) voiditerate(OffheapMap.Visitor<K, V> visitor) voiditerate(OffheapMap.Visitor<K, V> visitor, int workers) voiditerate(OffheapMap.Visitor<K, V> visitor, int start, int end, int step) voiditerate(OffheapMap.WritableVisitor<K, V> visitor) voiditerate(OffheapMap.WritableVisitor<K, V> visitor, int workers) voiditerate(OffheapMap.WritableVisitor<K, V> visitor, int start, int end, int step) protected KkeyAt(long entry) protected RWLocklockFor(long hashCode) lockRecordForRead(K key) lockRecordForRead(K key, long timeout) lockRecordForWrite(K key, boolean create) lockRecordForWrite(K key, long timeout, boolean create) booleanbooleanputIfAbsent(K key, V value) booleanintremoveExpired(long expirationAge) protected booleanreuseEntry(long entry, int newSize) voidsetCleanupInterval(long cleanupInterval) voidsetCleanupThreshold(double cleanupThreshold) voidsetLockWaitTime(long lockWaitTime) voidsetMaxSamples(int maxSamples) voidsetMinTimeToLive(long minTimeToLive) protected voidsetTimeAt(long entry) protected voidsetTimeAt(long entry, long time) voidsetTimeToLive(long timeToLive) protected abstract voidsetValueAt(long entry, V value) protected booleanshouldCleanup(long entry, long expirationTime) protected abstract intsizeOf(long entry) protected abstract intprotected longtimeAt(long entry) voidprotected abstract VvalueAt(long entry)
-
Field Details
-
log
protected static final org.slf4j.Logger log -
unsafe
protected static final sun.misc.Unsafe unsafe -
byteArrayOffset
protected static final long byteArrayOffset -
MB
protected static final long MB- See Also:
-
CONCURRENCY_LEVEL
protected static final int CONCURRENCY_LEVEL- See Also:
-
HASH_OFFSET
protected static final int HASH_OFFSET- See Also:
-
NEXT_OFFSET
protected static final int NEXT_OFFSET- See Also:
-
TIME_OFFSET
protected static final int TIME_OFFSET- See Also:
-
HEADER_SIZE
protected static final int HEADER_SIZE- See Also:
-
capacity
protected final int capacity -
count
-
expirations
-
locks
-
mapBase
protected long mapBase -
timeToLive
protected long timeToLive -
minTimeToLive
protected long minTimeToLive -
lockWaitTime
protected long lockWaitTime -
cleanupInterval
protected long cleanupInterval -
cleanupThreshold
protected double cleanupThreshold -
maxSamples
protected int maxSamples -
cleanupThread
-
-
Constructor Details
-
OffheapMap
protected OffheapMap(int capacity) -
OffheapMap
protected OffheapMap(int capacity, long address)
-
-
Method Details
-
close
public final void close() -
closeInternal
protected void closeInternal() -
getTimeToLive
public long getTimeToLive()- Specified by:
getTimeToLivein interfaceOffheapMapMXBean
-
setTimeToLive
public void setTimeToLive(long timeToLive) - Specified by:
setTimeToLivein interfaceOffheapMapMXBean
-
getMinTimeToLive
public long getMinTimeToLive()- Specified by:
getMinTimeToLivein interfaceOffheapMapMXBean
-
setMinTimeToLive
public void setMinTimeToLive(long minTimeToLive) - Specified by:
setMinTimeToLivein interfaceOffheapMapMXBean
-
getLockWaitTime
public long getLockWaitTime()- Specified by:
getLockWaitTimein interfaceOffheapMapMXBean
-
setLockWaitTime
public void setLockWaitTime(long lockWaitTime) - Specified by:
setLockWaitTimein interfaceOffheapMapMXBean
-
getCleanupInterval
public long getCleanupInterval()- Specified by:
getCleanupIntervalin interfaceOffheapMapMXBean
-
setCleanupInterval
public void setCleanupInterval(long cleanupInterval) - Specified by:
setCleanupIntervalin interfaceOffheapMapMXBean
-
getCleanupThreshold
public double getCleanupThreshold()- Specified by:
getCleanupThresholdin interfaceOffheapMapMXBean
-
setCleanupThreshold
public void setCleanupThreshold(double cleanupThreshold) - Specified by:
setCleanupThresholdin interfaceOffheapMapMXBean
-
getMaxSamples
public int getMaxSamples()- Specified by:
getMaxSamplesin interfaceOffheapMapMXBean
-
setMaxSamples
public void setMaxSamples(int maxSamples) - Specified by:
setMaxSamplesin interfaceOffheapMapMXBean
-
getCapacity
public int getCapacity()- Specified by:
getCapacityin interfaceOffheapMapMXBean
-
getCount
public int getCount()- Specified by:
getCountin interfaceOffheapMapMXBean
-
getExpirations
public long getExpirations()- Specified by:
getExpirationsin interfaceOffheapMapMXBean
-
get
-
put
- Throws:
OutOfMemoryException
-
putIfAbsent
- Throws:
OutOfMemoryException
-
remove
-
touch
-
lockRecordForRead
- Throws:
TimeoutException
-
lockRecordForRead
-
lockRecordForWrite
public OffheapMap.WritableRecord<K,V> lockRecordForWrite(K key, long timeout, boolean create) throws TimeoutException - Throws:
TimeoutException
-
lockRecordForWrite
-
entriesToClean
public int entriesToClean() -
removeExpired
public int removeExpired(long expirationAge) -
clear
public void clear() -
iterate
-
iterate
-
iterate
-
iterate
-
iterate
-
iterate
-
bucketFor
protected long bucketFor(long hashCode) -
lockFor
-
timeAt
protected long timeAt(long entry) -
setTimeAt
protected void setTimeAt(long entry) -
setTimeAt
protected void setTimeAt(long entry, long time) -
isExpired
protected boolean isExpired(long entry, boolean touch) -
shouldCleanup
protected boolean shouldCleanup(long entry, long expirationTime) -
keyAt
-
reuseEntry
protected boolean reuseEntry(long entry, int newSize) -
hashCode
-
equalsAt
-
valueAt
-
setValueAt
-
allocateEntry
- Throws:
OutOfMemoryException
-
destroyEntry
protected abstract void destroyEntry(long entry) -
sizeOf
protected abstract int sizeOf(long entry) -
sizeOf
-