public abstract class HashSlotArrayBase extends Object implements HashSlotArray
HashSlotArray
, common to all its subtype implementations.Modifier and Type | Class and Description |
---|---|
protected class |
HashSlotArrayBase.Cursor |
protected class |
HashSlotArrayBase.CursorIntKey2 |
protected class |
HashSlotArrayBase.CursorLongKey2 |
Modifier and Type | Field and Description |
---|---|
static int |
CAPACITY_OFFSET |
static int |
EXPAND_THRESHOLD_OFFSET |
static int |
HEADER_SIZE |
protected static int |
KEY_1_OFFSET |
protected static int |
KEY_2_OFFSET |
protected long |
offsetOfUnassignedSentinel
Offset (from the slot's base address) where the unassigned sentinel value is to be found.
|
static int |
SIZE_OFFSET |
protected int |
slotLength
Total length of an array slot in bytes.
|
protected long |
unassignedSentinel
Sentinel value that marks a slot as "unassigned".
|
protected static int |
VALUE_SIZE_GRANULARITY |
Modifier | Constructor and Description |
---|---|
protected |
HashSlotArrayBase(long unassignedSentinel,
long offsetOfUnassignedSentinel,
MemoryManager mm,
MemoryAllocator auxMalloc,
int keyLength,
int valueLength,
int initialCapacity,
float loadFactor)
Constructs a new
HashSlotArrayImpl with the given initial capacity and the load factor. |
Modifier and Type | Method and Description |
---|---|
long |
address() |
protected void |
allocateArrayAndAdjustFields(long size,
long newCapacity) |
protected void |
assertValid() |
long |
capacity() |
void |
clear()
After this method returns, all slots in the current hash slot array are unassigned.
|
void |
dispose()
Disposes this object and releases any data and/or resources associated
with it.
|
protected SlotAssignmentResult |
ensure0(long key1,
long key2) |
protected boolean |
equal(long key1a,
long key2a,
long key1b,
long key2b) |
long |
expansionThreshold()
Array expansion and rehashing will be triggered when
size reaches this value. |
protected long |
get0(long key1,
long key2) |
void |
gotoAddress(long address)
Position this flyweight to the supplied base address.
|
long |
gotoNew()
Allocate a new array and position this flyweight to its base address.
|
protected boolean |
isAssigned(long baseAddress,
long slot) |
protected long |
key1OfSlot(long baseAddress,
long slot) |
protected long |
key2OfSlot(long baseAddress,
long slot) |
protected long |
keyHash(long key1,
long key2) |
protected MemoryAllocator |
malloc() |
protected void |
markUnassigned(long baseAddress,
long slot) |
protected MemoryAccessor |
mem() |
void |
migrateTo(MemoryAllocator newMalloc)
Migrates the backing memory region to a new allocator, freeing the current region.
|
protected void |
putKey(long baseAddress,
long slot,
long key1,
long key2) |
protected void |
rehash(long oldCapacity,
long oldAddress) |
protected boolean |
remove0(long key1,
long key2) |
protected void |
resizeTo(long newCapacity)
Allocates a new slot array with the requested size and moves all the
assigned slots from the current array into the new one.
|
protected void |
setMemMgr(MemoryManager memoryManager) |
protected void |
shiftConflictingKeys(long slotCurr)
Shift all the slot-conflicting keys allocated to (and including)
slot . |
long |
size() |
protected long |
slotBase(long baseAddr,
long slot) |
protected long |
slotHash(long baseAddress,
long slot) |
boolean |
trimToSize()
Compact the array by reducing its capacity, if allowed by the current size and load factor.
|
public static final int HEADER_SIZE
public static final int CAPACITY_OFFSET
public static final int SIZE_OFFSET
public static final int EXPAND_THRESHOLD_OFFSET
protected static final int VALUE_SIZE_GRANULARITY
protected static final int KEY_1_OFFSET
protected static final int KEY_2_OFFSET
protected final long unassignedSentinel
protected final long offsetOfUnassignedSentinel
protected final int slotLength
protected HashSlotArrayBase(long unassignedSentinel, long offsetOfUnassignedSentinel, MemoryManager mm, MemoryAllocator auxMalloc, int keyLength, int valueLength, int initialCapacity, float loadFactor)
HashSlotArrayImpl
with the given initial capacity and the load factor.
valueLength
must be a factor of 8. Does not allocate any memory, therefore
the instance is unusable until one of the goto...
methods is called.unassignedSentinel
- the value to be used to mark an unassigned slotoffsetOfUnassignedSentinel
- offset (from each slot's base address) where the unassigned sentinel is keptmm
- the memory managerauxMalloc
- memory allocator to use for temporary storage during resizing. Its memory must be accessible
by the supplied memory manager's accessor.keyLength
- length of key in bytesvalueLength
- length of value in bytesinitialCapacity
- Initial capacity of map (will be rounded to closest power of 2, if not already)public final long address()
address
in interface HashSlotArray
public final void gotoAddress(long address)
HashSlotArray
gotoAddress
in interface HashSlotArray
public final long gotoNew()
HashSlotArray
gotoNew
in interface HashSlotArray
public final long size()
size
in interface HashSlotArray
public final long capacity()
capacity
in interface HashSlotArray
public final long expansionThreshold()
HashSlotArray
size
reaches this value.expansionThreshold
in interface HashSlotArray
public final void clear()
HashSlotArray
clear
in interface HashSlotArray
public final boolean trimToSize()
HashSlotArray
trimToSize
in interface HashSlotArray
public final void dispose()
Disposable
dispose
in interface Disposable
public final void migrateTo(MemoryAllocator newMalloc)
protected final SlotAssignmentResult ensure0(long key1, long key2)
protected final long get0(long key1, long key2)
protected final boolean remove0(long key1, long key2)
protected final void shiftConflictingKeys(long slotCurr)
slot
.protected final void allocateArrayAndAdjustFields(long size, long newCapacity)
protected final void rehash(long oldCapacity, long oldAddress)
protected final void setMemMgr(MemoryManager memoryManager)
protected final void assertValid()
protected final MemoryAllocator malloc()
protected final MemoryAccessor mem()
protected final long slotBase(long baseAddr, long slot)
protected void resizeTo(long newCapacity)
protected long key1OfSlot(long baseAddress, long slot)
protected long key2OfSlot(long baseAddress, long slot)
protected boolean isAssigned(long baseAddress, long slot)
protected void markUnassigned(long baseAddress, long slot)
protected void putKey(long baseAddress, long slot, long key1, long key2)
protected long keyHash(long key1, long key2)
protected long slotHash(long baseAddress, long slot)
protected boolean equal(long key1a, long key2a, long key1b, long key2b)
Copyright © 2020 Hazelcast, Inc.. All Rights Reserved.