OrderedMap a.k.a. FastMap is a general purpose off-heap hash table used to store intermediate data of join, group by, sample by queries, but not only. It provides MapKey and MapValue, as well as RecordCursor interfaces for data access and modification. The preferred way to cr
| 96 | * Length field is present for var-size keys only. It stores key length in bytes. |
| 97 | */ |
| 98 | public class OrderedMap implements Map, Reopenable { |
| 99 | static final long VAR_KEY_HEADER_SIZE = 4; |
| 100 | private static final long MAX_HEAP_SIZE = (Integer.toUnsignedLong(-1) - 1) << 3; |
| 101 | private static final int MIN_KEY_CAPACITY = 16; |
| 102 | |
| 103 | private final OrderedMapCursor cursor; |
| 104 | private final int heapMemoryTag; |
| 105 | private final Key key; |
| 106 | private final long keyOffset; |
| 107 | // Set to -1 when key is var-size. |
| 108 | private final long keySize; |
| 109 | private final int listMemoryTag; |
| 110 | private final double loadFactor; |
| 111 | private final int maxResizes; |
| 112 | private final MergeFunction mergeRef; |
| 113 | private final OrderedMapRecord record; |
| 114 | private final FlyweightPackedMapValue value; |
| 115 | private final FlyweightPackedMapValue value2; |
| 116 | private final FlyweightPackedMapValue value3; |
| 117 | private final int valueColumnCount; |
| 118 | private final long valueSize; |
| 119 | private long batchEmptyValueStart; |
| 120 | private int free; |
| 121 | private long heapAddr; // Heap memory start pointer. |
| 122 | private long heapLimit; // Heap memory limit pointer. |
| 123 | private long heapSize; |
| 124 | private long initialHeapSize; |
| 125 | private int initialKeyCapacity; |
| 126 | private long kPos; // Current key-value memory pointer (contains searched key / pending key-value pair). |
| 127 | private int keyCapacity; |
| 128 | private int mask; |
| 129 | private int nResizes; |
| 130 | // Holds a list of [compressed_offset, hash_code] pairs. |
| 131 | // Offsets are shifted by +1 (0 -> 1, 1 -> 2, etc.), so that we fill the memory with 0. |
| 132 | // Lowest 32 bits of hash code can be used to obtain an entry index since |
| 133 | // maximum number of entries in the map is limited with 32-bit compressed offsets. |
| 134 | private long offsetsAddr; |
| 135 | private int size = 0; |
| 136 | |
| 137 | public OrderedMap( |
| 138 | long heapSize, |
| 139 | @Transient @NotNull ColumnTypes keyTypes, |
| 140 | int keyCapacity, |
| 141 | double loadFactor, |
| 142 | int maxResizes |
| 143 | ) { |
| 144 | this(heapSize, keyTypes, null, keyCapacity, loadFactor, maxResizes); |
| 145 | } |
| 146 | |
| 147 | public OrderedMap( |
| 148 | long heapSize, |
| 149 | @Transient @NotNull ColumnTypes keyTypes, |
| 150 | @Transient @Nullable ColumnTypes valueTypes, |
| 151 | int keyCapacity, |
| 152 | double loadFactor, |
| 153 | int maxResizes, |
| 154 | int memoryTag |
| 155 | ) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…