Example usage for org.apache.spark.unsafe.array ByteArrayMethods nextPowerOf2

List of usage examples for org.apache.spark.unsafe.array ByteArrayMethods nextPowerOf2

Introduction

In this page you can find the example usage for org.apache.spark.unsafe.array ByteArrayMethods nextPowerOf2.

Prototype

public static long nextPowerOf2(long num) 

Source Link

Document

Returns the next number greater or equal num that is power of 2.

Usage

From source file:edu.ucla.cs.wis.bigdatalog.spark.storage.map.BytesToBytesMap.java

License:Apache License

/**
 * Allocate new data structures for this map. When calling this outside of the constructor,
 * make sure to keep references to the old data structures so that you can free them.
 *
 * @param capacity the new map capacity/*from  www .ja  v a 2  s.  c om*/
 */
private void allocate(int capacity) {
    assert (capacity >= 0);
    capacity = Math.max((int) Math.min(MAX_CAPACITY, ByteArrayMethods.nextPowerOf2(capacity)), 64);
    assert (capacity <= MAX_CAPACITY);
    longArray = allocateArray(capacity * 2);
    longArray.zeroOut();

    this.growthThreshold = (int) (capacity * loadFactor);
    this.mask = capacity - 1;
}