Unordered4Map is a general purpose off-heap hash table with 4 byte keys (INT, IPv4, SYMBOL) used to store intermediate data of group by, sample by queries. It provides MapKey and MapValue, as well as RecordCursor interfaces for data access and modification. The preferred way
| 86 | * </pre> |
| 87 | */ |
| 88 | public class Unordered4Map implements Map, Reopenable { |
| 89 | static final long KEY_SIZE = Integer.BYTES; |
| 90 | private static final int MIN_KEY_CAPACITY = 16; |
| 91 | |
| 92 | private final Unordered4MapCursor cursor; |
| 93 | private final long entrySize; |
| 94 | private final Key key; |
| 95 | private final double loadFactor; |
| 96 | private final int maxResizes; |
| 97 | private final int memoryTag; |
| 98 | private final Unordered4MapRecord record; |
| 99 | private final FlyweightPackedMapValue value; |
| 100 | private final FlyweightPackedMapValue value2; |
| 101 | private final FlyweightPackedMapValue value3; |
| 102 | private final long valueSize; |
| 103 | private long batchEmptyValueStart; |
| 104 | private int free; |
| 105 | private boolean hasZero; |
| 106 | private int initialKeyCapacity; |
| 107 | private int keyCapacity; |
| 108 | private long mask; |
| 109 | private long memLimit; // Hash table memory limit pointer. |
| 110 | private long memStart; // Hash table memory start pointer. |
| 111 | private int nResizes; |
| 112 | private int size = 0; |
| 113 | private long zeroMemStart; // Zero key-value pair memory start pointer. |
| 114 | |
| 115 | public Unordered4Map( |
| 116 | int keyType, |
| 117 | @Transient @Nullable ColumnTypes valueTypes, |
| 118 | int keyCapacity, |
| 119 | double loadFactor, |
| 120 | int maxResizes |
| 121 | ) { |
| 122 | this(keyType, valueTypes, keyCapacity, loadFactor, maxResizes, MemoryTag.NATIVE_UNORDERED_MAP); |
| 123 | } |
| 124 | |
| 125 | Unordered4Map( |
| 126 | int keyType, |
| 127 | @Nullable @Transient ColumnTypes valueTypes, |
| 128 | int keyCapacity, |
| 129 | double loadFactor, |
| 130 | int maxResizes, |
| 131 | int memoryTag |
| 132 | ) { |
| 133 | assert loadFactor > 0 && loadFactor < 1d; |
| 134 | |
| 135 | try { |
| 136 | this.memoryTag = memoryTag; |
| 137 | this.loadFactor = loadFactor; |
| 138 | this.keyCapacity = (int) (keyCapacity / loadFactor); |
| 139 | this.keyCapacity = this.initialKeyCapacity = Math.max(Numbers.ceilPow2(this.keyCapacity), MIN_KEY_CAPACITY); |
| 140 | this.maxResizes = maxResizes; |
| 141 | mask = this.keyCapacity - 1; |
| 142 | free = (int) (this.keyCapacity * loadFactor); |
| 143 | nResizes = 0; |
| 144 | |
| 145 | if (!isSupportedKeyType(keyType)) { |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…