public final class HashSlotArray12byteKeyImpl extends HashSlotArrayBase implements HashSlotArray12byteKey
HashSlotArray8byteKey
as a restriction of HashSlotArrayBase
to a case where just key1
is used.
This class uses the first 4 bytes of the value block for the unassigned sentinel.
It is the responsibility of the caller to ensure that the unassigned sentinel
is overwritten with a non-sentinel value as soon as a new slot is assigned (after calling
ensure(long, int)
and getting a positive return value).
For the same reason this class must not be instantiated with zero value length. Use
HashSlotArray8byteKeyNoValue
as a zero-length key implementation.
HashSlotArrayBase.Cursor, HashSlotArrayBase.CursorIntKey2, HashSlotArrayBase.CursorLongKey2
CAPACITY_OFFSET, EXPAND_THRESHOLD_OFFSET, HEADER_SIZE, KEY_1_OFFSET, KEY_2_OFFSET, offsetOfUnassignedSentinel, SIZE_OFFSET, slotLength, unassignedSentinel, VALUE_SIZE_GRANULARITY
Constructor and Description |
---|
HashSlotArray12byteKeyImpl(int unassignedSentinel,
MemoryManager mm,
int valueLength) |
HashSlotArray12byteKeyImpl(int unassignedSentinel,
MemoryManager mm,
int valueLength,
int initialCapacity,
float loadFactor) |
Modifier and Type | Method and Description |
---|---|
HashSlotCursor12byteKey |
cursor()
Returns a cursor over all assigned slots in this array.
|
SlotAssignmentResult |
ensure(long key1,
int key2)
Ensures that there is a mapping from
(key1, key2) to a slot in the array. |
long |
get(long key1,
int key2)
Returns the address of the value block mapped by
(key1, key2) . |
protected boolean |
isAssigned(long baseAddress,
long slot) |
protected long |
key2OfSlot(long baseAddress,
long slot) |
protected long |
keyHash(long key1,
long key2) |
protected void |
markUnassigned(long baseAddress,
long slot) |
protected void |
putKey(long baseAddress,
long slot,
long key1,
long key2) |
boolean |
remove(long key1,
int key2)
Removes the mapping for
(key1, key2) , if any. |
address, allocateArrayAndAdjustFields, assertValid, capacity, clear, dispose, ensure0, equal, expansionThreshold, get0, gotoAddress, gotoNew, key1OfSlot, malloc, mem, migrateTo, rehash, remove0, resizeTo, setMemMgr, shiftConflictingKeys, size, slotBase, slotHash, trimToSize
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
address, capacity, clear, expansionThreshold, gotoAddress, gotoNew, size, trimToSize
dispose
public HashSlotArray12byteKeyImpl(int unassignedSentinel, MemoryManager mm, int valueLength, int initialCapacity, float loadFactor)
public HashSlotArray12byteKeyImpl(int unassignedSentinel, MemoryManager mm, int valueLength)
public SlotAssignmentResult ensure(long key1, int key2)
(key1, key2)
to a slot in the array.
The returned object contains the slot value block address and whether a new
slot had to be assigned. The hash slot array implementation keeps a reference
to the returned object and will always return the same instance, albeit with
updated fields on each new invocation.
This means the returned object is valid until the next invocation of this
method.
Whenever this method returns a newly assigned slot, the caller must ensure that the null-sentinel value at the returned address is overwritten with a non-sentinel value.
ensure
in interface HashSlotArray12byteKey
key1
- key part 1key2
- key part 2SlotAssignmentResult.isNew()
public long get(long key1, int key2)
HashSlotArray12byteKey
(key1, key2)
.get
in interface HashSlotArray12byteKey
key1
- key part 1key2
- key part 2MemoryAllocator.NULL_ADDRESS
if no mapping for (key1, key2)
exists.public boolean remove(long key1, int key2)
HashSlotArray12byteKey
(key1, key2)
, if any.remove
in interface HashSlotArray12byteKey
key1
- key part 1key2
- key part 2public HashSlotCursor12byteKey cursor()
HashSlotArray12byteKey
cursor
in interface HashSlotArray12byteKey
protected long key2OfSlot(long baseAddress, long slot)
key2OfSlot
in class HashSlotArrayBase
protected void putKey(long baseAddress, long slot, long key1, long key2)
putKey
in class HashSlotArrayBase
protected void markUnassigned(long baseAddress, long slot)
markUnassigned
in class HashSlotArrayBase
protected boolean isAssigned(long baseAddress, long slot)
isAssigned
in class HashSlotArrayBase
protected long keyHash(long key1, long key2)
keyHash
in class HashSlotArrayBase
Copyright © 2021 Hazelcast, Inc.. All Rights Reserved.