List of usage examples for org.apache.spark.unsafe.array LongArray get
public long get(int index)
From source file:edu.ucla.cs.wis.bigdatalog.spark.storage.map.BytesToBytesMap.java
License:Apache License
/** * Grows the size of the hash table and re-hash everything. *//*from w ww . j a va 2 s .c o m*/ @VisibleForTesting void growAndRehash() { assert (longArray != null); long resizeStartTime = -1; if (enablePerfMetrics) { resizeStartTime = System.nanoTime(); } // Store references to the old data structures to be used when we re-hash final LongArray oldLongArray = longArray; final int oldCapacity = (int) oldLongArray.size() / 2; // Allocate the new data structures allocate(Math.min(growthStrategy.nextCapacity(oldCapacity), MAX_CAPACITY)); // Re-mask (we don't recompute the hashcode because we stored all 32 bits of it) for (int i = 0; i < oldLongArray.size(); i += 2) { final long keyPointer = oldLongArray.get(i); if (keyPointer == 0) { continue; } final int hashcode = (int) oldLongArray.get(i + 1); int newPos = hashcode & mask; int step = 1; while (longArray.get(newPos * 2) != 0) { newPos = (newPos + step) & mask; step++; } longArray.set(newPos * 2, keyPointer); longArray.set(newPos * 2 + 1, hashcode); } freeArray(oldLongArray); if (enablePerfMetrics) { timeSpentResizingNs += System.nanoTime() - resizeStartTime; } }