@@ -109,7 +109,7 @@ public final class BytesToBytesMap {
109109 * Position {@code 2 * i} in the array is used to track a pointer to the key at index {@code i},
110110 * while position {@code 2 * i + 1} in the array holds key's full 32-bit hashcode.
111111 */
112- private LongArray longArray ;
112+ @ Nullable private LongArray longArray ;
113113 // TODO: we're wasting 32 bits of space here; we can probably store fewer bits of the hashcode
114114 // and exploit word-alignment to use fewer bits to hold the address. This might let us store
115115 // only one long per map entry, increasing the chance that this array will fit in cache at the
@@ -124,7 +124,7 @@ public final class BytesToBytesMap {
124124 * A {@link BitSet} used to track location of the map where the key is set.
125125 * Size of the bitset should be half of the size of the long array.
126126 */
127- private BitSet bitset ;
127+ @ Nullable private BitSet bitset ;
128128
129129 private final double loadFactor ;
130130
@@ -323,6 +323,9 @@ public Location lookup(
323323 Object keyBaseObject ,
324324 long keyBaseOffset ,
325325 int keyRowLengthBytes ) {
326+ assert (bitset != null );
327+ assert (longArray != null );
328+
326329 if (enablePerfMetrics ) {
327330 numKeyLookups ++;
328331 }
@@ -412,6 +415,7 @@ private void updateAddressesAndSizes(final Object page, final long offsetInPage)
412415 }
413416
414417 private Location with (int pos , int keyHashcode , boolean isDefined ) {
418+ assert (longArray != null );
415419 this .pos = pos ;
416420 this .isDefined = isDefined ;
417421 this .keyHashcode = keyHashcode ;
@@ -527,6 +531,9 @@ public boolean putNewKey(
527531 assert (!isDefined ) : "Can only set value once for a key" ;
528532 assert (keyLengthBytes % 8 == 0 );
529533 assert (valueLengthBytes % 8 == 0 );
534+ assert (bitset != null );
535+ assert (longArray != null );
536+
530537 if (numElements == MAX_CAPACITY ) {
531538 throw new IllegalStateException ("BytesToBytesMap has reached maximum capacity" );
532539 }
@@ -693,7 +700,9 @@ public long getTotalMemoryConsumption() {
693700 for (MemoryBlock dataPage : dataPages ) {
694701 totalDataPagesSize += dataPage .size ();
695702 }
696- return totalDataPagesSize + bitset .memoryBlock ().size () + longArray .memoryBlock ().size ();
703+ return totalDataPagesSize +
704+ ((bitset != null ) ? bitset .memoryBlock ().size () : 0L ) +
705+ ((longArray != null ) ? longArray .memoryBlock ().size () : 0L );
697706 }
698707
699708 private void updatePeakMemoryUsed () {
@@ -748,6 +757,9 @@ int getNumDataPages() {
748757 */
749758 @ VisibleForTesting
750759 void growAndRehash () {
760+ assert (bitset != null );
761+ assert (longArray != null );
762+
751763 long resizeStartTime = -1 ;
752764 if (enablePerfMetrics ) {
753765 resizeStartTime = System .nanoTime ();
0 commit comments