public class GridUnsafePartitionedMap extends Object implements GridOffHeapPartitionedMap
Unsafe
implementation.Constructor and Description |
---|
GridUnsafePartitionedMap(int parts,
int concurrency,
float load,
long initCap,
long totalMem,
short lruStripes,
GridOffHeapEvictListener evictLsnr) |
Modifier and Type | Method and Description |
---|---|
long |
allocatedSize()
Gets size of a memory allocated for map entries so far.
|
int |
concurrency()
Gets concurrency level for this map.
|
boolean |
contains(int part,
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 p,
int hash,
byte[] keyBytes)
Enables eviction for entry.
|
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 p,
int hash,
byte[] keyBytes)
Gets value bytes for given key.
|
void |
insert(int p,
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 the whole map.
|
<T> GridCloseableIterator<T> |
iterator(CX2<T2<Long,Integer>,T2<Long,Integer>,T> c)
Gets iterator over the whole map.
|
<T> GridCloseableIterator<T> |
iterator(CX2<T2<Long,Integer>,T2<Long,Integer>,T> c,
int part)
Gets iterator over the partition.
|
GridCloseableIterator<IgniteBiTuple<byte[],byte[]>> |
iterator(int p)
Gets iterator over certain partition.
|
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 |
partitions()
Gets number of partitions.
|
boolean |
put(int p,
int hash,
byte[] keyBytes,
byte[] valBytes)
Puts key and value bytes into the map potentially replacing
existing entry.
|
byte[] |
remove(int p,
int hash,
byte[] keyBytes)
Removes value from off-heap map.
|
boolean |
removex(int p,
int hash,
byte[] keyBytes)
Removes value from off-heap map without returning it.
|
boolean |
removex(int part,
int hash,
byte[] keyBytes,
IgniteBiPredicate<Long,Integer> p)
Removes value from off-heap map without returning it.
|
long |
size()
Gets number of elements in the map.
|
long |
size(Set<Integer> parts)
Gets number of elements in the map.
|
long |
systemAllocatedSize()
Gets memory allocated for map internal structure so far.
|
IgniteBiTuple<Long,Integer> |
valuePointer(int p,
int hash,
byte[] keyBytes)
Gets value pointer for given key.
|
public GridUnsafePartitionedMap(int parts, int concurrency, float load, long initCap, long totalMem, short lruStripes, @Nullable GridOffHeapEvictListener evictLsnr)
parts
- Partitions.concurrency
- Concurrency.load
- Load factor.initCap
- Initial capacity.totalMem
- Total memory.lruStripes
- LRU stripes.evictLsnr
- Eviction callback.public float loadFactor()
loadFactor
in interface GridOffHeapPartitionedMap
public int concurrency()
concurrency
in interface GridOffHeapPartitionedMap
public int partitions()
partitions
in interface GridOffHeapPartitionedMap
public boolean contains(int part, int hash, byte[] keyBytes)
contains
in interface GridOffHeapPartitionedMap
part
- Partition.hash
- Hash.keyBytes
- Key bytes.True
if key is contained in the map.public byte[] get(int p, int hash, byte[] keyBytes)
get
in interface GridOffHeapPartitionedMap
p
- Partition.hash
- Hash.keyBytes
- Key bytes.public IgniteBiTuple<Long,Integer> valuePointer(int p, int hash, byte[] keyBytes)
GridOffHeapPartitionedMap.put(int, int, byte[], byte[])
or
GridOffHeapPartitionedMap.enableEviction(int, int, byte[])
is called.valuePointer
in interface GridOffHeapPartitionedMap
p
- Partition.hash
- Hash.keyBytes
- Key bytes.public void enableEviction(int p, int hash, byte[] keyBytes)
enableEviction
in interface GridOffHeapPartitionedMap
p
- Partition.hash
- Hash.keyBytes
- Key bytes.public byte[] remove(int p, int hash, byte[] keyBytes)
remove
in interface GridOffHeapPartitionedMap
p
- Partition.hash
- Hash.keyBytes
- Key bytes.public boolean removex(int p, int hash, byte[] keyBytes)
removex
in interface GridOffHeapPartitionedMap
p
- Partition.hash
- Hash.keyBytes
- Key bytes.True
if value was removed.public boolean removex(int part, int hash, byte[] keyBytes, IgniteBiPredicate<Long,Integer> p)
removex
in interface GridOffHeapPartitionedMap
part
- Partition.hash
- Hash.keyBytes
- Key bytes.p
- Value predicate (arguments are value address and value length).True
if value was removed.public boolean put(int p, int hash, byte[] keyBytes, byte[] valBytes)
put
in interface GridOffHeapPartitionedMap
p
- Partition.hash
- Hash.keyBytes
- Key bytes.valBytes
- Value bytes.True
if new entry was created, false
if existing value was updated.public void insert(int p, int hash, byte[] keyBytes, byte[] valBytes)
Use with caution whenever certain that inserting a new value without current mapping.
insert
in interface GridOffHeapPartitionedMap
p
- Partition.hash
- Hash.keyBytes
- Key bytes.valBytes
- Value bytes.public long size()
size
in interface GridOffHeapPartitionedMap
public long size(Set<Integer> parts)
size
in interface GridOffHeapPartitionedMap
parts
- Partitions.public long memorySize()
memorySize
in interface GridOffHeapPartitionedMap
public long allocatedSize()
allocatedSize
in interface GridOffHeapPartitionedMap
public long systemAllocatedSize()
systemAllocatedSize
in interface GridOffHeapPartitionedMap
public long freeSize()
freeSize
in interface GridOffHeapPartitionedMap
public boolean eventListener(GridOffHeapEventListener evtLsnr)
eventListener
in interface GridOffHeapPartitionedMap
evtLsnr
- Listener.True
if event listener was added, false
if
another listener already exists.public boolean evictListener(GridOffHeapEvictListener evictLsnr)
evictListener
in interface GridOffHeapPartitionedMap
evictLsnr
- Evict listener.True
if evict listener was added, false
if
another listener already exists or LRU
is disabled.public void destruct()
destruct
in interface GridOffHeapPartitionedMap
public GridCloseableIterator<IgniteBiTuple<byte[],byte[]>> iterator()
iterator
in interface GridOffHeapPartitionedMap
public <T> GridCloseableIterator<T> iterator(CX2<T2<Long,Integer>,T2<Long,Integer>,T> c)
iterator
in interface GridOffHeapPartitionedMap
c
- Key/value closure.public <T> GridCloseableIterator<T> iterator(CX2<T2<Long,Integer>,T2<Long,Integer>,T> c, int part)
iterator
in interface GridOffHeapPartitionedMap
c
- Key/value closure.part
- Partition.public GridCloseableIterator<IgniteBiTuple<byte[],byte[]>> iterator(int p)
iterator
in interface GridOffHeapPartitionedMap
p
- Partition.public short lruStripes()
public long lruMemorySize()
public long lruSize()
Follow @ApacheIgnite
Ignite Fabric : ver. 2.0.0 Release Date : April 30 2017