code: static final void resize(final WritableMemory mem, final int preambleLongs,
        final int srcLgArrLongs, final int tgtLgArrLongs) {
      //Note: This copies the Memory data onto the heap and then at the end copies the result
      // back to Memory. Even if we tried to do this directly into Memory it would require pre-clearing,
      // and the internal loops would be slower. The bulk copies are performed at a low level and
      // are quite fast. Measurements reveal that we are not paying much of a penalty.
  
      //Preamble stays in place
      final int preBytes = preambleLongs << 3;
      //Bulk copy source to on-heap buffer
      final int srcHTLen = 1 << srcLgArrLongs; //current value
      final long[] srcHTArr = new long[srcHTLen]; //on-heap src buffer
      mem.getLongArray(preBytes, srcHTArr, 0, srcHTLen);
      //Create destination on-heap buffer
      final int dstHTLen = 1 << tgtLgArrLongs;
      final long[] dstHTArr = new long[dstHTLen]; //on-heap dst buffer
      //Rebuild hash table in destination buffer
      final long thetaLong = extractThetaLong(mem);
      HashOperations.hashArrayInsert(srcHTArr, dstHTArr, tgtLgArrLongs, thetaLong);
      //Bulk copy to destination memory
      mem.putLongArray(preBytes, dstHTArr, 0, dstHTLen);  //put it back, no need to clear
      insertLgArrLongs(mem, tgtLgArrLongs); //update in mem
    }
docs: Resizes existing hash array into a larger one within a single Memory assuming enough space.
  This assumes a Memory preamble of standard form with the correct value of thetaLong.
  The Memory lgArrLongs will change.
  Afterwards, the caller must update local copies of lgArrLongs and hashTableThreshold from
  Memory.
  
  @param mem the Memory
  @param preambleLongs the size of the preamble in longs
  @param srcLgArrLongs the size of the source hash table
  @param tgtLgArrLongs the LgArrLongs value for the new hash table