public class GridUnsafeMap<K> extends Object implements GridOffHeapMap<K>
Unsafe implementation.| Constructor and Description |
|---|
GridUnsafeMap(int concurrency,
float load,
long initCap,
long totalMem,
short lruStripes,
GridOffHeapEvictListener evictLsnr) |
| Modifier and Type | Method and Description |
|---|---|
long |
allocatedSize()
Gets memory allocated for map entries so far.
|
int |
concurrency()
Gets concurrency level for this map.
|
boolean |
contains(int hash,
byte[] keyBytes)
Checks if given key is contained in the map.
|
void |
destruct()
Destructs this map and deallocates all memory.
|
void |
enableEviction(int hash,
byte[] keyBytes)
Enables eviction for given key.
|
boolean |
eventListener(GridOffHeapEventListener evtLsnr)
Adds off-heap event listener.
|
boolean |
evictListener(GridOffHeapEvictListener evictLsnr)
Sets callback for when entries are evicted due to memory constraints.
|
long |
freeSize()
Gets available memory.
|
byte[] |
get(int hash,
byte[] keyBytes)
Gets value bytes for given key.
|
void |
insert(int hash,
byte[] keyBytes,
byte[] valBytes)
Inserts new entry into the map without comparing if there is
a mapping for given key already stored in map.
|
GridCloseableIterator<IgniteBiTuple<byte[],byte[]>> |
iterator()
Gets iterator over map.
|
<T> GridCloseableIterator<T> |
iterator(CX2<T2<Long,Integer>,T2<Long,Integer>,T> c)
Gets iterator over map.
|
float |
loadFactor()
Gets load factor of this map.
|
long |
lruMemorySize()
Gets memory size occupied by LRU queue.
|
long |
lruSize()
Gets number of elements in LRU queue.
|
short |
lruStripes()
Gets number of LRU stripes.
|
long |
memorySize()
Gets total available memory size.
|
int |
partition()
Gets partition this map belongs to.
|
boolean |
put(int hash,
byte[] keyBytes,
byte[] valBytes)
Puts key and value bytes into the map potentially replacing
existing entry.
|
byte[] |
remove(int hash,
byte[] keyBytes)
Removes value from off-heap map.
|
boolean |
removex(int hash,
byte[] keyBytes)
Removes value from off-heap map without returning it.
|
long |
size()
Gets number of elements in the map.
|
long |
systemAllocatedSize()
Gets memory allocated for map internal structure so far.
|
long |
totalSize()
Gets number of elements in the map.
|
IgniteBiTuple<Long,Integer> |
valuePointer(int hash,
byte[] keyBytes)
Gets value pointer for given key.
|
public GridUnsafeMap(int concurrency,
float load,
long initCap,
long totalMem,
short lruStripes,
@Nullable
GridOffHeapEvictListener evictLsnr)
concurrency - Concurrency.load - Load factor.initCap - Initial capacity.totalMem - Total memory.lruStripes - Number of LRU stripes.evictLsnr - Eviction listener.public boolean eventListener(GridOffHeapEventListener evtLsnr)
eventListener in interface GridOffHeapMap<K>evtLsnr - Listener.True if event listener was added, false if
another listener already exists.public boolean evictListener(GridOffHeapEvictListener evictLsnr)
evictListener in interface GridOffHeapMap<K>evictLsnr - Evict listener.True if evict listener was added, false if
another listener already exists or LRU is disabled.public int partition()
partition in interface GridOffHeapMap<K>public float loadFactor()
loadFactor in interface GridOffHeapMap<K>public int concurrency()
concurrency in interface GridOffHeapMap<K>public boolean contains(int hash,
byte[] keyBytes)
contains in interface GridOffHeapMap<K>hash - Hash.keyBytes - Key bytes.True if key is contained in the map.public byte[] get(int hash,
byte[] keyBytes)
get in interface GridOffHeapMap<K>hash - Hash.keyBytes - Key bytes.@Nullable public IgniteBiTuple<Long,Integer> valuePointer(int hash, byte[] keyBytes)
valuePointer in interface GridOffHeapMap<K>hash - Hash.keyBytes - Key bytes.public void enableEviction(int hash,
byte[] keyBytes)
enableEviction in interface GridOffHeapMap<K>hash - Hash.keyBytes - Key bytes.public byte[] remove(int hash,
byte[] keyBytes)
remove in interface GridOffHeapMap<K>hash - Hash.keyBytes - Key bytes.public boolean removex(int hash,
byte[] keyBytes)
removex in interface GridOffHeapMap<K>hash - Hash.keyBytes - Key bytes.True if value was removed.public boolean put(int hash,
byte[] keyBytes,
byte[] valBytes)
put in interface GridOffHeapMap<K>hash - Hash.keyBytes - Key bytes.valBytes - Value bytes.True if new entry was created, false if existing value was updated.public void insert(int hash,
byte[] keyBytes,
byte[] valBytes)
Use with caution whenever certain that inserting a new value without current mapping.
insert in interface GridOffHeapMap<K>hash - Hash.keyBytes - Key bytes.valBytes - Value bytes.public long totalSize()
totalSize in interface GridOffHeapMap<K>public long size()
size in interface GridOffHeapMap<K>public long memorySize()
memorySize in interface GridOffHeapMap<K>public long allocatedSize()
allocatedSize in interface GridOffHeapMap<K>public long systemAllocatedSize()
systemAllocatedSize in interface GridOffHeapMap<K>public long freeSize()
freeSize in interface GridOffHeapMap<K>public void destruct()
destruct in interface GridOffHeapMap<K>public GridCloseableIterator<IgniteBiTuple<byte[],byte[]>> iterator()
iterator in interface GridOffHeapMap<K>public <T> GridCloseableIterator<T> iterator(CX2<T2<Long,Integer>,T2<Long,Integer>,T> c)
iterator in interface GridOffHeapMap<K>c - Key/value closure.public short lruStripes()
public long lruMemorySize()
public long lruSize()
Follow @ApacheIgnite
Ignite Fabric : ver. 1.2.0-incubating Release Date : June 16 2015